mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-26 21:41:36 +00:00
Merge pull request #2354 from xyzz/android-cpp
Switch android_main to cpp
This commit is contained in:
commit
8d489793a9
4 changed files with 11 additions and 54 deletions
|
@ -8,8 +8,7 @@ set(GAME
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(GAME ${GAME} android_commandLine.cpp)
|
set(GAME ${GAME} android_main.cpp)
|
||||||
set(GAME ${GAME} android_main.c)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GAME_HEADER
|
set(GAME_HEADER
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#include "android_commandLine.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
const char **argvData;
|
|
||||||
int argcData;
|
|
||||||
|
|
||||||
extern "C" void releaseArgv();
|
|
||||||
|
|
||||||
void releaseArgv() {
|
|
||||||
delete[] argvData;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env,
|
|
||||||
jobject obj, jint argc, jobjectArray stringArray) {
|
|
||||||
jboolean iscopy;
|
|
||||||
argcData = (int) argc;
|
|
||||||
argvData = new const char *[argcData + 1];
|
|
||||||
argvData[0] = "openmw";
|
|
||||||
for (int i = 1; i < argcData + 1; i++) {
|
|
||||||
jstring string = (jstring) (env)->GetObjectArrayElement(stringArray,
|
|
||||||
i - 1);
|
|
||||||
argvData[i] = (env)->GetStringUTFChars(string, &iscopy);
|
|
||||||
(env)->DeleteLocalRef(string);
|
|
||||||
}
|
|
||||||
(env)->DeleteLocalRef(stringArray);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
|
||||||
#include <jni.h>
|
|
||||||
#ifndef _Included_ui_activity_GameActivity_commandLine
|
|
||||||
#define _Included_ui_activity_GameActivity_commandLine
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env, jobject obj,jint argcData, jobjectArray stringArray);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -18,35 +18,35 @@ extern const char **argvData;
|
||||||
void releaseArgv();
|
void releaseArgv();
|
||||||
|
|
||||||
|
|
||||||
int Java_org_libsdl_app_SDLActivity_getMouseX(JNIEnv *env, jclass cls, jobject obj) {
|
extern "C" int Java_org_libsdl_app_SDLActivity_getMouseX(JNIEnv *env, jclass cls, jobject obj) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
SDL_GetMouseState(&ret, NULL);
|
SDL_GetMouseState(&ret, nullptr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Java_org_libsdl_app_SDLActivity_getMouseY(JNIEnv *env, jclass cls, jobject obj) {
|
extern "C" int Java_org_libsdl_app_SDLActivity_getMouseY(JNIEnv *env, jclass cls, jobject obj) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
SDL_GetMouseState(NULL, &ret);
|
SDL_GetMouseState(nullptr, &ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv *env, jclass cls, jobject obj) {
|
extern "C" int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv *env, jclass cls, jobject obj) {
|
||||||
return SDL_ShowCursor(SDL_QUERY);
|
return SDL_ShowCursor(SDL_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern SDL_Window *Android_Window;
|
extern SDL_Window *Android_Window;
|
||||||
int SDL_SendMouseMotion(SDL_Window * window, int mouseID, int relative, int x, int y);
|
extern "C" int SDL_SendMouseMotion(SDL_Window * window, int mouseID, int relative, int x, int y);
|
||||||
void Java_org_libsdl_app_SDLActivity_sendRelativeMouseMotion(JNIEnv *env, jclass cls, int x, int y) {
|
extern "C" void Java_org_libsdl_app_SDLActivity_sendRelativeMouseMotion(JNIEnv *env, jclass cls, int x, int y) {
|
||||||
SDL_SendMouseMotion(Android_Window, 0, 1, x, y);
|
SDL_SendMouseMotion(Android_Window, 0, 1, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SendMouseButton(SDL_Window * window, int mouseID, Uint8 state, Uint8 button);
|
extern "C" int SDL_SendMouseButton(SDL_Window * window, int mouseID, Uint8 state, Uint8 button);
|
||||||
void Java_org_libsdl_app_SDLActivity_sendMouseButton(JNIEnv *env, jclass cls, int state, int button) {
|
extern "C" void Java_org_libsdl_app_SDLActivity_sendMouseButton(JNIEnv *env, jclass cls, int state, int button) {
|
||||||
SDL_SendMouseButton(Android_Window, 0, state, button);
|
SDL_SendMouseButton(Android_Window, 0, state, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) {
|
extern "C" int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) {
|
||||||
setenv("OPENMW_DECOMPRESS_TEXTURES", "1", 1);
|
setenv("OPENMW_DECOMPRESS_TEXTURES", "1", 1);
|
||||||
|
|
||||||
// On Android, we use a virtual controller with guid="Virtual"
|
// On Android, we use a virtual controller with guid="Virtual"
|
Loading…
Reference in a new issue