rnd-20140104-2-src
authorHolger Schemel <info@artsoft.org>
Sat, 4 Jan 2014 12:50:39 +0000 (13:50 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:27 +0000 (11:00 +0200)
* fixed remaining text input problems for non-ASCII keys with modifier

ChangeLog
src/conftime.h
src/events.c
src/libgame/misc.c
src/libgame/sdl.h

index 4e650a734761c0377c2517d3750286af5ad8a25f..203831c4db91405cf59e3bbb355a2655aaf278a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
+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
index 09eada1eeb7fb63d25189243aa3ddd029b150fd4..59500ab8f79b049c686df4f01c64d8b880474f72 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-01-04 02:29"
+#define COMPILE_DATE_STRING "2014-01-04 13:44"
index 50a39762865d8b0e6e1c5ee3714f998ec164d49a..6fc55ea5d32433f31304c3ac969b94452ea07a81 100644 (file)
@@ -477,19 +477,35 @@ void HandleFingerEvent(FingerEvent *event)
 #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);
@@ -528,13 +544,18 @@ void HandleKeyEvent(KeyEvent *event)
     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
 }
index d0746a46a1f650b4a1fcc2c5dcb8dbfac715f819..36bf1ce9dbd68fb1d905d9c6c38fedc51cd5e4cf 100644 (file)
@@ -1644,7 +1644,7 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode)
     { 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",        "Ö" },
@@ -1654,6 +1654,18 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode)
     { 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" },
index 254b9927166fc33d126911e9898c49b803610369..16c62c0f50034b4608ba004178d66074a653abae 100644 (file)
@@ -201,7 +201,13 @@ struct MouseCursorInfo
 #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
@@ -411,6 +417,9 @@ struct MouseCursorInfo
 #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 */