Commit 988e5158 authored by fallenstardust's avatar fallenstardust Committed by GitHub

Merge pull request #50 from 247321453/master

适配arm64
parents f40255df b8c425d2
...@@ -17,7 +17,6 @@ LOCAL_SRC_FILES := \ ...@@ -17,7 +17,6 @@ LOCAL_SRC_FILES := \
bufferevent_ratelim.c \ bufferevent_ratelim.c \
bufferevent_sock.c \ bufferevent_sock.c \
epoll.c \ epoll.c \
epoll_sub.c \
evdns.c \ evdns.c \
event.c \ event.c \
event_tagging.c \ event_tagging.c \
...@@ -35,6 +34,9 @@ LOCAL_SRC_FILES := \ ...@@ -35,6 +34,9 @@ LOCAL_SRC_FILES := \
signal.c \ signal.c \
strlcpy.c strlcpy.c
# android has <sys/epoll.h>
# LOCAL_SRC_FILES += epoll_sub.c
LOCAL_C_INCLUDES := $(LOCAL_PATH) \ LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/android \ $(LOCAL_PATH)/android \
$(LOCAL_PATH)/include \ $(LOCAL_PATH)/include \
......
...@@ -32,21 +32,31 @@ ...@@ -32,21 +32,31 @@
#include <sys/epoll.h> #include <sys/epoll.h>
#include <unistd.h> #include <unistd.h>
//http://androidxref.com/9.0.0_r3/xref/bionic/libc/bionic/sys_epoll.cpp
int int
epoll_create(int size) epoll_create(int size)
{ {
return (syscall(__NR_epoll_create, size)); #ifdef __LP64__
return (int)(syscall(__NR_epoll_create1, size));
#else
return (int)(syscall(__NR_epoll_create, size));
#endif
} }
int int
epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
{ {
return (syscall(__NR_epoll_ctl, epfd, op, fd, event)); return (int)(syscall(__NR_epoll_ctl, epfd, op, fd, event));
} }
int int
epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
{ {
return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); #ifdef __LP64__
return (int)(syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0));
#else
return (int)(syscall(__NR_epoll_wait, epfd, events, maxevents, timeout));
#endif
} }
...@@ -13,9 +13,9 @@ buildscript { ...@@ -13,9 +13,9 @@ buildscript {
} }
ext { ext {
compileSdkVersion = 29 compileSdkVersion = 30
//buildToolsVersion = compileSdkVersion+".0.0" //buildToolsVersion = compileSdkVersion+".0.0"
supportVersion = "27.1.0" supportVersion = "30.0.0"
} }
allprojects { allprojects {
......
...@@ -14,3 +14,4 @@ ...@@ -14,3 +14,4 @@
android.enableJetifier=true android.enableJetifier=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
android.injected.testOnly=false
\ No newline at end of file
...@@ -188,7 +188,7 @@ void TouchEventTransferAndroid::set_long_click_handler(int mode) { ...@@ -188,7 +188,7 @@ void TouchEventTransferAndroid::set_long_click_handler(int mode) {
} }
void TouchEventTransferAndroid::long_press_handler(sigval_t info) { void TouchEventTransferAndroid::long_press_handler(sigval_t info) {
int mode = (int)info.sival_ptr; int mode = (int)(long)info.sival_ptr;
char log[256]; char log[256];
sprintf(log, "receve long click %d", mode); sprintf(log, "receve long click %d", mode);
os::Printer::log(log); os::Printer::log(log);
......
...@@ -749,8 +749,8 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) { ...@@ -749,8 +749,8 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity); jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
jmethodID MethodSetHandle = jni->GetMethodID(ClassNativeActivity, jmethodID MethodSetHandle = jni->GetMethodID(ClassNativeActivity,
"setNativeHandle", "(I)V"); "setNativeHandle", "(J)V");
jint code = (int) handle; jlong code = (jlong) handle;
jni->CallVoidMethod(lNativeActivity, MethodSetHandle, code); jni->CallVoidMethod(lNativeActivity, MethodSetHandle, code);
......
...@@ -5,7 +5,8 @@ android { ...@@ -5,7 +5,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 //noinspection ExpiredTargetSdkVersion
targetSdkVersion 26
flavorDimensions "versionCode" flavorDimensions "versionCode"
/* ndk { /* ndk {
moduleName "YGOMobile" moduleName "YGOMobile"
......
APP_ABI := armeabi-v7a x86
APP_ABI := armeabi-v7a x86 arm64-v8a
APP_PLATFORM := android-21 APP_PLATFORM := android-21
#APP_MODULES := YGOMobile #APP_MODULES := YGOMobile
#NDK_TOOLCHAIN_VERSION=4.8 #NDK_TOOLCHAIN_VERSION=4.8
...@@ -7,3 +9,5 @@ APP_ALLOW_MISSING_DEPS=true ...@@ -7,3 +9,5 @@ APP_ALLOW_MISSING_DEPS=true
APP_STL := c++_static APP_STL := c++_static
APP_CPPFLAGS := -Wno-error=format-security -std=gnu++14 -fpermissive -D__cplusplus=201402L APP_CPPFLAGS := -Wno-error=format-security -std=gnu++14 -fpermissive -D__cplusplus=201402L
APP_OPTIM := release APP_OPTIM := release
# 防止路径过长
APP_SHORT_COMMANDS := true
...@@ -24,7 +24,7 @@ const static char secret_key[] = "O2zMfI3gqJYYJSAuCeUkH9J_vm5S_A4Yn8fhrjU3"; ...@@ -24,7 +24,7 @@ const static char secret_key[] = "O2zMfI3gqJYYJSAuCeUkH9J_vm5S_A4Yn8fhrjU3";
* Method: nativeInsertText * Method: nativeInsertText
* Signature: (ILjava/lang/String;)V * Signature: (ILjava/lang/String;)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeInsertText( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeInsertText(
JNIEnv* env, jclass clazz, jint handle, jstring textString) { JNIEnv* env, jclass clazz, jlong handle, jstring textString) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
IGUIEnvironment* irrenv = device->getGUIEnvironment(); IGUIEnvironment* irrenv = device->getGUIEnvironment();
...@@ -112,7 +112,7 @@ JNIEXPORT jbyteArray JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_native ...@@ -112,7 +112,7 @@ JNIEXPORT jbyteArray JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_native
* Method: nativeSetComboBoxSelection * Method: nativeSetComboBoxSelection
* Signature: (II)V * Signature: (II)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetComboBoxSelection( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetComboBoxSelection(
JNIEnv* env, jclass clazz, jint handle, jint idx) { JNIEnv* env, jclass clazz, jlong handle, jint idx) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
IGUIEnvironment* irrenv = device->getGUIEnvironment(); IGUIEnvironment* irrenv = device->getGUIEnvironment();
...@@ -147,7 +147,7 @@ JNIEXPORT jbyteArray JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_native ...@@ -147,7 +147,7 @@ JNIEXPORT jbyteArray JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_native
* Method: nativeSetCheckBoxesSelection * Method: nativeSetCheckBoxesSelection
* Signature: (II)V * Signature: (II)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetCheckBoxesSelection( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetCheckBoxesSelection(
JNIEnv* env, jclass clazz, jint handle, jint idx) { JNIEnv* env, jclass clazz, jlong handle, jint idx) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
IGUIEnvironment* irrenv = device->getGUIEnvironment(); IGUIEnvironment* irrenv = device->getGUIEnvironment();
...@@ -232,7 +232,7 @@ static void* join_game_thread(void* param) { ...@@ -232,7 +232,7 @@ static void* join_game_thread(void* param) {
* Method: nativeRefreshTexture * Method: nativeRefreshTexture
* Signature: (I)V * Signature: (I)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeRefreshTexture( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeRefreshTexture(
JNIEnv* env, jclass clazz, jint handle) { JNIEnv* env, jclass clazz, jlong handle) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
...@@ -255,7 +255,7 @@ static void* join_game_thread(void* param) { ...@@ -255,7 +255,7 @@ static void* join_game_thread(void* param) {
* Method: nativeIgnoreChain * Method: nativeIgnoreChain
* Signature: (IZ)V * Signature: (IZ)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeIgnoreChain( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeIgnoreChain(
JNIEnv* env, jclass clazz, jint handle, jboolean begin) { JNIEnv* env, jclass clazz, jlong handle, jboolean begin) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
if (device->isWindowFocused()) { if (device->isWindowFocused()) {
...@@ -277,7 +277,7 @@ static void* join_game_thread(void* param) { ...@@ -277,7 +277,7 @@ static void* join_game_thread(void* param) {
* Method: nativeReactChain * Method: nativeReactChain
* Signature: (IZ)V * Signature: (IZ)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeReactChain( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeReactChain(
JNIEnv* env, jclass clazz, jint handle, jboolean begin) { JNIEnv* env, jclass clazz, jlong handle, jboolean begin) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
if (device->isWindowFocused()) { if (device->isWindowFocused()) {
...@@ -295,7 +295,7 @@ static void* join_game_thread(void* param) { ...@@ -295,7 +295,7 @@ static void* join_game_thread(void* param) {
} }
JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix( JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix(
JNIEnv* env, jclass clazz, jint handle, jint x, jint y) { JNIEnv* env, jclass clazz, jlong handle, jint x, jint y) {
if(ygo::mainGame) { if(ygo::mainGame) {
__android_log_print(ANDROID_LOG_INFO, "ygo", "setInputFix posX=%d, posY=%d", x, y); __android_log_print(ANDROID_LOG_INFO, "ygo", "setInputFix posX=%d, posY=%d", x, y);
ygo::mainGame->setPositionFix(core::position2di(x, y)); ygo::mainGame->setPositionFix(core::position2di(x, y));
...@@ -324,7 +324,7 @@ static void* cancel_chain_thread(void* param) { ...@@ -324,7 +324,7 @@ static void* cancel_chain_thread(void* param) {
* Method: nativeCancelChain * Method: nativeCancelChain
* Signature: (I)V * Signature: (I)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeCancelChain( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeCancelChain(
JNIEnv* env, jclass clazz, jint handle) { JNIEnv* env, jclass clazz, jlong handle) {
if (handle) { if (handle) {
IrrlichtDevice* device = (IrrlichtDevice*) handle; IrrlichtDevice* device = (IrrlichtDevice*) handle;
if (device->isWindowFocused()) { if (device->isWindowFocused()) {
...@@ -344,7 +344,7 @@ static void* cancel_chain_thread(void* param) { ...@@ -344,7 +344,7 @@ static void* cancel_chain_thread(void* param) {
* Method: nativeJoinGame * Method: nativeJoinGame
* Signature: (ILjava/nio/ByteBuffer;I)V * Signature: (ILjava/nio/ByteBuffer;I)V
*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeJoinGame( */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeJoinGame(
JNIEnv* env, jclass clazz, jint handle, jobject buffer, jint length) { JNIEnv* env, jclass clazz, jlong handle, jobject buffer, jint length) {
void* data = env->GetDirectBufferAddress(buffer); void* data = env->GetDirectBufferAddress(buffer);
s_init_param_buffer = malloc(length); s_init_param_buffer = malloc(length);
memcpy(s_init_param_buffer, data, length); memcpy(s_init_param_buffer, data, length);
......
...@@ -470,7 +470,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -470,7 +470,7 @@ public class YGOMobileActivity extends NativeActivity implements
} }
@Override @Override
public void setNativeHandle(int nativeHandle) { public void setNativeHandle(long nativeHandle) {
IrrlichtBridge.sNativeHandle = nativeHandle; IrrlichtBridge.sNativeHandle = nativeHandle;
} }
......
...@@ -39,27 +39,27 @@ public final class IrrlichtBridge { ...@@ -39,27 +39,27 @@ public final class IrrlichtBridge {
} }
public static int sNativeHandle; public static long sNativeHandle;
//显示卡图 //显示卡图
public static native byte[] nativeBpgImage(byte[] data); public static native byte[] nativeBpgImage(byte[] data);
//插入文本(大概是发送消息) //插入文本(大概是发送消息)
private static native void nativeInsertText(int handle, String text); private static native void nativeInsertText(long handle, String text);
//刷新文字 //刷新文字
private static native void nativeRefreshTexture(int handle); private static native void nativeRefreshTexture(long handle);
//忽略时点 //忽略时点
private static native void nativeIgnoreChain(int handle, boolean begin); private static native void nativeIgnoreChain(long handle, boolean begin);
//强制时点 //强制时点
private static native void nativeReactChain(int handle, boolean begin); private static native void nativeReactChain(long handle, boolean begin);
//取消连锁 //取消连锁
private static native void nativeCancelChain(int handle); private static native void nativeCancelChain(long handle);
private static native void nativeSetCheckBoxesSelection(int handle, int idx); private static native void nativeSetCheckBoxesSelection(long handle, int idx);
private static native void nativeSetComboBoxSelection(int handle, int idx); private static native void nativeSetComboBoxSelection(long handle, int idx);
private static native void nativeJoinGame(int handle, ByteBuffer buffer, int length); private static native void nativeJoinGame(long handle, ByteBuffer buffer, int length);
private static native void nativeSetInputFix(int handle, int x, int y); private static native void nativeSetInputFix(long handle, int x, int y);
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final String TAG = IrrlichtBridge.class.getSimpleName(); private static final String TAG = IrrlichtBridge.class.getSimpleName();
...@@ -205,7 +205,7 @@ public final class IrrlichtBridge { ...@@ -205,7 +205,7 @@ public final class IrrlichtBridge {
int getLocalAddress(); int getLocalAddress();
void setNativeHandle(int nativeHandle); void setNativeHandle(long nativeHandle);
int getPositionX(); int getPositionX();
......
...@@ -6,11 +6,11 @@ android { ...@@ -6,11 +6,11 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
//noinspection ExpiredTargetSdkVersion //noinspection ExpiredTargetSdkVersion
targetSdkVersion 28 targetSdkVersion 26
ndk { ndk {
moduleName "YGOMobile" moduleName "YGOMobile"
abiFilters "armeabi-v7a","x86" abiFilters "armeabi-v7a","x86","arm64-v8a"
} }
} }
......
...@@ -7,32 +7,60 @@ android { ...@@ -7,32 +7,60 @@ android {
defaultConfig { defaultConfig {
applicationId "cn.garymb.ygomobile" applicationId "cn.garymb.ygomobile"
minSdkVersion 21 minSdkVersion 21
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29 targetSdkVersion 29
versionCode 380300525 versionCode 380300525
versionName "3.8.3" versionName "3.8.3"
flavorDimensions "versionCode" flavorDimensions "versionCode"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a", "x86"
}
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
flavorDimensions 'abi', 'lang'
productFlavors { productFlavors {
cn { cn {
dimension 'lang'
manifestPlaceholders = [APP_ID: "0b6f110306"] manifestPlaceholders = [APP_ID: "0b6f110306"]
} }
en { en {
dimension 'lang'
applicationIdSuffix ".EN" applicationIdSuffix ".EN"
manifestPlaceholders = [APP_ID: "9c66525dfa"] manifestPlaceholders = [APP_ID: "9c66525dfa"]
} }
ko { ko {
dimension 'lang'
applicationIdSuffix ".KO" applicationIdSuffix ".KO"
manifestPlaceholders = [APP_ID: "0488398d8a"] manifestPlaceholders = [APP_ID: "0488398d8a"]
} }
x86 {
dimension 'abi'
ndk {
abiFilters "x86"
}
}
arm {
dimension 'abi'
ndk {
abiFilters "armeabi-v7a"
}
}
arm64 {
dimension 'abi'
ndk {
abiFilters "arm64-v8a"
}
}
} }
// splits {
// abi {
// enable true
// reset()
// include 'x86', 'armeabi-v7a', 'arm64-v8a'
// universalApk true
// }
// }
buildTypes { buildTypes {
release { release {
shrinkResources false shrinkResources false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment