-#endif
-
-//-----------------------------------------------------------------------------
-// key code mapping routines
-//-----------------------------------------------------------------------------
-
-static long map_to_unmodified_wx_keysym( GdkEventKey *event )
-{
- // VZ: it seems that GDK_KEY_RELEASE event doesn't set event->string
- // but only event->keyval which is quite useless to us, so remember
- // the last character from GDK_KEY_PRESS and resue it as last resort
- //
- // NB: should be MT-neutral as always called from main thread only
- static struct
- {
- KeySym keysym;
- long keycode;
- } s_lastKeyPress = { 0, 0 };
-
- KeySym keysym = event->keyval;
- long key_code;
-
- switch ( keysym )
- {
- case GDK_Shift_L:
- case GDK_Shift_R: key_code = WXK_SHIFT; break;
- case GDK_Control_L:
- case GDK_Control_R: key_code = WXK_CONTROL; break;
- case GDK_Meta_L:
- case GDK_Meta_R:
- case GDK_Alt_L:
- case GDK_Alt_R:
- case GDK_Super_L:
- case GDK_Super_R: key_code = WXK_ALT; break;
- case GDK_Menu: key_code = WXK_MENU; break;
- case GDK_Help: key_code = WXK_HELP; break;
- case GDK_BackSpace: key_code = WXK_BACK; break;
- case GDK_ISO_Left_Tab:
- case GDK_Tab: key_code = WXK_TAB; break;
- case GDK_Linefeed: key_code = WXK_RETURN; break;
- case GDK_Clear: key_code = WXK_CLEAR; break;
- case GDK_Return: key_code = WXK_RETURN; break;
- case GDK_Pause: key_code = WXK_PAUSE; break;
- case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
- case GDK_Escape: key_code = WXK_ESCAPE; break;
- case GDK_Delete: key_code = WXK_DELETE; break;
- case GDK_Home: key_code = WXK_HOME; break;
- case GDK_Left: key_code = WXK_LEFT; break;
- case GDK_Up: key_code = WXK_UP; break;
- case GDK_Right: key_code = WXK_RIGHT; break;
- case GDK_Down: key_code = WXK_DOWN; break;
- case GDK_Prior: key_code = WXK_PRIOR; break;
-// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
- case GDK_Next: key_code = WXK_NEXT; break;
-// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
- case GDK_End: key_code = WXK_END; break;
- case GDK_Begin: key_code = WXK_HOME; break;
- case GDK_Select: key_code = WXK_SELECT; break;
- case GDK_Print: key_code = WXK_PRINT; break;
- case GDK_Execute: key_code = WXK_EXECUTE; break;
- case GDK_Insert: key_code = WXK_INSERT; break;
- case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
-
- case GDK_KP_0: key_code = WXK_NUMPAD0; break;
- case GDK_KP_1: key_code = WXK_NUMPAD1; break;
- case GDK_KP_2: key_code = WXK_NUMPAD2; break;
- case GDK_KP_3: key_code = WXK_NUMPAD3; break;
- case GDK_KP_4: key_code = WXK_NUMPAD4; break;
- case GDK_KP_5: key_code = WXK_NUMPAD5; break;
- case GDK_KP_6: key_code = WXK_NUMPAD6; break;
- case GDK_KP_7: key_code = WXK_NUMPAD7; break;
- case GDK_KP_8: key_code = WXK_NUMPAD8; break;
- case GDK_KP_9: key_code = WXK_NUMPAD9; break;
- case GDK_KP_Space: key_code = WXK_NUMPAD_SPACE; break;
- case GDK_KP_Tab: key_code = WXK_NUMPAD_TAB; break;
- case GDK_KP_Enter: key_code = WXK_NUMPAD_ENTER; break;
- case GDK_KP_F1: key_code = WXK_NUMPAD_F1; break;
- case GDK_KP_F2: key_code = WXK_NUMPAD_F2; break;
- case GDK_KP_F3: key_code = WXK_NUMPAD_F3; break;
- case GDK_KP_F4: key_code = WXK_NUMPAD_F4; break;
- case GDK_KP_Home: key_code = WXK_NUMPAD_HOME; break;
- case GDK_KP_Left: key_code = WXK_NUMPAD_LEFT; break;
- case GDK_KP_Up: key_code = WXK_NUMPAD_UP; break;
- case GDK_KP_Right: key_code = WXK_NUMPAD_RIGHT; break;
- case GDK_KP_Down: key_code = WXK_NUMPAD_DOWN; break;
- case GDK_KP_Prior: key_code = WXK_NUMPAD_PRIOR; break;
-// case GDK_KP_Page_Up: key_code = WXK_NUMPAD_PAGEUP; break;
- case GDK_KP_Next: key_code = WXK_NUMPAD_NEXT; break;
-// case GDK_KP_Page_Down: key_code = WXK_NUMPAD_PAGEDOWN; break;
- case GDK_KP_End: key_code = WXK_NUMPAD_END; break;
- case GDK_KP_Begin: key_code = WXK_NUMPAD_BEGIN; break;
- case GDK_KP_Insert: key_code = WXK_NUMPAD_INSERT; break;
- case GDK_KP_Delete: key_code = WXK_NUMPAD_DELETE; break;
- case GDK_KP_Equal: key_code = WXK_NUMPAD_EQUAL; break;
- case GDK_KP_Multiply: key_code = WXK_NUMPAD_MULTIPLY; break;
- case GDK_KP_Add: key_code = WXK_NUMPAD_ADD; break;
- case GDK_KP_Separator: key_code = WXK_NUMPAD_SEPARATOR; break;
- case GDK_KP_Subtract: key_code = WXK_NUMPAD_SUBTRACT; break;
- case GDK_KP_Decimal: key_code = WXK_NUMPAD_DECIMAL; break;
- case GDK_KP_Divide: key_code = WXK_NUMPAD_DIVIDE; break;
-
- case GDK_F1: key_code = WXK_F1; break;
- case GDK_F2: key_code = WXK_F2; break;
- case GDK_F3: key_code = WXK_F3; break;
- case GDK_F4: key_code = WXK_F4; break;
- case GDK_F5: key_code = WXK_F5; break;
- case GDK_F6: key_code = WXK_F6; break;
- case GDK_F7: key_code = WXK_F7; break;
- case GDK_F8: key_code = WXK_F8; break;
- case GDK_F9: key_code = WXK_F9; break;
- case GDK_F10: key_code = WXK_F10; break;
- case GDK_F11: key_code = WXK_F11; break;
- case GDK_F12: key_code = WXK_F12; break;
- default:
- {
- // do we have the translation?
- if ( event->length == 1 )
- {
- keysym = (KeySym)event->string[0];
- }
- else if ( (keysym & 0xFF) != keysym )
- {
- // non ASCII key, what to do?
-
- if ( event->type == GDK_KEY_RELEASE )
- {
- // reuse the one from the last keypress if any
- if ( keysym == s_lastKeyPress.keysym )
- {
- key_code = s_lastKeyPress.keycode;
-
- // skip "return 0"
- break;
- }
- }
-
- // ignore this one, we don't know it
- return 0;
- }
- //else: ASCII key, ok
-
- guint upper = gdk_keyval_to_upper( (guint)keysym );
- key_code = upper ? upper : keysym;
-
- if ( event->type == GDK_KEY_PRESS )
- {
- // remember it to be reused below later
- s_lastKeyPress.keysym = keysym;
- s_lastKeyPress.keycode = key_code;
- }
- }
- }
-
- return key_code;
-}
-
-static long map_to_wx_keysym( GdkEventKey *event )
-{
- KeySym keysym = event->keyval;
- guint key_code = 0;
-
- switch (keysym)
- {
- case GDK_Menu: key_code = WXK_MENU; break;
- case GDK_Help: key_code = WXK_HELP; break;
- case GDK_BackSpace: key_code = WXK_BACK; break;
- case GDK_ISO_Left_Tab:
- case GDK_Tab: key_code = WXK_TAB; break;
- case GDK_Linefeed: key_code = WXK_RETURN; break;
- case GDK_Clear: key_code = WXK_CLEAR; break;
- case GDK_Return: key_code = WXK_RETURN; break;
- case GDK_Pause: key_code = WXK_PAUSE; break;
- case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
- case GDK_Escape: key_code = WXK_ESCAPE; break;
- case GDK_Delete: key_code = WXK_DELETE; break;
- case GDK_Home: key_code = WXK_HOME; break;
- case GDK_Left: key_code = WXK_LEFT; break;
- case GDK_Up: key_code = WXK_UP; break;
- case GDK_Right: key_code = WXK_RIGHT; break;
- case GDK_Down: key_code = WXK_DOWN; break;
- case GDK_Prior: key_code = WXK_PRIOR; break;
-// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
- case GDK_Next: key_code = WXK_NEXT; break;
-// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
- case GDK_End: key_code = WXK_END; break;
- case GDK_Begin: key_code = WXK_HOME; break;
- case GDK_Select: key_code = WXK_SELECT; break;
- case GDK_Print: key_code = WXK_PRINT; break;
- case GDK_Execute: key_code = WXK_EXECUTE; break;
- case GDK_Insert: key_code = WXK_INSERT; break;
- case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
-
- case GDK_KP_0: key_code = '0'; break;
- case GDK_KP_1: key_code = '1'; break;
- case GDK_KP_2: key_code = '2'; break;
- case GDK_KP_3: key_code = '3'; break;
- case GDK_KP_4: key_code = '4'; break;
- case GDK_KP_5: key_code = '5'; break;
- case GDK_KP_6: key_code = '6'; break;
- case GDK_KP_7: key_code = '7'; break;
- case GDK_KP_8: key_code = '8'; break;
- case GDK_KP_9: key_code = '9'; break;
- case GDK_KP_Space: key_code = ' '; break;
- case GDK_KP_Tab: key_code = WXK_TAB; break; /* or '\t' ??? */
- case GDK_KP_Enter: key_code = WXK_RETURN; break; /* or '\r' ??? */
- case GDK_KP_F1: key_code = WXK_NUMPAD_F1; break;
- case GDK_KP_F2: key_code = WXK_NUMPAD_F2; break;
- case GDK_KP_F3: key_code = WXK_NUMPAD_F3; break;
- case GDK_KP_F4: key_code = WXK_NUMPAD_F4; break;
- case GDK_KP_Home: key_code = WXK_HOME; break;
- case GDK_KP_Left: key_code = WXK_LEFT; break;
- case GDK_KP_Up: key_code = WXK_UP; break;
- case GDK_KP_Right: key_code = WXK_RIGHT; break;
- case GDK_KP_Down: key_code = WXK_DOWN; break;
- case GDK_KP_Prior: key_code = WXK_PRIOR; break;
-// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
- case GDK_KP_Next: key_code = WXK_NEXT; break;
-// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
- case GDK_KP_End: key_code = WXK_END; break;
- case GDK_KP_Begin: key_code = WXK_HOME; break;
- case GDK_KP_Insert: key_code = WXK_INSERT; break;
- case GDK_KP_Delete: key_code = WXK_DELETE; break;
- case GDK_KP_Equal: key_code = '='; break;
- case GDK_KP_Multiply: key_code = '*'; break;
- case GDK_KP_Add: key_code = '+'; break;
- case GDK_KP_Separator: key_code = ','; break;
- case GDK_KP_Subtract: key_code = '-'; break;
- case GDK_KP_Decimal: key_code = '.'; break;
- case GDK_KP_Divide: key_code = '/'; break;
-
- case GDK_F1: key_code = WXK_F1; break;
- case GDK_F2: key_code = WXK_F2; break;
- case GDK_F3: key_code = WXK_F3; break;
- case GDK_F4: key_code = WXK_F4; break;
- case GDK_F5: key_code = WXK_F5; break;
- case GDK_F6: key_code = WXK_F6; break;
- case GDK_F7: key_code = WXK_F7; break;
- case GDK_F8: key_code = WXK_F8; break;
- case GDK_F9: key_code = WXK_F9; break;
- case GDK_F10: key_code = WXK_F10; break;
- case GDK_F11: key_code = WXK_F11; break;
- case GDK_F12: key_code = WXK_F12; break;
- default:
- if (event->length == 1)
- {
- key_code = (unsigned char)*event->string;
- }
- else if ((keysym & 0xFF) == keysym)
- {
- key_code = (guint)keysym;
- }
- }
-
- return key_code;
-}