}
}
-static boolean checkTextInputKeyModState(void)
+static boolean checkTextInputKey(Key key)
{
- // when playing, only handle raw key events and ignore text input
- if (game_status == GAME_MODE_PLAYING)
- return FALSE;
-
- return ((GetKeyModState() & KMOD_TextInput) != KMOD_None);
+ return (textinput_status && KSYM_PRINTABLE(key));
}
void HandleTextEvent(TextEvent *event)
GetKeyModState());
#endif
-#if !defined(HAS_SCREEN_KEYBOARD)
- // non-mobile devices: only handle key input with modifier keys pressed here
- // (every other key input is handled directly as physical key input event)
- if (!checkTextInputKeyModState())
- return;
-#endif
-
- // process text input as "classic" (with uppercase etc.) key input event
- HandleKey(key, KEY_PRESSED);
- HandleKey(key, KEY_RELEASED);
+ if (checkTextInputKey(key))
+ {
+ // process printable keys (with uppercase etc.) in text input mode
+ HandleKey(key, KEY_PRESSED);
+ HandleKey(key, KEY_RELEASED);
+ }
}
void HandlePauseResumeEvent(PauseResumeEvent *event)
HandleKeyModState(keymod, key_status);
- // only handle raw key input without text modifier keys pressed
- if (!checkTextInputKeyModState())
+ // process all keys if not in text input mode or if non-printable keys
+ if (!checkTextInputKey(key))
HandleKey(key, key_status);
}
#define KSYM_FKEY_LAST KSYM_F12
#define KSYM_NUM_FKEYS (KSYM_FKEY_LAST - KSYM_FKEY_FIRST + 1)
+#define KSYM_PRINTABLE(k) (((k) >= KSYM_space && \
+ (k) <= KSYM_z) || \
+ (k) == KSYM_Adiaeresis || \
+ (k) == KSYM_Odiaeresis || \
+ (k) == KSYM_Udiaeresis || \
+ (k) == KSYM_adiaeresis || \
+ (k) == KSYM_odiaeresis || \
+ (k) == KSYM_udiaeresis)
+
#define KMOD_None KMOD_NONE
#define KMOD_Shift_L KMOD_LSHIFT
#define KMOD_Shift_R KMOD_RSHIFT
KMOD_Meta | \
KMOD_Alt)
-#define KMOD_TextInput (KMOD_Shift | KMOD_Alt_R)
-
// SDL function definitions
boolean SDLSetNativeSurface(SDL_Surface **);
boolean motion_status = FALSE;
int wheel_steps = DEFAULT_WHEEL_STEPS;
boolean keyrepeat_status = TRUE;
+boolean textinput_status = FALSE;
int redraw_mask = REDRAW_NONE;
void StartTextInput(int x, int y, int width, int height)
{
+ textinput_status = TRUE;
+
#if defined(HAS_SCREEN_KEYBOARD)
SDL_StartTextInput();
void StopTextInput(void)
{
+ textinput_status = FALSE;
+
#if defined(HAS_SCREEN_KEYBOARD)
SDL_StopTextInput();