mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Sync with cocos2d-x v3 branch ddb4dc8 commit.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
@@ -41,11 +41,13 @@ THE SOFTWARE.
|
||||
#include <android/api-level.h>
|
||||
#include <jni.h>
|
||||
|
||||
#define LOG_TAG "main"
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||
#define LOG_TAG "main"
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||
|
||||
void cocos_android_app_init(JNIEnv* env) __attribute__((weak));
|
||||
|
||||
void cocos_audioengine_focus_change(int focusChange);
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
extern "C"
|
||||
@@ -56,32 +58,32 @@ extern "C"
|
||||
#if __ANDROID_API__ > 19
|
||||
#include <signal.h>
|
||||
#include <dlfcn.h>
|
||||
typedef __sighandler_t (*bsd_signal_func_t)(int, __sighandler_t);
|
||||
bsd_signal_func_t bsd_signal_func = NULL;
|
||||
typedef __sighandler_t (*bsd_signal_func_t)(int, __sighandler_t);
|
||||
bsd_signal_func_t bsd_signal_func = NULL;
|
||||
|
||||
__sighandler_t bsd_signal(int s, __sighandler_t f) {
|
||||
if (bsd_signal_func == NULL) {
|
||||
// For now (up to Android 7.0) this is always available
|
||||
bsd_signal_func = (bsd_signal_func_t) dlsym(RTLD_DEFAULT, "bsd_signal");
|
||||
__sighandler_t bsd_signal(int s, __sighandler_t f) {
|
||||
if (bsd_signal_func == NULL) {
|
||||
// For now (up to Android 7.0) this is always available
|
||||
bsd_signal_func = (bsd_signal_func_t) dlsym(RTLD_DEFAULT, "bsd_signal");
|
||||
|
||||
if (bsd_signal_func == NULL) {
|
||||
__android_log_assert("", "bsd_signal_wrapper", "bsd_signal symbol not found!");
|
||||
}
|
||||
if (bsd_signal_func == NULL) {
|
||||
__android_log_assert("", "bsd_signal_wrapper", "bsd_signal symbol not found!");
|
||||
}
|
||||
}
|
||||
return bsd_signal_func(s, f);
|
||||
}
|
||||
|
||||
return bsd_signal_func(s, f);
|
||||
}
|
||||
#endif // __ANDROID_API__ > 19
|
||||
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
JniHelper::setJavaVM(vm);
|
||||
|
||||
cocos_android_app_init(JniHelper::getEnv());
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
auto director = cocos2d::Director::getInstance();
|
||||
auto glview = director->getOpenGLView();
|
||||
@@ -122,6 +124,11 @@ JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNI
|
||||
return glContextAttrsJava;
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxAudioFocusManager_nativeOnAudioFocusChange(JNIEnv* env, jobject thiz, jint focusChange)
|
||||
{
|
||||
cocos_audioengine_focus_change(focusChange);
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
cocos2d::Application::getInstance()->applicationScreenSizeChanged(w, h);
|
||||
|
||||
Reference in New Issue
Block a user