gtk2: keyboard macro update

This commit is contained in:
Gregory Hainaut 2014-12-07 23:01:51 +01:00
parent ba9e998ff5
commit d1389db2f4
2 changed files with 87 additions and 92 deletions

View File

@ -17,11 +17,6 @@
#include "ConsoleLogger.h" #include "ConsoleLogger.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#if (GTK_MAJOR_VERSION > 2)
// All those GDK_<key> defines are now GDK_KEY_<key>, as of around Gtk+ 2.22. This include gets brought in automatically until Gtk 3.0,
// But we want to bring it in after that, too, until we're ready to break compatability prior to Gtk+ 2.22.
#include <gdk/gdkkeysyms-compat.h>
#endif
void NTFS_CompressFile( const wxString& file, bool compressStatus ) {} void NTFS_CompressFile( const wxString& file, bool compressStatus ) {}
@ -33,229 +28,229 @@ int TranslateGDKtoWXK( u32 keysym )
switch ( keysym ) switch ( keysym )
{ {
// Shift, Control and Alt don't generate the CHAR events at all // Shift, Control and Alt don't generate the CHAR events at all
case GDK_Shift_L: case GDK_KEY_Shift_L:
case GDK_Shift_R: case GDK_KEY_Shift_R:
key_code = WXK_SHIFT; key_code = WXK_SHIFT;
break; break;
case GDK_Control_L: case GDK_KEY_Control_L:
case GDK_Control_R: case GDK_KEY_Control_R:
key_code = WXK_CONTROL; key_code = WXK_CONTROL;
break; break;
case GDK_Meta_L: case GDK_KEY_Meta_L:
case GDK_Meta_R: case GDK_KEY_Meta_R:
case GDK_Alt_L: case GDK_KEY_Alt_L:
case GDK_Alt_R: case GDK_KEY_Alt_R:
case GDK_Super_L: case GDK_KEY_Super_L:
case GDK_Super_R: case GDK_KEY_Super_R:
key_code = WXK_ALT; key_code = WXK_ALT;
break; break;
// neither do the toggle modifies // neither do the toggle modifies
case GDK_Scroll_Lock: case GDK_KEY_Scroll_Lock:
key_code = WXK_SCROLL; key_code = WXK_SCROLL;
break; break;
case GDK_Caps_Lock: case GDK_KEY_Caps_Lock:
key_code = WXK_CAPITAL; key_code = WXK_CAPITAL;
break; break;
case GDK_Num_Lock: case GDK_KEY_Num_Lock:
key_code = WXK_NUMLOCK; key_code = WXK_NUMLOCK;
break; break;
// various other special keys // various other special keys
case GDK_Menu: case GDK_KEY_Menu:
key_code = WXK_MENU; key_code = WXK_MENU;
break; break;
case GDK_Help: case GDK_KEY_Help:
key_code = WXK_HELP; key_code = WXK_HELP;
break; break;
case GDK_BackSpace: case GDK_KEY_BackSpace:
key_code = WXK_BACK; key_code = WXK_BACK;
break; break;
case GDK_ISO_Left_Tab: case GDK_KEY_ISO_Left_Tab:
case GDK_Tab: case GDK_KEY_Tab:
key_code = WXK_TAB; key_code = WXK_TAB;
break; break;
case GDK_Linefeed: case GDK_KEY_Linefeed:
case GDK_Return: case GDK_KEY_Return:
key_code = WXK_RETURN; key_code = WXK_RETURN;
break; break;
case GDK_Clear: case GDK_KEY_Clear:
key_code = WXK_CLEAR; key_code = WXK_CLEAR;
break; break;
case GDK_Pause: case GDK_KEY_Pause:
key_code = WXK_PAUSE; key_code = WXK_PAUSE;
break; break;
case GDK_Select: case GDK_KEY_Select:
key_code = WXK_SELECT; key_code = WXK_SELECT;
break; break;
case GDK_Print: case GDK_KEY_Print:
key_code = WXK_PRINT; key_code = WXK_PRINT;
break; break;
case GDK_Execute: case GDK_KEY_Execute:
key_code = WXK_EXECUTE; key_code = WXK_EXECUTE;
break; break;
case GDK_Escape: case GDK_KEY_Escape:
key_code = WXK_ESCAPE; key_code = WXK_ESCAPE;
break; break;
// cursor and other extended keyboard keys // cursor and other extended keyboard keys
case GDK_Delete: case GDK_KEY_Delete:
key_code = WXK_DELETE; key_code = WXK_DELETE;
break; break;
case GDK_Home: case GDK_KEY_Home:
key_code = WXK_HOME; key_code = WXK_HOME;
break; break;
case GDK_Left: case GDK_KEY_Left:
key_code = WXK_LEFT; key_code = WXK_LEFT;
break; break;
case GDK_Up: case GDK_KEY_Up:
key_code = WXK_UP; key_code = WXK_UP;
break; break;
case GDK_Right: case GDK_KEY_Right:
key_code = WXK_RIGHT; key_code = WXK_RIGHT;
break; break;
case GDK_Down: case GDK_KEY_Down:
key_code = WXK_DOWN; key_code = WXK_DOWN;
break; break;
case GDK_Prior: // == GDK_Page_Up case GDK_KEY_Prior: // == GDK_KEY_Page_Up
key_code = WXK_PAGEUP; key_code = WXK_PAGEUP;
break; break;
case GDK_Next: // == GDK_Page_Down case GDK_KEY_Next: // == GDK_KEY_Page_Down
key_code = WXK_PAGEDOWN; key_code = WXK_PAGEDOWN;
break; break;
case GDK_End: case GDK_KEY_End:
key_code = WXK_END; key_code = WXK_END;
break; break;
case GDK_Begin: case GDK_KEY_Begin:
key_code = WXK_HOME; key_code = WXK_HOME;
break; break;
case GDK_Insert: case GDK_KEY_Insert:
key_code = WXK_INSERT; key_code = WXK_INSERT;
break; break;
// numpad keys // numpad keys
case GDK_KP_0: case GDK_KEY_KP_0:
case GDK_KP_1: case GDK_KEY_KP_1:
case GDK_KP_2: case GDK_KEY_KP_2:
case GDK_KP_3: case GDK_KEY_KP_3:
case GDK_KP_4: case GDK_KEY_KP_4:
case GDK_KP_5: case GDK_KEY_KP_5:
case GDK_KP_6: case GDK_KEY_KP_6:
case GDK_KP_7: case GDK_KEY_KP_7:
case GDK_KP_8: case GDK_KEY_KP_8:
case GDK_KP_9: case GDK_KEY_KP_9:
key_code = WXK_NUMPAD0 + keysym - GDK_KP_0; key_code = WXK_NUMPAD0 + keysym - GDK_KEY_KP_0;
break; break;
case GDK_KP_Space: case GDK_KEY_KP_Space:
key_code = WXK_NUMPAD_SPACE; key_code = WXK_NUMPAD_SPACE;
break; break;
case GDK_KP_Tab: case GDK_KEY_KP_Tab:
key_code = WXK_NUMPAD_TAB; key_code = WXK_NUMPAD_TAB;
break; break;
case GDK_KP_Enter: case GDK_KEY_KP_Enter:
key_code = WXK_NUMPAD_ENTER; key_code = WXK_NUMPAD_ENTER;
break; break;
case GDK_KP_F1: case GDK_KEY_KP_F1:
key_code = WXK_NUMPAD_F1; key_code = WXK_NUMPAD_F1;
break; break;
case GDK_KP_F2: case GDK_KEY_KP_F2:
key_code = WXK_NUMPAD_F2; key_code = WXK_NUMPAD_F2;
break; break;
case GDK_KP_F3: case GDK_KEY_KP_F3:
key_code = WXK_NUMPAD_F3; key_code = WXK_NUMPAD_F3;
break; break;
case GDK_KP_F4: case GDK_KEY_KP_F4:
key_code = WXK_NUMPAD_F4; key_code = WXK_NUMPAD_F4;
break; break;
case GDK_KP_Home: case GDK_KEY_KP_Home:
key_code = WXK_NUMPAD_HOME; key_code = WXK_NUMPAD_HOME;
break; break;
case GDK_KP_Left: case GDK_KEY_KP_Left:
key_code = WXK_NUMPAD_LEFT; key_code = WXK_NUMPAD_LEFT;
break; break;
case GDK_KP_Up: case GDK_KEY_KP_Up:
key_code = WXK_NUMPAD_UP; key_code = WXK_NUMPAD_UP;
break; break;
case GDK_KP_Right: case GDK_KEY_KP_Right:
key_code = WXK_NUMPAD_RIGHT; key_code = WXK_NUMPAD_RIGHT;
break; break;
case GDK_KP_Down: case GDK_KEY_KP_Down:
key_code = WXK_NUMPAD_DOWN; key_code = WXK_NUMPAD_DOWN;
break; break;
case GDK_KP_Prior: // == GDK_KP_Page_Up case GDK_KEY_KP_Prior: // == GDK_KEY_KP_Page_Up
key_code = WXK_NUMPAD_PAGEUP; key_code = WXK_NUMPAD_PAGEUP;
break; break;
case GDK_KP_Next: // == GDK_KP_Page_Down case GDK_KEY_KP_Next: // == GDK_KEY_KP_Page_Down
key_code = WXK_NUMPAD_PAGEDOWN; key_code = WXK_NUMPAD_PAGEDOWN;
break; break;
case GDK_KP_End: case GDK_KEY_KP_End:
key_code = WXK_NUMPAD_END; key_code = WXK_NUMPAD_END;
break; break;
case GDK_KP_Begin: case GDK_KEY_KP_Begin:
key_code = WXK_NUMPAD_BEGIN; key_code = WXK_NUMPAD_BEGIN;
break; break;
case GDK_KP_Insert: case GDK_KEY_KP_Insert:
key_code = WXK_NUMPAD_INSERT; key_code = WXK_NUMPAD_INSERT;
break; break;
case GDK_KP_Delete: case GDK_KEY_KP_Delete:
key_code = WXK_NUMPAD_DELETE; key_code = WXK_NUMPAD_DELETE;
break; break;
case GDK_KP_Equal: case GDK_KEY_KP_Equal:
key_code = WXK_NUMPAD_EQUAL; key_code = WXK_NUMPAD_EQUAL;
break; break;
case GDK_KP_Multiply: case GDK_KEY_KP_Multiply:
key_code = WXK_NUMPAD_MULTIPLY; key_code = WXK_NUMPAD_MULTIPLY;
break; break;
case GDK_KP_Add: case GDK_KEY_KP_Add:
key_code = WXK_NUMPAD_ADD; key_code = WXK_NUMPAD_ADD;
break; break;
case GDK_KP_Separator: case GDK_KEY_KP_Separator:
// FIXME: what is this? // FIXME: what is this?
// //
// Some numeric keyboards have a comma on them. I believe this is the symbol // Some numeric keyboards have a comma on them. I believe this is the symbol
@ -264,33 +259,33 @@ int TranslateGDKtoWXK( u32 keysym )
key_code = WXK_NUMPAD_SEPARATOR; key_code = WXK_NUMPAD_SEPARATOR;
break; break;
case GDK_KP_Subtract: case GDK_KEY_KP_Subtract:
key_code = WXK_NUMPAD_SUBTRACT; key_code = WXK_NUMPAD_SUBTRACT;
break; break;
case GDK_KP_Decimal: case GDK_KEY_KP_Decimal:
key_code = WXK_NUMPAD_DECIMAL; key_code = WXK_NUMPAD_DECIMAL;
break; break;
case GDK_KP_Divide: case GDK_KEY_KP_Divide:
key_code = WXK_NUMPAD_DIVIDE; key_code = WXK_NUMPAD_DIVIDE;
break; break;
// function keys // function keys
case GDK_F1: case GDK_KEY_F1:
case GDK_F2: case GDK_KEY_F2:
case GDK_F3: case GDK_KEY_F3:
case GDK_F4: case GDK_KEY_F4:
case GDK_F5: case GDK_KEY_F5:
case GDK_F6: case GDK_KEY_F6:
case GDK_F7: case GDK_KEY_F7:
case GDK_F8: case GDK_KEY_F8:
case GDK_F9: case GDK_KEY_F9:
case GDK_F10: case GDK_KEY_F10:
case GDK_F11: case GDK_KEY_F11:
case GDK_F12: case GDK_KEY_F12:
key_code = WXK_F1 + keysym - GDK_F1; key_code = WXK_F1 + keysym - GDK_KEY_F1;
break; break;
default: default:

View File

@ -233,7 +233,7 @@ bool PollX11KeyboardMouseEvent(u32 &pkey)
if (ev != NULL) if (ev != NULL)
{ {
if (ev->type == GDK_KEY_PRESS) { if (ev->type == GDK_KEY_PRESS) {
pkey = ev->key.keyval != GDK_Escape ? ev->key.keyval : 0; pkey = ev->key.keyval != GDK_KEY_Escape ? ev->key.keyval : 0;
return true; return true;
} else if(ev->type == GDK_BUTTON_PRESS) { } else if(ev->type == GDK_BUTTON_PRESS) {
pkey = ev->button.button; pkey = ev->button.button;