You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.1 KiB
C++
57 lines
2.1 KiB
C++
7 years ago
|
int stderr = 0; // Hack: fix linker error
|
||
11 years ago
|
|
||
|
#include "SDL_main.h"
|
||
7 years ago
|
#include <SDL_gamecontroller.h>
|
||
7 years ago
|
#include <SDL_mouse.h>
|
||
|
#include <SDL_events.h>
|
||
11 years ago
|
|
||
|
/*******************************************************************************
|
||
10 years ago
|
Functions called by JNI
|
||
|
*******************************************************************************/
|
||
11 years ago
|
#include <jni.h>
|
||
|
|
||
11 years ago
|
/* Called before to initialize JNI bindings */
|
||
11 years ago
|
|
||
|
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
|
||
10 years ago
|
extern int argcData;
|
||
10 years ago
|
extern const char **argvData;
|
||
10 years ago
|
void releaseArgv();
|
||
10 years ago
|
|
||
7 years ago
|
|
||
6 years ago
|
extern "C" int Java_org_libsdl_app_SDLActivity_getMouseX(JNIEnv *env, jclass cls, jobject obj) {
|
||
7 years ago
|
int ret = 0;
|
||
6 years ago
|
SDL_GetMouseState(&ret, nullptr);
|
||
7 years ago
|
return ret;
|
||
|
}
|
||
|
|
||
|
|
||
6 years ago
|
extern "C" int Java_org_libsdl_app_SDLActivity_getMouseY(JNIEnv *env, jclass cls, jobject obj) {
|
||
7 years ago
|
int ret = 0;
|
||
6 years ago
|
SDL_GetMouseState(nullptr, &ret);
|
||
7 years ago
|
return ret;
|
||
|
}
|
||
|
|
||
6 years ago
|
extern "C" int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv *env, jclass cls, jobject obj) {
|
||
7 years ago
|
return SDL_ShowCursor(SDL_QUERY);
|
||
|
}
|
||
|
|
||
7 years ago
|
extern SDL_Window *Android_Window;
|
||
6 years ago
|
extern "C" int SDL_SendMouseMotion(SDL_Window * window, int mouseID, int relative, int x, int y);
|
||
|
extern "C" void Java_org_libsdl_app_SDLActivity_sendRelativeMouseMotion(JNIEnv *env, jclass cls, int x, int y) {
|
||
7 years ago
|
SDL_SendMouseMotion(Android_Window, 0, 1, x, y);
|
||
|
}
|
||
|
|
||
6 years ago
|
extern "C" int SDL_SendMouseButton(SDL_Window * window, int mouseID, Uint8 state, Uint8 button);
|
||
|
extern "C" void Java_org_libsdl_app_SDLActivity_sendMouseButton(JNIEnv *env, jclass cls, int state, int button) {
|
||
7 years ago
|
SDL_SendMouseButton(Android_Window, 0, state, button);
|
||
|
}
|
||
|
|
||
6 years ago
|
extern "C" int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) {
|
||
7 years ago
|
setenv("OPENMW_DECOMPRESS_TEXTURES", "1", 1);
|
||
|
|
||
7 years ago
|
// On Android, we use a virtual controller with guid="Virtual"
|
||
|
SDL_GameControllerAddMapping("5669727475616c000000000000000000,Virtual,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4");
|
||
|
|
||
7 years ago
|
return 0;
|
||
11 years ago
|
}
|