6 #include <X11/keysym.h>
8 #include <msp/core/except.h>
15 unsigned keymap[Msp::Input::N_KEYS_]=
18 0, 0, 0, 0, 0, 0, 0, 0,
19 XK_BackSpace, XK_Tab, XK_Return, 0, 0, 0, 0, 0,
20 0, 0, 0, 0, 0, 0, 0, 0,
21 0, 0, 0, XK_Escape, 0, 0, 0, 0,
23 XK_space, 0, 0, 0, 0, 0, 0, 0,
24 0, 0, 0, XK_plus, XK_comma, XK_minus, XK_period, XK_slash,
25 XK_0, XK_1, XK_2, XK_3, XK_4, XK_5, XK_6, XK_7,
26 XK_8, XK_9, 0, XK_semicolon, XK_less, XK_equal, 0, 0,
28 0, XK_a, XK_b, XK_c, XK_d, XK_e, XK_f, XK_g,
29 XK_h, XK_i, XK_j, XK_k, XK_l, XK_m, XK_n, XK_o,
30 XK_p, XK_q, XK_r, XK_s, XK_t, XK_u, XK_v, XK_w,
31 XK_x, XK_y, XK_z, XK_bracketleft, XK_backslash, XK_bracketright, 0, 0,
33 XK_grave, 0, 0, 0, 0, 0, 0, 0,
34 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0,
36 0, 0, 0, 0, 0, 0, 0, 0,
38 XK_adiaeresis, XK_odiaeresis, XK_udiaeresis, XK_aring, 0, 0, 0, 0,
39 0, 0, 0, 0, 0, 0, 0, 0,
40 0, 0, 0, 0, 0, 0, 0, 0,
41 0, 0, 0, 0, 0, 0, 0, 0,
43 XK_Left, XK_Right, XK_Up, XK_Down, 0, 0, 0, 0,
44 XK_Home, XK_End, XK_Page_Up, XK_Page_Down, XK_Insert, XK_Delete, 0, 0,
45 XK_F1, XK_F2, XK_F3, XK_F4, XK_F5, XK_F6, XK_F7, XK_F8,
46 XK_F9, XK_F10, XK_F11, XK_F12, 0, 0, 0, 0,
48 XK_Shift_L, XK_Shift_R, XK_Control_L, XK_Control_R, XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
49 XK_Caps_Lock, XK_Scroll_Lock, XK_Num_Lock, 0, 0, 0, 0, 0,
50 XK_KP_0, XK_KP_1, XK_KP_2, XK_KP_3, XK_KP_4, XK_KP_5, XK_KP_6, XK_KP_7,
51 XK_KP_8, XK_KP_9, XK_KP_Add, XK_KP_Subtract, XK_KP_Multiply, XK_KP_Divide, XK_KP_Separator, 0,
53 XK_Pause, XK_Print, XK_Menu, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0,
59 VK_BACK, VK_TAB, VK_RETURN, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, VK_ESCAPE, 0, 0, 0, 0,
63 VK_SPACE, 0, 0, 0, 0, 0, 0, 0,
64 0, 0, 0, 0, 0, 0, 0, 0,
65 '0', '1', '2', '3', '4', '5', '6', '7',
66 '8', '9', 0, 0, 0, 0, 0, 0,
68 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
69 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
70 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
71 'X', 'Y', 'Z', 0, 0, 0, 0, 0,
73 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0,
79 0, 0, 0, 0, 0, 0, 0, 0,
80 0, 0, 0, 0, 0, 0, 0, 0,
81 0, 0, 0, 0, 0, 0, 0, 0,
83 VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, 0, 0, 0, 0,
84 VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_INSERT, VK_DELETE, 0, 0,
85 0, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7,
86 VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, 0, 0, 0,
88 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL, 0, 0, VK_LWIN, VK_RWIN,
89 VK_CAPITAL, VK_SCROLL, VK_NUMLOCK, 0, 0, 0, 0, 0,
90 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
91 VK_NUMPAD8, VK_NUMPAD9, VK_ADD, VK_SUBTRACT, VK_MULTIPLY, VK_DIVIDE, VK_SEPARATOR, 0,
93 VK_PAUSE, VK_SNAPSHOT, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0,
100 unsigned modmap[Msp::Input::N_MODS_]=
103 ShiftMask, ControlMask, Mod1Mask, Mod4Mask
114 unsigned key_from_sys(unsigned code)
116 static bool init_done=false;
117 static map<unsigned, unsigned> reverse_map;
121 for(unsigned i=0; i<N_KEYS_; ++i)
123 reverse_map[keymap[i]]=i;
128 map<unsigned, unsigned>::const_iterator i=reverse_map.find(code);
129 if(i!=reverse_map.end())
135 unsigned key_to_sys(unsigned key)
138 throw InvalidParameterValue("Key out of range");
142 unsigned mod_from_sys(unsigned mod)
145 for(unsigned i=0; i<N_MODS_; ++i)