comparison dynamin/gui/x_key.d @ 0:aa4efef0f0b1

Initial commit of code.
author Jordan Miner <jminer7@gmail.com>
date Mon, 15 Jun 2009 22:10:48 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:aa4efef0f0b1
1 // Written in the D programming language
2 // www.digitalmars.com/d/
3
4
5
6 Key XKeyCodeToKey(int code) {
7 switch(code) {
8 case XK_parenright:
9 case XK_0: return Key.D0;
10 case XK_exclam:
11 case XK_1: return Key.D1;
12 case XK_at:
13 case XK_2: return Key.D2;
14 case XK_numbersign:
15 case XK_3: return Key.D3;
16 case XK_dollar:
17 case XK_4: return Key.D4;
18 case XK_percent:
19 case XK_5: return Key.D5;
20 case XK_asciicircum:
21 case XK_6: return Key.D6;
22 case XK_ampersand:
23 case XK_7: return Key.D7;
24 case XK_asterisk:
25 case XK_8: return Key.D8;
26 case XK_parenleft:
27 case XK_9: return Key.D9;
28
29 case XK_F1: return Key.F1;
30 case XK_F2: return Key.F2;
31 case XK_F3: return Key.F3;
32 case XK_F4: return Key.F4;
33 case XK_F5: return Key.F5;
34 case XK_F6: return Key.F6;
35 case XK_F7: return Key.F7;
36 case XK_F8: return Key.F8;
37 case XK_F9: return Key.F9;
38 case XK_F10: return Key.F10;
39 case XK_F11: return Key.F11;
40 case XK_F12: return Key.F12;
41
42 case XK_Escape: return Key.Escape;
43 case XK_Tab: return Key.Tab;
44 case XK_BackSpace: return Key.Backspace;
45 case XK_Return: return Key.Enter;
46 case XK_KP_Enter: return Key.Enter;
47 case XK_space: return Key.Space;
48
49 case XK_KP_Left:
50 case XK_Left: return Key.Left;
51 case XK_KP_Right:
52 case XK_Right: return Key.Right;
53 case XK_KP_Up:
54 case XK_Up: return Key.Up;
55 case XK_KP_Down:
56 case XK_Down: return Key.Down;
57
58 case XK_KP_Insert:
59 case XK_Insert: return Key.Insert;
60 case XK_KP_Delete:
61 case XK_Delete: return Key.Delete;
62 case XK_KP_Home:
63 case XK_Home: return Key.Home;
64 case XK_KP_End:
65 case XK_End: return Key.End;
66 case XK_KP_Prior:
67 case XK_Prior: return Key.PageUp;
68 case XK_KP_Next:
69 case XK_Next: return Key.PageDown;
70
71 case XK_Sys_Req: return Key.PrintScreen;
72 case XK_Pause: return Key.Pause;
73
74 case XK_Caps_Lock: return Key.CapsLock;
75 case XK_Num_Lock: return Key.NumLock;
76 case XK_Scroll_Lock: return Key.ScrollLock;
77
78 case XK_KP_0: return Key.NumPad0;
79 case XK_KP_1: return Key.NumPad1;
80 case XK_KP_2: return Key.NumPad2;
81 case XK_KP_3: return Key.NumPad3;
82 case XK_KP_4: return Key.NumPad4;
83 case XK_KP_5: return Key.NumPad5;
84 case XK_KP_6: return Key.NumPad6;
85 case XK_KP_7: return Key.NumPad7;
86 case XK_KP_8: return Key.NumPad8;
87 case XK_KP_9: return Key.NumPad9;
88 case XK_KP_Divide: return Key.NumPadDivide;
89 case XK_KP_Multiply: return Key.NumPadMultiply;
90 case XK_KP_Subtract: return Key.NumPadSubtract;
91 case XK_KP_Add: return Key.NumPadAdd;
92 case XK_KP_Decimal: return Key.NumPadDecimal;
93
94 case XK_grave:
95 case XK_asciitilde: return Key.Backquote;
96 case XK_minus:
97 case XK_underscore: return Key.Minus;
98 case XK_equal:
99 case XK_plus: return Key.Equals;
100 case XK_bracketleft:
101 case XK_braceleft: return Key.OpenBracket;
102 case XK_bracketright:
103 case XK_braceright: return Key.CloseBracket;
104 case XK_backslash:
105 case XK_bar: return Key.Backslash;
106 case XK_semicolon:
107 case XK_colon: return Key.Semicolon;
108 case XK_apostrophe:
109 case XK_quotedbl: return Key.Quote;
110 case XK_comma:
111 case XK_less: return Key.Comma;
112 case XK_period:
113 case XK_greater: return Key.Period;
114 case XK_slash:
115 case XK_question: return Key.Slash;
116
117 //case XK_Menu: return Key.Menu;
118
119 case XK_Shift_L:
120 case XK_Shift_R: return Key.Shift;
121 case XK_Control_L:
122 case XK_Control_R: return Key.Control;
123 case XK_Alt_L:
124 case XK_Alt_R: return Key.Alt;
125
126 //case XK_: return Key.;
127 default:
128 if(code >= 0x41 && code <= 0x5A) // Key.A - Key.Z
129 return cast(Key)code;
130 if(code >= 0x61 && code <= 0x7A) // Key.A - Key.Z
131 return cast(Key)(code-32);
132 return 0;
133 }
134 }
135