+2014-01-04
+ * fixed remaining text input problems for non-ASCII keys with modifier
+
2014-01-03
* fixed key code problems with certain keys for SDL2
+ (keypad keys not being in numerical order; number of function keys)
* fixed text input problems for text characters using modifier keys
2014-01-02
-#define COMPILE_DATE_STRING "2014-01-04 02:29"
+#define COMPILE_DATE_STRING "2014-01-04 13:44"
#endif
}
+static boolean checkTextInputKeyModState()
+{
+ // 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);
+}
+
void HandleTextEvent(TextEvent *event)
{
char *text = event->text;
Key key = getKeyFromKeyName(text);
#if DEBUG_EVENTS
- Error(ERR_DEBUG, "TEXT EVENT: text == '%s', resulting key == %d (%s)",
+ Error(ERR_DEBUG, "TEXT EVENT: text == '%s' [%d byte(s), '%c'/%d], resulting key == %d (%s)",
text,
+ strlen(text),
+ text[0], (int)(text[0]),
key,
getKeyNameFromKey(key));
#endif
- if (game_status != GAME_MODE_PLAYING && GetKeyModState() != KMOD_None)
+ // if (game_status != GAME_MODE_PLAYING && GetKeyModState() != KMOD_None)
+ /*
+ if (game_status != GAME_MODE_PLAYING &&
+ (GetKeyModState() & KMOD_TextInput) != KMOD_None)
+ */
+ if (checkTextInputKeyModState())
{
HandleKey(key, KEY_PRESSED);
HandleKey(key, KEY_RELEASED);
key = KSYM_Escape;
#endif
-#if defined(TARGET_SDL2)
HandleKeyModState(keymod, key_status);
- if (game_status == GAME_MODE_PLAYING || GetKeyModState() == KMOD_None)
+#if defined(TARGET_SDL2)
+
+ // if (game_status == GAME_MODE_PLAYING || GetKeyModState() == KMOD_None)
+ /*
+ if (game_status == GAME_MODE_PLAYING ||
+ (GetKeyModState() & KMOD_TextInput) == KMOD_None)
+ */
+ if (!checkTextInputKeyModState())
HandleKey(key, key_status);
#else
- HandleKeyModState(keymod, key_status);
HandleKey(key, key_status);
#endif
}
{ KSYM_braceright, "XK_braceright", "brace right" },
{ KSYM_asciitilde, "XK_asciitilde", "~" },
- /* special (non-ASCII) keys */
+ /* special (non-ASCII) keys (ISO-Latin-1) */
{ KSYM_degree, "XK_degree", "°" },
{ KSYM_Adiaeresis, "XK_Adiaeresis", "Ä" },
{ KSYM_Odiaeresis, "XK_Odiaeresis", "Ö" },
{ KSYM_udiaeresis, "XK_udiaeresis", "ü" },
{ KSYM_ssharp, "XK_ssharp", "sharp s" },
+#if defined(TARGET_SDL2)
+ /* special (non-ASCII) keys (UTF-8, for reverse mapping only) */
+ { KSYM_degree, "XK_degree", "\xc2\xb0" },
+ { KSYM_Adiaeresis, "XK_Adiaeresis", "\xc3\x84" },
+ { KSYM_Odiaeresis, "XK_Odiaeresis", "\xc3\x96" },
+ { KSYM_Udiaeresis, "XK_Udiaeresis", "\xc3\x9c" },
+ { KSYM_adiaeresis, "XK_adiaeresis", "\xc3\xa4" },
+ { KSYM_odiaeresis, "XK_odiaeresis", "\xc3\xb6" },
+ { KSYM_udiaeresis, "XK_udiaeresis", "\xc3\xbc" },
+ { KSYM_ssharp, "XK_ssharp", "\xc3\x9f" },
+#endif
+
#if defined(TARGET_SDL2)
/* keypad keys are not in numerical order in SDL2 */
{ KSYM_KP_0, "XK_KP_0", "keypad 0" },
#define KSYM_quotedbl SDLK_QUOTEDBL
#define KSYM_numbersign SDLK_HASH
#define KSYM_dollar SDLK_DOLLAR
-#define KSYM_percent KSYM_UNDEFINED /* undefined */
+
+#if defined(TARGET_SDL2)
+#define KSYM_percent SDLK_PERCENT
+#else
+#define KSYM_percent 37 /* undefined in SDL */
+#endif
+
#define KSYM_ampersand SDLK_AMPERSAND
#define KSYM_apostrophe SDLK_QUOTE
#define KSYM_parenleft SDLK_LEFTPAREN
#define KMOD_Meta (KMOD_Meta_L | KMOD_Meta_R)
#define KMOD_Alt (KMOD_Alt_L | KMOD_Alt_R)
+#if defined(TARGET_SDL2)
+#define KMOD_TextInput (KMOD_Shift | KMOD_Alt_R)
+#endif
/* SDL function definitions */