Browse Source

Changed SDL to support unknown keys and pass them as the unused/raw keysym field as it seems that it used to do...
Will fix Urho3D to read that field and pass it to the Variant event for the systems to process if wanted.

OvermindDL1 12 years ago
parent
commit
dba4216c86

+ 1 - 1
Source/ThirdParty/SDL/include/SDL_keyboard.h

@@ -49,7 +49,7 @@ typedef struct SDL_Keysym
     SDL_Scancode scancode;      /**< SDL physical key code - see ::SDL_Scancode for details */
     SDL_Keycode sym;            /**< SDL virtual key code - see ::SDL_Keycode for details */
     Uint16 mod;                 /**< current key modifiers */
-    Uint32 unused;
+    Uint32 raw;
 } SDL_Keysym;
 
 /* Function prototypes */

+ 5 - 2
Source/ThirdParty/SDL/src/events/SDL_keyboard.c

@@ -570,7 +570,7 @@ SDL_ResetKeyboard(void)
 #endif
     for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
         if (keyboard->keystate[scancode] == SDL_PRESSED) {
-            SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+            SDL_SendKeyboardKey(SDL_RELEASED, 0, scancode);
         }
     }
 }
@@ -647,7 +647,7 @@ SDL_SetKeyboardFocus(SDL_Window * window)
 }
 
 int
-SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
+SDL_SendKeyboardKey(Uint8 state, Uint32 keycode, SDL_Scancode scancode)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
     int posted;
@@ -655,9 +655,11 @@ SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
     Uint32 type;
     Uint8 repeat;
 
+#if 0
     if (!scancode) {
         return 0;
     }
+#endif
 #ifdef DEBUG_KEYBOARD
     printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode),
            state == SDL_PRESSED ? "pressed" : "released");
@@ -774,6 +776,7 @@ SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
         event.key.keysym.scancode = scancode;
         event.key.keysym.sym = keyboard->keymap[scancode];
         event.key.keysym.mod = modstate;
+        event.key.keysym.raw = keycode;
         event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
         posted = (SDL_PushEvent(&event) > 0);
     }

+ 1 - 1
Source/ThirdParty/SDL/src/events/SDL_keyboard_c.h

@@ -48,7 +48,7 @@ extern void SDL_SetScancodeName(SDL_Scancode scancode, const char *name);
 extern void SDL_SetKeyboardFocus(SDL_Window * window);
 
 /* Send a keyboard key event */
-extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode);
+extern int SDL_SendKeyboardKey(Uint8 state, Uint32 keycode, SDL_Scancode scancode);
 
 /* Send keyboard text input */
 extern int SDL_SendKeyboardText(const char *text);

+ 3 - 3
Source/ThirdParty/SDL/src/video/x11/SDL_x11events.c

@@ -447,8 +447,8 @@ X11_DispatchEvent(_THIS)
 #ifdef DEBUG_XEVENTS
             printf("window %p: KeyPress (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode);
 #endif
-            SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
-#if 1
+			SDL_SendKeyboardKey(SDL_PRESSED, keycode, videodata->key_layout[keycode]);
+#if 0
             if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
                 int min_keycode, max_keycode;
                 X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
@@ -490,7 +490,7 @@ X11_DispatchEvent(_THIS)
                 /* We're about to get a repeated key down, ignore the key up */
                 break;
             }
-            SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]);
+            SDL_SendKeyboardKey(SDL_RELEASED, keycode, videodata->key_layout[keycode]);
         }
         break;