Option for touchscreen keyboard to keep buttons pressed, to emulate Ctrl/Alt/Shift
This commit is contained in:
@@ -64,7 +64,7 @@ enum {
|
||||
|
||||
/* Set on-screen button position, specify zero width to hide the button.
|
||||
All coordinates are in the actual screen dimensions, NOT what you are supplying to SDL_SetVideoMode(),
|
||||
use SDL_ListModes()[0] to determine the actual screen boundaries. */
|
||||
use SDL_ListModes(NULL, 0)[0] to determine the actual screen boundaries. */
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
|
||||
|
||||
@@ -99,6 +99,12 @@ extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardSize(void);
|
||||
/* Set a particular button to pass a mouse/multitouch events down to the application, by default all buttons block touch events */
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(int buttonId, int generateEvents);
|
||||
|
||||
/* Configure a button to stay pressed after touch, and un-press after second touch, to emulate Ctrl/Alt/Shift keys */
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonStayPressedAfterTouch(int buttonId, int stayPressed);
|
||||
|
||||
/* Set screen keyboard transparency, 255 or SDL_ALPHA_OPAQUE is non-transparent, 0 or SDL_ALPHA_TRANSPARENT is transparent */
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardTransparency(int alpha);
|
||||
|
||||
/* Show Android QWERTY keyboard, and pass entered text back to application as SDL keypress events,
|
||||
previousText is UTF-8 encoded, it may be NULL, only 256 first bytes will be used, and this call will not block */
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardTextInput(const char * previousText);
|
||||
|
||||
@@ -130,7 +130,7 @@ int SDL_ANDROID_currentMouseButtons = 0;
|
||||
static int hardwareMouseDetected = 0;
|
||||
enum { MOUSE_HW_BUTTON_LEFT = 1, MOUSE_HW_BUTTON_RIGHT = 2, MOUSE_HW_BUTTON_MIDDLE = 4, MOUSE_HW_BUTTON_BACK = 8, MOUSE_HW_BUTTON_FORWARD = 16, MOUSE_HW_BUTTON_MAX = MOUSE_HW_BUTTON_FORWARD };
|
||||
enum { MOUSE_HW_INPUT_FINGER = 0, MOUSE_HW_INPUT_STYLUS = 1, MOUSE_HW_INPUT_MOUSE = 2 };
|
||||
enum { DEADZONE_HOVER_FINGER = 32, DEADZONE_HOVER_STYLUS = 64, HOVER_FREEZE_TIME = 500, HOVER_DISTANCE_MAX = 1024 };
|
||||
enum { DEADZONE_HOVER_FINGER = 50, DEADZONE_HOVER_STYLUS = 80, HOVER_FREEZE_TIME = 500, HOVER_DISTANCE_MAX = 1024 };
|
||||
static int hoverJitterFilter = 1;
|
||||
static int hoverX, hoverY, hoverTime = 0, hoverMouseFreeze = 0, hoverDeadzone = 0;
|
||||
static int rightMouseButtonLongPress = 1;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
#define VIDEO_DEBUG 1
|
||||
//#define VIDEO_DEBUG 1
|
||||
|
||||
enum ScreenZoom { ZOOM_NONE = 0, ZOOM_MAGNIFIER = 1 };
|
||||
|
||||
|
||||
@@ -69,8 +69,9 @@ SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_5)),
|
||||
enum { ARROW_LEFT = 1, ARROW_RIGHT = 2, ARROW_UP = 4, ARROW_DOWN = 8 };
|
||||
static short oldArrows = 0;
|
||||
|
||||
static short pointerInButtonRect[MAX_BUTTONS + MAX_JOYSTICKS];
|
||||
static short buttonsGenerateSdlEvents[MAX_BUTTONS + MAX_JOYSTICKS];
|
||||
static Sint8 pointerInButtonRect[MAX_BUTTONS + MAX_JOYSTICKS];
|
||||
static Sint8 buttonsGenerateSdlEvents[MAX_BUTTONS + MAX_JOYSTICKS];
|
||||
static Sint8 buttonsStayPressedAfterTouch[MAX_BUTTONS + MAX_JOYSTICKS];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -410,6 +411,8 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
|
||||
pointerInButtonRect[i] = pointerId;
|
||||
if( i == BUTTON_TEXT_INPUT )
|
||||
SDL_ANDROID_ToggleScreenKeyboardTextInput(NULL);
|
||||
else if( buttonsStayPressedAfterTouch[i] )
|
||||
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] == 0 ? SDL_PRESSED : SDL_RELEASED, buttonKeysyms[i], 0 );
|
||||
else
|
||||
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, buttonKeysyms[i], 0 );
|
||||
}
|
||||
@@ -449,7 +452,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po
|
||||
{
|
||||
processed |= 1<<i;
|
||||
pointerInButtonRect[i] = -1;
|
||||
if( i != BUTTON_TEXT_INPUT )
|
||||
if( i != BUTTON_TEXT_INPUT && !buttonsStayPressedAfterTouch[i] )
|
||||
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i], 0 );
|
||||
}
|
||||
}
|
||||
@@ -984,6 +987,19 @@ int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(int buttonId,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonStayPressedAfterTouch(int buttonId, int stayPressed)
|
||||
{
|
||||
if( buttonId < 0 || buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM )
|
||||
return 0;
|
||||
buttonsStayPressedAfterTouch[buttonId] = stayPressed;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SDLCALL SDL_ANDROID_SetScreenKeyboardTransparency(int alpha)
|
||||
{
|
||||
transparency = (float)alpha / 255.0f;
|
||||
}
|
||||
|
||||
static int ScreenKbRedefinedByUser = 0;
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
||||
Reference in New Issue
Block a user