1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-28 18:18:52 +00:00
OpenMW/apps/openmw/android_main.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.1 KiB
C++
Raw Normal View History

#ifndef stderr
2018-01-14 23:14:30 +00:00
int stderr = 0; // Hack: fix linker error
#endif
2014-08-04 15:52:01 +00:00
#include "SDL_main.h"
#include <SDL_events.h>
#include <SDL_gamecontroller.h>
#include <SDL_mouse.h>
2014-08-04 15:52:01 +00:00
/*******************************************************************************
2015-03-15 17:15:58 +00:00
Functions called by JNI
*******************************************************************************/
2014-08-04 15:52:01 +00:00
#include <jni.h>
2014-08-05 20:46:21 +00:00
/* Called before to initialize JNI bindings */
2014-08-04 15:52:01 +00:00
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
2015-03-15 17:15:58 +00:00
extern int argcData;
extern const char** argvData;
2015-03-16 14:21:38 +00:00
void releaseArgv();
2015-03-15 17:15:58 +00:00
2019-04-28 21:52:53 +00:00
extern "C" int Java_org_libsdl_app_SDLActivity_getMouseX(JNIEnv* env, jclass cls, jobject obj)
{
int ret = 0;
2019-04-28 21:52:53 +00:00
SDL_GetMouseState(&ret, nullptr);
return ret;
}
2019-04-28 21:52:53 +00:00
extern "C" int Java_org_libsdl_app_SDLActivity_getMouseY(JNIEnv* env, jclass cls, jobject obj)
{
int ret = 0;
2019-04-28 21:52:53 +00:00
SDL_GetMouseState(nullptr, &ret);
return ret;
}
2019-04-28 21:52:53 +00:00
extern "C" int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv* env, jclass cls, jobject obj)
{
return SDL_ShowCursor(SDL_QUERY);
}
extern SDL_Window* Android_Window;
2019-04-28 21:52:53 +00:00
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)
{
SDL_SendMouseMotion(Android_Window, 0, 1, x, y);
}
2019-04-28 21:52:53 +00:00
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)
{
SDL_SendMouseButton(Android_Window, 0, state, button);
}
2019-04-28 21:52:53 +00:00
extern "C" int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
{
2018-01-14 23:14:30 +00:00
setenv("OPENMW_DECOMPRESS_TEXTURES", "1", 1);
// 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");
2018-03-25 01:26:58 +00:00
return 0;
2014-08-04 15:52:01 +00:00
}