SDL: API to change mouse mode on the fly

This commit is contained in:
Sergii Pylypenko
2017-01-27 22:57:06 +02:00
parent fc3265c289
commit c23b64cdaf
5 changed files with 37 additions and 6 deletions

View File

@@ -49,9 +49,6 @@ LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) $(filter-out $(APP_AVAILABLE_STATIC
LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
$(warning APP LOCAL_SHARED_LIBRARIES $(LOCAL_SHARED_LIBRARIES))
$(warning APP LOCAL_STATIC_LIBRARIES $(LOCAL_STATIC_LIBRARIES))
APP_STL := gnustl_static
LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog -lz # -lgnustl_static

View File

@@ -689,11 +689,12 @@ int main(int argc, char* argv[])
if(evt.key.keysym.sym == SDLK_0)
{
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 1);
SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
}
if(evt.key.keysym.sym == SDLK_1)
{
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 0);
SDL_ANDROID_OpenExternalWebBrowser("http:/google.com/");
SDL_ANDROID_SetMouseEmulationMode(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
}
if(evt.key.keysym.sym == SDLK_2)
{

View File

@@ -13,7 +13,7 @@ LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_SHARED_LIBRARIES := freetype expat
LOCAL_LDLIBS := -lz
#LOCAL_LDLIBS := -lz
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \

View File

@@ -134,9 +134,21 @@ enum {
/* TODO: more options, see Globals.java */
};
/* Set SDL Android-specifc option, such as video depth or mouse emulation mode. Most options require restarting the app. */
/* Set SDL Android-specifc option, and save it to SDL config file, such as video depth or mouse emulation mode. Most options require restarting the app. */
extern DECLSPEC void SDLCALL SDL_ANDROID_SetConfigOption(int option, int value);
/* Change mouse emulation mode, pass -1 to any option to keep the current value, this does not change SDL config file.
Currently only relativeMovement is processed, other options are ignored */
extern DECLSPEC void SDLCALL SDL_ANDROID_SetMouseEmulationMode(
int relativeMovement, int relativeMovementSpeed, int relativeMovementAcceleration,
int leftClickMode, int leftClickKey, int leftClickTimeout,
int rightClickMode, int rightClickKey, int rightClickTimeout,
int moveMouseWithJoystick, int moveMouseWithJoystickSpeed, int moveMouseWithJoystickAcceleration,
int moveMouseWithGyroscope, int moveMouseWithGyroscopeSpeed,
int forceHardwareMouse, int showScreenUnderFinger,
int fingerHover, int fingerHoverJitterFilter, int generateSubframeTouchEvents
);
#ifdef __cplusplus
}
#endif

View File

@@ -1179,6 +1179,27 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) (JNIEnv* env, jobject thiz,
}
}
void SDLCALL SDL_ANDROID_SetMouseEmulationMode(
int _relativeMovement, int _relativeMovementSpeed, int _relativeMovementAcceleration,
int _leftClickMode, SDLKey _leftClickKey, int _leftClickTimeout,
int _rightClickMode, SDLKey _rightClickKey, int _rightClickTimeout,
int _moveMouseWithJoystick, int _moveMouseWithJoystickSpeed, int _moveMouseWithJoystickAcceleration,
int _moveMouseWithGyroscope, int _moveMouseWithGyroscopeSpeed,
int _forceHardwareMouse, int _showScreenUnderFinger,
int _fingerHover, int _fingerHoverJitterFilter, int _generateSubframeTouchEvents
)
{
relativeMovement = _relativeMovement;
if (relativeMovement)
{
leftClickMethod = LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
}
else
{
leftClickMethod = LEFT_CLICK_NORMAL;
}
}
typedef struct
{
int leftClickMethod;