[SDL_tizen] Add Tizen scancodes 16/93616/1
authorhuiyu.eun <huiyu.eun@samsung.com>
Tue, 25 Oct 2016 05:39:57 +0000 (14:39 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Tue, 25 Oct 2016 05:43:37 +0000 (14:43 +0900)
Translate tizen keycode into SDL scancode.

Change-Id: I7052e9069d02ebdbd2cdee4ceb319e2bb826d53a
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/events/scancodes_tizen.h [new file with mode: 0644]
src/video/tizen/SDL_tizenevents.c
src/video/tizen/SDL_tizenkeyboard.c

diff --git a/src/events/scancodes_tizen.h b/src/events/scancodes_tizen.h
new file mode 100644 (file)
index 0000000..7da5c14
--- /dev/null
@@ -0,0 +1,260 @@
+
+#include "../../include/SDL_scancode.h"
+
+static SDL_Scancode Tizen_Keycodes[] = {
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_ESCAPE,
+    SDL_SCANCODE_1,//10
+    SDL_SCANCODE_2,
+    SDL_SCANCODE_3,
+    SDL_SCANCODE_4,
+    SDL_SCANCODE_5,
+    SDL_SCANCODE_6,
+    SDL_SCANCODE_7,
+    SDL_SCANCODE_8,
+    SDL_SCANCODE_9,
+    SDL_SCANCODE_0,
+    SDL_SCANCODE_MINUS,
+    SDL_SCANCODE_EQUALS,
+    SDL_SCANCODE_BACKSPACE,
+    SDL_SCANCODE_TAB,
+    SDL_SCANCODE_Q,
+    SDL_SCANCODE_W,
+    SDL_SCANCODE_E,
+    SDL_SCANCODE_R,
+    SDL_SCANCODE_T,
+    SDL_SCANCODE_Y,
+    SDL_SCANCODE_U,
+    SDL_SCANCODE_I,
+    SDL_SCANCODE_O,
+    SDL_SCANCODE_P,
+    SDL_SCANCODE_LEFTBRACKET,
+    SDL_SCANCODE_RIGHTBRACKET,
+    SDL_SCANCODE_RETURN,
+    SDL_SCANCODE_LCTRL,
+    SDL_SCANCODE_A,
+    SDL_SCANCODE_S,
+    SDL_SCANCODE_D,
+    SDL_SCANCODE_F,
+    SDL_SCANCODE_G,
+    SDL_SCANCODE_H,
+    SDL_SCANCODE_J,
+    SDL_SCANCODE_K,
+    SDL_SCANCODE_L,
+    SDL_SCANCODE_SEMICOLON,
+    SDL_SCANCODE_APOSTROPHE,
+    SDL_SCANCODE_GRAVE,
+    SDL_SCANCODE_LSHIFT,
+    SDL_SCANCODE_NONUSBACKSLASH,
+    SDL_SCANCODE_Z,
+    SDL_SCANCODE_X,
+    SDL_SCANCODE_C,
+    SDL_SCANCODE_V,
+    SDL_SCANCODE_B,
+    SDL_SCANCODE_N,
+    SDL_SCANCODE_M,
+    SDL_SCANCODE_COMMA,
+    SDL_SCANCODE_PERIOD,
+    SDL_SCANCODE_SLASH,
+    SDL_SCANCODE_RSHIFT,
+    SDL_SCANCODE_KP_MULTIPLY,
+    SDL_SCANCODE_LALT,
+    SDL_SCANCODE_SPACE,
+    SDL_SCANCODE_CAPSLOCK,
+    SDL_SCANCODE_F1,
+    SDL_SCANCODE_F2,
+    SDL_SCANCODE_F3,
+    SDL_SCANCODE_F4,
+    SDL_SCANCODE_F5,
+    SDL_SCANCODE_F6,
+    SDL_SCANCODE_F7,
+    SDL_SCANCODE_F8,
+    SDL_SCANCODE_F9,
+    SDL_SCANCODE_F10,
+    SDL_SCANCODE_NUMLOCKCLEAR,
+    SDL_SCANCODE_SCROLLLOCK,
+    SDL_SCANCODE_KP_7,
+    SDL_SCANCODE_KP_8,
+    SDL_SCANCODE_KP_9,
+    SDL_SCANCODE_KP_MINUS,
+    SDL_SCANCODE_KP_4,
+    SDL_SCANCODE_KP_5,
+    SDL_SCANCODE_KP_6,
+    SDL_SCANCODE_KP_PLUS,
+    SDL_SCANCODE_KP_7,
+    SDL_SCANCODE_KP_8,
+    SDL_SCANCODE_KP_9,
+    SDL_SCANCODE_KP_0,
+    SDL_SCANCODE_KP_DECIMAL,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_KP_LESS,
+    SDL_SCANCODE_F11,
+    SDL_SCANCODE_F12,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_LANG3,
+    SDL_SCANCODE_LANG4,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_KP_ENTER,
+    SDL_SCANCODE_RCTRL,
+    SDL_SCANCODE_KP_DIVIDE,
+    SDL_SCANCODE_PRINTSCREEN,
+    SDL_SCANCODE_RALT,
+    SDL_SCANCODE_RETURN,
+    SDL_SCANCODE_HOME,
+    SDL_SCANCODE_UP,
+    SDL_SCANCODE_PRIOR,
+    SDL_SCANCODE_LEFT,
+    SDL_SCANCODE_RIGHT,
+    SDL_SCANCODE_END,
+    SDL_SCANCODE_DOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_INSERT,
+    SDL_SCANCODE_DELETE,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_AUDIOMUTE,
+    SDL_SCANCODE_VOLUMEDOWN,
+    SDL_SCANCODE_VOLUMEUP,
+    SDL_SCANCODE_POWER,
+    SDL_SCANCODE_KP_EQUALS,
+    SDL_SCANCODE_KP_PLUSMINUS,
+    SDL_SCANCODE_PAUSE,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_KP_DECIMAL,
+    SDL_SCANCODE_LANG1,
+    SDL_SCANCODE_LANG2,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_LGUI,
+    SDL_SCANCODE_RGUI,
+    SDL_SCANCODE_MENU,
+    SDL_SCANCODE_AUDIOSTOP,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNDO,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_COPY,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_PASTE,
+    SDL_SCANCODE_FIND,
+    SDL_SCANCODE_CUT,
+    SDL_SCANCODE_HELP,
+    SDL_SCANCODE_AC_HOME,
+    SDL_SCANCODE_CALCULATOR,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_SLEEP,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_WWW,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_MAIL,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_COMPUTER,
+    SDL_SCANCODE_AC_BACK,
+    SDL_SCANCODE_AC_FORWARD,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_EJECT,
+    SDL_SCANCODE_EJECT,
+    SDL_SCANCODE_AUDIONEXT,
+    SDL_SCANCODE_AUDIOPLAY,
+    SDL_SCANCODE_AUDIOPREV,
+    SDL_SCANCODE_AUDIOSTOP,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_MENU,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_KP_LEFTPAREN,
+    SDL_SCANCODE_KP_RIGHTPAREN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_AUDIOPLAY,
+    SDL_SCANCODE_AUDIOSTOP,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_AUDIOPLAY,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_PRINTSCREEN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_MAIL,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_AC_SEARCH,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_BRIGHTNESSDOWN,
+    SDL_SCANCODE_BRIGHTNESSUP,
+    SDL_SCANCODE_MEDIASELECT,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN//253
+};
+
index fd48476..9ae0dc3 100644 (file)
 #include "SDL_tizenwindow.h"
 #include "SDL_log.h"
 
+#include "../../events/scancodes_tizen.h"
+#include "SDL_tizenkeyboard.h"
+
+static SDL_Scancode
+TranslateKeycode(int keycode)
+{
+    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
+
+    if (keycode < SDL_arraysize(Tizen_Keycodes)) {
+        scancode = Tizen_Keycodes[keycode];
+    }
+    if (scancode == SDL_SCANCODE_UNKNOWN) {
+        SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[SDL] Unknown keycode %d",keycode);
+    }
+    return scancode;
+}
+
 void
 Tizen_PumpEvents(_THIS)
 {
@@ -48,8 +65,9 @@ _tizen_cb_event_keyup_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Key * e = event;
-    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key up: %d",e->keycode);
-    SDL_SendKeyboardKey(SDL_RELEASED, e->keycode);
+    SDL_Scancode scancode = TranslateKeycode(e->keycode);
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key up: %d", scancode);
+    SDL_SendKeyboardKey(SDL_RELEASED, scancode);
 
     return ECORE_CALLBACK_PASS_ON;
 }
@@ -60,8 +78,9 @@ _tizen_cb_event_keydown_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Key * e = event;
-    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key down: %d",e->keycode);
-    SDL_SendKeyboardKey(SDL_PRESSED, e->keycode);
+    SDL_Scancode scancode = TranslateKeycode(e->keycode);
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key down: %d", scancode);
+    SDL_SendKeyboardKey(SDL_PRESSED, scancode);
 
     return ECORE_CALLBACK_PASS_ON;
 }
index b39e6a2..3af43bf 100644 (file)
@@ -49,6 +49,15 @@ _ecore_imf_event_state_change_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED,
     return;
 }
 
+void Tizen_SetKeymap()
+{
+    SDL_Keycode keymap[SDL_NUM_SCANCODES];
+
+    /* Add default scancode to key mapping */
+    SDL_GetDefaultKeymap(keymap);
+    SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
+}
+
 void Tizen_InitKeyboard(_THIS)
 {
     //TODO : need the ref count
@@ -79,6 +88,8 @@ void Tizen_InitKeyboard(_THIS)
     ecore_imf_context_focus_out(tizen_keyboard.imf_context);
     ecore_imf_context_input_panel_hide(tizen_keyboard.imf_context);
 
+    Tizen_SetKeymap();
+
 }
 
 void Tizen_FiniKeyboard(void)