Added SDL_ANDROID_SetScreenKeyboardButtonShown() to hide/show individual buttons
This commit is contained in:
@@ -67,6 +67,8 @@ enum {
|
|||||||
use SDL_ListModes()[0] to determine the actual screen boundaries. */
|
use SDL_ListModes()[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_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos);
|
||||||
|
|
||||||
|
/* Set button image position - it can be smaller than the button area */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonImagePos(int buttonId, SDL_Rect * pos);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonImagePos(int buttonId, SDL_Rect * pos);
|
||||||
|
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonKey(int buttonId,
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonKey(int buttonId,
|
||||||
@@ -89,35 +91,38 @@ extern DECLSPEC
|
|||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardAutoFireButtonsAmount(int nbuttons);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardAutoFireButtonsAmount(int nbuttons);
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardAutoFireButtonsAmount(void);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardAutoFireButtonsAmount(void);
|
||||||
|
|
||||||
/* Hide the whole screen keyboard */
|
/* Hide all on-screen buttons (not the QWERTY text input) */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardShown(int shown);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardShown(int shown);
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardShown(void);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardShown(void);
|
||||||
|
/* Hide individual buttons - this will just put button width and height to 0, but it will save previous button size */
|
||||||
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonShown(int buttonId, int shown);
|
||||||
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardButtonShown(int buttonId);
|
||||||
/* Get the button size modifier, as configured by user with SDL startup menu */
|
/* Get the button size modifier, as configured by user with SDL startup menu */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardSize(void);
|
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 */
|
/* 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);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(int buttonId, int generateEvents);
|
||||||
|
|
||||||
/* Show Android on-screen keyboard, and pass entered text back to application as SDL keypress events,
|
/* 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 */
|
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);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardTextInput(const char * previousText);
|
||||||
|
|
||||||
/* Show only the bare Android on-screen keyboard without any text input field, so it won't cover the screen */
|
/* Show only the bare Android QWERTY keyboard without any text input field, so it won't cover the screen */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(void);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(void);
|
||||||
|
|
||||||
/* Show Android on-screen keyboard, and pass entered text back to application in a buffer,
|
/* Show Android QWERTY keyboard, and pass entered text back to application in a buffer,
|
||||||
using buffer contents as previous text (UTF-8 encoded), the buffer may be of any size -
|
using buffer contents as previous text (UTF-8 encoded), the buffer may be of any size -
|
||||||
this call will block until user typed all text. */
|
this call will block until user typed all text. */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardTextInput(char * textBuf, int textBufSize);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardTextInput(char * textBuf, int textBufSize);
|
||||||
|
|
||||||
/* Whether user redefined on-screen keyboard layout via SDL menu, app should not enforce it's own layout in that case */
|
/* Whether user redefined on-screen keyboard layout via SDL menu, app should not enforce it's own layout in that case */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardRedefinedByUser(void);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardRedefinedByUser(void);
|
||||||
|
|
||||||
/* Set hint message for the text input field, it may be multi-line, set NULL to reset hint to default */
|
/* Set hint message for the QWERTY text input field, it may be multi-line, set NULL to reset hint to default */
|
||||||
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardHintMesage(const char * hint);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardHintMesage(const char * hint);
|
||||||
|
|
||||||
/* API compatible to SDL2, it's a wrapper to the SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(), it does not block */
|
/* API compatible to SDL2, it's a wrapper to the SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(), it does not block.
|
||||||
|
These functions control native Android QWERTY keyboard, not the overlay buttons */
|
||||||
extern DECLSPEC int SDLCALL SDL_HasScreenKeyboardSupport(void *unused);
|
extern DECLSPEC int SDLCALL SDL_HasScreenKeyboardSupport(void *unused);
|
||||||
|
|
||||||
extern DECLSPEC int SDLCALL SDL_ShowScreenKeyboard(void *unused);
|
extern DECLSPEC int SDLCALL SDL_ShowScreenKeyboard(void *unused);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_JOYSTICKS = 2,
|
|||||||
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
|
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
|
||||||
static short touchscreenKeyboardTheme = 0;
|
static short touchscreenKeyboardTheme = 0;
|
||||||
static short touchscreenKeyboardShown = 1;
|
static short touchscreenKeyboardShown = 1;
|
||||||
|
static SDL_Rect hiddenButtons[SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM];
|
||||||
static short AutoFireButtonsNum = 0;
|
static short AutoFireButtonsNum = 0;
|
||||||
static short buttonsize = 1;
|
static short buttonsize = 1;
|
||||||
static short buttonDrawSize = 1;
|
static short buttonDrawSize = 1;
|
||||||
@@ -92,6 +93,7 @@ enum { MOUSE_POINTER_W = 32, MOUSE_POINTER_H = 32, MOUSE_POINTER_X = 5, MOUSE_PO
|
|||||||
static int sunTheme = 0;
|
static int sunTheme = 0;
|
||||||
static int joystickTouchPoints[MAX_JOYSTICKS*2];
|
static int joystickTouchPoints[MAX_JOYSTICKS*2];
|
||||||
|
|
||||||
|
|
||||||
static inline int InsideRect(const SDL_Rect * r, int x, int y)
|
static inline int InsideRect(const SDL_Rect * r, int x, int y)
|
||||||
{
|
{
|
||||||
return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h );
|
return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h );
|
||||||
@@ -779,9 +781,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
|
|||||||
buttons[6].h = SDL_ANDROID_sRealWindowHeight/10;
|
buttons[6].h = SDL_ANDROID_sRealWindowHeight/10;
|
||||||
|
|
||||||
for( i = 0; i < sizeof(pointerInButtonRect)/sizeof(pointerInButtonRect[0]); i++ )
|
for( i = 0; i < sizeof(pointerInButtonRect)/sizeof(pointerInButtonRect[0]); i++ )
|
||||||
{
|
|
||||||
pointerInButtonRect[i] = -1;
|
pointerInButtonRect[i] = -1;
|
||||||
}
|
|
||||||
for( i = 0; i < nbuttonsAutoFire; i++ )
|
for( i = 0; i < nbuttonsAutoFire; i++ )
|
||||||
{
|
{
|
||||||
buttonsAutoFireRect[i].w = buttons[i].w * 2;
|
buttonsAutoFireRect[i].w = buttons[i].w * 2;
|
||||||
@@ -789,14 +789,12 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
|
|||||||
buttonsAutoFireRect[i].x = buttons[i].x - buttons[i].w / 2;
|
buttonsAutoFireRect[i].x = buttons[i].x - buttons[i].w / 2;
|
||||||
buttonsAutoFireRect[i].y = buttons[i].y - buttons[i].h / 2;
|
buttonsAutoFireRect[i].y = buttons[i].y - buttons[i].h / 2;
|
||||||
}
|
}
|
||||||
for(i = 0; i < MAX_JOYSTICKS; i++)
|
for( i = 0; i < MAX_JOYSTICKS; i++ )
|
||||||
{
|
|
||||||
shrinkButtonRect(arrows[i], &arrowsDraw[i]);
|
shrinkButtonRect(arrows[i], &arrowsDraw[i]);
|
||||||
}
|
for( i = 0; i < MAX_BUTTONS; i++ )
|
||||||
for(i = 0; i < MAX_BUTTONS; i++)
|
|
||||||
{
|
|
||||||
shrinkButtonRect(buttons[i], &buttonsDraw[i]);
|
shrinkButtonRect(buttons[i], &buttonsDraw[i]);
|
||||||
}
|
for( i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++ )
|
||||||
|
SDL_ANDROID_GetScreenKeyboardButtonPos(i, &hiddenButtons[i]);
|
||||||
};
|
};
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
@@ -1070,6 +1068,26 @@ int SDL_ANDROID_GetScreenKeyboardShown(void)
|
|||||||
return touchscreenKeyboardShown;
|
return touchscreenKeyboardShown;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int SDL_ANDROID_SetScreenKeyboardButtonShown(int buttonId, int shown)
|
||||||
|
{
|
||||||
|
if( buttonId < 0 || buttonId >= SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( !shown && SDL_ANDROID_GetScreenKeyboardButtonShown(buttonId) )
|
||||||
|
SDL_ANDROID_GetScreenKeyboardButtonPos(buttonId, &hiddenButtons[buttonId]);
|
||||||
|
if( shown && !SDL_ANDROID_GetScreenKeyboardButtonShown(buttonId) )
|
||||||
|
SDL_ANDROID_SetScreenKeyboardButtonPos(buttonId, &hiddenButtons[buttonId]);
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
int SDL_ANDROID_GetScreenKeyboardButtonShown(int buttonId)
|
||||||
|
{
|
||||||
|
SDL_Rect pos;
|
||||||
|
if( !SDL_ANDROID_GetScreenKeyboardButtonPos(buttonId, &pos) )
|
||||||
|
return 0;
|
||||||
|
return pos.h > 0 && pos.w > 0;
|
||||||
|
};
|
||||||
|
|
||||||
int SDL_ANDROID_GetScreenKeyboardSize(void)
|
int SDL_ANDROID_GetScreenKeyboardSize(void)
|
||||||
{
|
{
|
||||||
return buttonsize;
|
return buttonsize;
|
||||||
|
|||||||
Reference in New Issue
Block a user