ruby-sdl2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/hint.c ADDED
@@ -0,0 +1,56 @@
1
+ #include "rubysdl2_internal.h"
2
+ #include <SDL_hints.h>
3
+
4
+ static VALUE sym_priority;
5
+
6
+ static VALUE Hints_s_clear(VALUE self)
7
+ {
8
+ SDL_ClearHints();
9
+ return Qnil;
10
+ }
11
+
12
+ static VALUE Hints_s_aref(VALUE self, VALUE name)
13
+ {
14
+ const char* value = SDL_GetHint(StringValueCStr(name));
15
+ if (value)
16
+ return utf8str_new_cstr(value);
17
+ else
18
+ return Qnil;
19
+ }
20
+
21
+ static VALUE Hints_s_aset(int argc, VALUE* argv, VALUE self)
22
+ {
23
+ VALUE name, pri, value;
24
+ rb_scan_args(argc, argv, "21", &name, &pri, &value);
25
+
26
+ if (argc == 2) {
27
+ value = pri;
28
+ return INT2BOOL(SDL_SetHint(StringValueCStr(name), StringValueCStr(value)));
29
+ } else {
30
+ Check_Type(pri, T_HASH);
31
+ return INT2BOOL(SDL_SetHintWithPriority(StringValueCStr(name),
32
+ StringValueCStr(value),
33
+ NUM2INT(rb_hash_aref(pri, sym_priority))));
34
+ }
35
+
36
+ return Qnil;
37
+ }
38
+
39
+ void rubysdl2_init_hints(void)
40
+ {
41
+ VALUE mHints = rb_define_module_under(mSDL2, "Hints");
42
+
43
+ rb_define_singleton_method(mHints, "clear", Hints_s_clear, 0);
44
+ rb_define_singleton_method(mHints, "[]", Hints_s_aref, 1);
45
+ rb_define_singleton_method(mHints, "get", Hints_s_aref, 1);
46
+ rb_define_singleton_method(mHints, "[]=", Hints_s_aset, -1);
47
+ rb_define_singleton_method(mHints, "set", Hints_s_aset, -1);
48
+
49
+ #define DEFINE_HINT_CONST(t) \
50
+ rb_define_const(mHints, #t, INT2NUM(SDL_HINT_##t))
51
+ DEFINE_HINT_CONST(DEFAULT);
52
+ DEFINE_HINT_CONST(NORMAL);
53
+ DEFINE_HINT_CONST(OVERRIDE);
54
+
55
+ sym_priority = ID2SYM(rb_intern("priority"));
56
+ }
@@ -0,0 +1,316 @@
1
+ #include "rubysdl2_internal.h"
2
+ #include <SDL_joystick.h>
3
+ #include <SDL_gamecontroller.h>
4
+
5
+ static VALUE cJoystick;
6
+ static VALUE cDeviceInfo;
7
+
8
+ typedef struct Joystick {
9
+ SDL_Joystick* joystick;
10
+ } Joystick;
11
+
12
+ static void Joystick_free(Joystick* j)
13
+ {
14
+ if (rubysdl2_is_active() && j->joystick)
15
+ SDL_JoystickClose(j->joystick);
16
+ free(j);
17
+ }
18
+
19
+ static VALUE Joystick_new(SDL_Joystick* joystick)
20
+ {
21
+ Joystick* j = ALLOC(Joystick);
22
+ j->joystick = joystick;
23
+ return Data_Wrap_Struct(cJoystick, 0, Joystick_free, j);
24
+ }
25
+
26
+ DEFINE_WRAPPER(SDL_Joystick, Joystick, joystick, cJoystick, "SDL2::Joystick");
27
+
28
+ /*
29
+ * Document-class: SDL2::Joystick
30
+ *
31
+ * This class represents a joystick connected to the machine.
32
+ *
33
+ * In order to use joystick subsystem, {SDL2.init} must have been called
34
+ * with the SDL2::INIT_JOYSTICK flag.
35
+ *
36
+ * @!method destroy?
37
+ * Return true if the device is alread closed.
38
+ * @see #destroy
39
+ */
40
+
41
+ /*
42
+ * Get the number of connected joysticks.
43
+ *
44
+ * @return [Integer]
45
+ */
46
+ static VALUE Joystick_s_num_connected_joysticks(VALUE self)
47
+ {
48
+ return INT2FIX(HANDLE_ERROR(SDL_NumJoysticks()));
49
+ }
50
+
51
+ static VALUE GUID_to_String(SDL_JoystickGUID guid)
52
+ {
53
+ char buf[128];
54
+ SDL_JoystickGetGUIDString(guid, buf, sizeof(buf));
55
+ return rb_usascii_str_new_cstr(buf);
56
+ }
57
+
58
+ /*
59
+ * Get the information of connected joysticks
60
+ *
61
+ * @return [Array<SDL2::Joystick::DeviceInfo>] information of connected devices
62
+ */
63
+ static VALUE Joystick_s_devices(VALUE self)
64
+ {
65
+ int num_joysticks = SDL_NumJoysticks();
66
+ int i;
67
+ VALUE devices = rb_ary_new2(num_joysticks);
68
+ for (i=0; i<num_joysticks; ++i) {
69
+ VALUE device = rb_obj_alloc(cDeviceInfo);
70
+ rb_iv_set(device, "@GUID", GUID_to_String(SDL_JoystickGetDeviceGUID(i)));
71
+ rb_iv_set(device, "@name", utf8str_new_cstr(SDL_JoystickNameForIndex(i)));
72
+ rb_ary_push(devices, device);
73
+ }
74
+ return devices;
75
+ }
76
+
77
+ /*
78
+ * @overload open(device_index)
79
+ * Open a joystick for use.
80
+ *
81
+ * @param [Integer] device_index device index
82
+ * @return [SDL2::Joystick] opended joystick object
83
+ * @raise [SDL2::Error] raised when device open is failed.
84
+ * for exmaple, device_index is out of range.
85
+ */
86
+ static VALUE Joystick_s_open(VALUE self, VALUE device_index)
87
+ {
88
+ SDL_Joystick* joystick = SDL_JoystickOpen(NUM2INT(device_index));
89
+ if (!joystick)
90
+ SDL_ERROR();
91
+ return Joystick_new(joystick);
92
+ }
93
+
94
+ /*
95
+ * @overload game_controller?(index)
96
+ * Return true if the joystick of given index supports the game controller
97
+ * interface.
98
+ *
99
+ * @param [Integer] index the joystick device index
100
+ * @see SDL2::GameController
101
+ *
102
+ */
103
+ static VALUE Joystick_s_game_controller_p(VALUE self, VALUE index)
104
+ {
105
+ return INT2BOOL(SDL_IsGameController(NUM2INT(index)));
106
+ }
107
+
108
+ /*
109
+ * Return true a joystick has been opened and currently connected.
110
+ */
111
+ static VALUE Joystick_attached_p(VALUE self)
112
+ {
113
+ Joystick* j = Get_Joystick(self);
114
+ if (!j->joystick)
115
+ return Qfalse;
116
+ return INT2BOOL(SDL_JoystickGetAttached(j->joystick));
117
+ }
118
+
119
+ /*
120
+ * Get the joystick GUID
121
+ *
122
+ * @return [String] GUID string
123
+ */
124
+ static VALUE Joystick_GUID(VALUE self)
125
+ {
126
+ SDL_JoystickGUID guid;
127
+ char buf[128];
128
+ guid = SDL_JoystickGetGUID(Get_SDL_Joystick(self));
129
+ SDL_JoystickGetGUIDString(guid, buf, sizeof(buf));
130
+ return rb_usascii_str_new_cstr(buf);
131
+ }
132
+
133
+ /*
134
+ * Get the index of a joystick
135
+ *
136
+ * @return [Integer] index
137
+ */
138
+ static VALUE Joystick_index(VALUE self)
139
+ {
140
+ return INT2NUM(HANDLE_ERROR(SDL_JoystickInstanceID(Get_SDL_Joystick(self))));
141
+ }
142
+
143
+ /*
144
+ * Close a joystick device.
145
+ *
146
+ * @return [nil]
147
+ * @see #destroy?
148
+ */
149
+ static VALUE Joystick_destroy(VALUE self)
150
+ {
151
+ Joystick* j = Get_Joystick(self);
152
+ if (j->joystick)
153
+ SDL_JoystickClose(j->joystick);
154
+ j->joystick = NULL;
155
+ return Qnil;
156
+ }
157
+
158
+ /*
159
+ * Get the name of a joystick
160
+ *
161
+ * @return [String] name
162
+ */
163
+ static VALUE Joystick_name(VALUE self)
164
+ {
165
+ return utf8str_new_cstr(SDL_JoystickName(Get_SDL_Joystick(self)));
166
+ }
167
+
168
+ /*
169
+ * Get the number of general axis controls on a joystick.
170
+ * @return [Integer]
171
+ * @see #axis
172
+ */
173
+ static VALUE Joystick_num_axes(VALUE self)
174
+ {
175
+ return INT2FIX(SDL_JoystickNumAxes(Get_SDL_Joystick(self)));
176
+ }
177
+
178
+ /*
179
+ * Get the number of trackball on a joystick
180
+ * @return [Integer]
181
+ * @see #ball
182
+ */
183
+ static VALUE Joystick_num_balls(VALUE self)
184
+ {
185
+ return INT2FIX(SDL_JoystickNumBalls(Get_SDL_Joystick(self)));
186
+ }
187
+
188
+ /*
189
+ * Get the number of button on a joystick
190
+ * @return [Integer]
191
+ * @see #button
192
+ */
193
+ static VALUE Joystick_num_buttons(VALUE self)
194
+ {
195
+ return INT2FIX(SDL_JoystickNumButtons(Get_SDL_Joystick(self)));
196
+ }
197
+
198
+ /*
199
+ * Get the number of POV hats on a joystick
200
+ * @return [Integer]
201
+ * @see #hat
202
+ */
203
+ static VALUE Joystick_num_hats(VALUE self)
204
+ {
205
+ return INT2FIX(SDL_JoystickNumHats(Get_SDL_Joystick(self)));
206
+ }
207
+
208
+ /*
209
+ * @overload axis(which)
210
+ * Get the current state of an axis control on a joystick.
211
+ *
212
+ * @param [Integer] which an index of an axis, started at index 0
213
+ * @return [Integer] state value, ranging from -32768 to 32767.
214
+ * @see #num_axes
215
+ */
216
+ static VALUE Joystick_axis(VALUE self, VALUE which)
217
+ {
218
+ return INT2FIX(SDL_JoystickGetAxis(Get_SDL_Joystick(self), NUM2INT(which)));
219
+ }
220
+
221
+ /*
222
+ * @overload ball(which)
223
+ * Get the current state of a trackball on a joystick.
224
+ *
225
+ * @param [Integer] which an index of a trackball, started at index 0
226
+ * @return [[Integer,Integer]] dx and dy
227
+ * @see #num_balls
228
+ */
229
+ static VALUE Joystick_ball(VALUE self, VALUE which)
230
+ {
231
+ int dx, dy;
232
+ HANDLE_ERROR(SDL_JoystickGetBall(Get_SDL_Joystick(self), NUM2INT(which), &dx, &dy));
233
+ return rb_ary_new3(2, INT2NUM(dx), INT2NUM(dy));
234
+ }
235
+
236
+ /*
237
+ * @overload button(which)
238
+ * Get the current state of a button on a joystick.
239
+ *
240
+ * @param [Integer] which an index of a button, started at index 0
241
+ * @return [Boolean] true if the button is pressed
242
+ * @see #num_buttons
243
+ */
244
+ static VALUE Joystick_button(VALUE self, VALUE which)
245
+ {
246
+ return INT2BOOL(SDL_JoystickGetButton(Get_SDL_Joystick(self), NUM2INT(which)));
247
+ }
248
+
249
+ /*
250
+ * @overload hat(which)
251
+ * Get the current state of a POV hat on a joystick.
252
+ *
253
+ * @param [Integer] which an index of a hat, started at index 0
254
+ * @return [Integer] hat state
255
+ * @see #num_hats
256
+ */
257
+ static VALUE Joystick_hat(VALUE self, VALUE which)
258
+ {
259
+ return UINT2NUM(SDL_JoystickGetHat(Get_SDL_Joystick(self), NUM2INT(which)));
260
+ }
261
+
262
+ /*
263
+ * Document-class: SDL2::Joystick::DeviceInfo
264
+ *
265
+ * This class represents joystick device information, its name and GUID.
266
+ *
267
+ * You can get the information with {SDL2::Joystick.devices}.
268
+ */
269
+ void rubysdl2_init_joystick(void)
270
+ {
271
+ cJoystick = rb_define_class_under(mSDL2, "Joystick", rb_cObject);
272
+ cDeviceInfo = rb_define_class_under(cJoystick, "DeviceInfo", rb_cObject);
273
+
274
+ rb_define_singleton_method(cJoystick, "num_connected_joysticks",
275
+ Joystick_s_num_connected_joysticks, 0);
276
+ rb_define_singleton_method(cJoystick, "devices", Joystick_s_devices, 0);
277
+ rb_define_singleton_method(cJoystick, "open", Joystick_s_open, 1);
278
+ rb_define_singleton_method(cJoystick, "game_controller?",
279
+ Joystick_s_game_controller_p, 1);
280
+ rb_define_method(cJoystick, "destroy?", Joystick_destroy_p, 0);
281
+ rb_define_alias(cJoystick, "close?", "destroy?");
282
+ rb_define_method(cJoystick, "attached?", Joystick_attached_p, 0);
283
+ rb_define_method(cJoystick, "GUID", Joystick_GUID, 0);
284
+ rb_define_method(cJoystick, "index", Joystick_index, 0);
285
+ rb_define_method(cJoystick, "destroy", Joystick_destroy, 0);
286
+ rb_define_alias(cJoystick, "close", "destroy");
287
+ rb_define_method(cJoystick, "name", Joystick_name, 0);
288
+ rb_define_method(cJoystick, "num_axes", Joystick_num_axes, 0);
289
+ rb_define_method(cJoystick, "num_balls", Joystick_num_balls, 0);
290
+ rb_define_method(cJoystick, "num_buttons", Joystick_num_buttons, 0);
291
+ rb_define_method(cJoystick, "num_hats", Joystick_num_hats, 0);
292
+ rb_define_method(cJoystick, "axis", Joystick_axis, 1);
293
+ rb_define_method(cJoystick, "ball", Joystick_ball, 1);
294
+ rb_define_method(cJoystick, "button", Joystick_button, 1);
295
+ rb_define_method(cJoystick, "hat", Joystick_hat, 1);
296
+ #define DEFINE_JOY_HAT_CONST(state) \
297
+ rb_define_const(cJoystick, "HAT_" #state, INT2NUM(SDL_HAT_##state))
298
+ DEFINE_JOY_HAT_CONST(CENTERED);
299
+ DEFINE_JOY_HAT_CONST(UP);
300
+ DEFINE_JOY_HAT_CONST(RIGHT);
301
+ DEFINE_JOY_HAT_CONST(DOWN);
302
+ DEFINE_JOY_HAT_CONST(LEFT);
303
+ DEFINE_JOY_HAT_CONST(RIGHTUP);
304
+ DEFINE_JOY_HAT_CONST(RIGHTDOWN);
305
+ DEFINE_JOY_HAT_CONST(LEFTUP);
306
+ DEFINE_JOY_HAT_CONST(LEFTDOWN);
307
+
308
+ /* Device GUID
309
+ * @return [String] */
310
+ rb_define_attr(cDeviceInfo, "GUID", 1, 0);
311
+ /* Device name
312
+ * @return [String] */
313
+ rb_define_attr(cDeviceInfo, "name", 1, 0);
314
+
315
+
316
+ }
@@ -0,0 +1,794 @@
1
+ /* -*- C -*- */
2
+ #include "rubysdl2_internal.h"
3
+ #include <SDL_events.h>
4
+ #include <SDL_keyboard.h>
5
+ #include <SDL_keycode.h>
6
+ #include <SDL_scancode.h>
7
+
8
+ static VALUE mKey;
9
+ static VALUE mScan;
10
+ static VALUE mMod;
11
+ static VALUE mTextInput;
12
+
13
+ /*
14
+ * Document-module: SDL2::Key
15
+ *
16
+ * This module has "virtual" keycode constants and some
17
+ * keyboard input handling functions.
18
+ *
19
+ */
20
+
21
+ /*
22
+ * @overload name_of(code)
23
+ * @param [Integer] code keycode
24
+ *
25
+ * Get a human-readable name for a key
26
+ *
27
+ * @return [String] the name of given keycode
28
+ * @see .keycode_from_name
29
+ * @see SDL2::Key::Scan.name_of
30
+ */
31
+ static VALUE Key_s_name_of(VALUE self, VALUE code)
32
+ {
33
+ return utf8str_new_cstr(SDL_GetKeyName(NUM2INT(code)));
34
+ }
35
+
36
+ /*
37
+ * @overload keycode_from_name(name)
38
+ * @param [String] name name of a key
39
+ *
40
+ * Get a key code from given name
41
+ * @return [Integer] keycode
42
+ * @see .name_of
43
+ * @see SDL2::Key::Scan.from_name
44
+ */
45
+ static VALUE Key_s_keycode_from_name(VALUE self, VALUE name)
46
+ {
47
+ return INT2NUM(SDL_GetKeyFromName(StringValueCStr(name)));
48
+ }
49
+
50
+ /*
51
+ * @overload keycode_from_scancode(scancode)
52
+ * @param [Integer] scancode scancode
53
+ *
54
+ * Convert a scancode to the corresponding keycode
55
+ *
56
+ * @return [Integer]
57
+ * @see SDL2::Key::Scan.from_keycode
58
+ */
59
+ static VALUE Key_s_keycode_from_scancode(VALUE self, VALUE scancode)
60
+ {
61
+ return INT2NUM(SDL_GetKeyFromScancode(NUM2INT(scancode)));
62
+ }
63
+
64
+ /*
65
+ * @overload pressed?(code)
66
+ * @param [Integer] code scancode
67
+ *
68
+ * Get whether the key of the given scancode is pressed or not.
69
+ */
70
+ static VALUE Key_s_pressed_p(VALUE self, VALUE code)
71
+ {
72
+ const Uint8* state = SDL_GetKeyboardState(NULL);
73
+ SDL_Scancode scancode;
74
+ if (!state) {
75
+ SDL_PumpEvents();
76
+ state = SDL_GetKeyboardState(NULL);
77
+ if (!state)
78
+ rb_raise(eSDL2Error, "Event subsystem is not initialized");
79
+ }
80
+ scancode = NUM2UINT(code);
81
+ if (scancode >= SDL_NUM_SCANCODES)
82
+ rb_raise(rb_eArgError, "too large scancode %d", scancode);
83
+
84
+ return INT2BOOL(state[scancode]);
85
+ }
86
+
87
+ /*
88
+ * Document-module: SDL2::Key::Scan
89
+ *
90
+ * This module has "physical" key scancode constants and some
91
+ * scancode handling functions.
92
+ */
93
+
94
+ /*
95
+ * @overload name_of(code)
96
+ * @param [Integer] code scancode
97
+ *
98
+ * Get a human-readable name of the given scancode
99
+ * @return [String]
100
+ * @see SDL2::Key.name_of
101
+ * @see .from_name
102
+ */
103
+ static VALUE Scan_s_name_of(VALUE self, VALUE code)
104
+ {
105
+ return utf8str_new_cstr(SDL_GetScancodeName(NUM2INT(code)));
106
+ }
107
+
108
+ /*
109
+ * @overload from_name(name)
110
+ * @param [String] name name of a key
111
+ *
112
+ * Get a scancode from the key of the given name
113
+ * @return [String]
114
+ * @see .name_of
115
+ * @see SDL2::Key.keycode_from_name
116
+ */
117
+ static VALUE Scan_s_from_name(VALUE self, VALUE name)
118
+ {
119
+ return INT2NUM(SDL_GetScancodeFromName(StringValueCStr(name)));
120
+ }
121
+
122
+ /*
123
+ * @overload from_keycode(keycode)
124
+ * @param [Integer] keycode keycode
125
+ *
126
+ * Get a keycode corresponding to the given keycode
127
+ * @return [Integer] keycode
128
+ * @see SDL2::Key.keycode_from_scancode
129
+ */
130
+ static VALUE Scan_s_from_keycode(VALUE self, VALUE keycode)
131
+ {
132
+ return INT2NUM(SDL_GetScancodeFromKey(NUM2INT(keycode)));
133
+ }
134
+
135
+ /*
136
+ * Document-module: SDL2::Key::Mod
137
+ *
138
+ * This module has key modifier bitmask constants and
139
+ * some functions to handle key modifier states.
140
+ */
141
+
142
+ /*
143
+ * Get the current key modifier state
144
+ *
145
+ * You can examine whether the modifier key is pressed
146
+ * using bitmask constants of {SDL2::Key::Mod}.
147
+ *
148
+ * @return [Integer] key state
149
+ */
150
+ static VALUE Mod_s_state(VALUE self)
151
+ {
152
+ return UINT2NUM(SDL_GetModState());
153
+ }
154
+
155
+ /*
156
+ * @overload state=(keymod)
157
+ * @param [Integer] keymod key modifier flags (bits)
158
+ *
159
+ * Set the current key modifier state
160
+ *
161
+ * @note This does not change the keyboard state, only the key modifier flags.
162
+ * @return [keymod]
163
+ * @see .state
164
+ */
165
+ static VALUE Mod_s_set_state(VALUE self, VALUE keymod)
166
+ {
167
+ SDL_SetModState(NUM2UINT(keymod));
168
+ return Qnil;
169
+ }
170
+
171
+ static VALUE TextInput_s_active_p(VALUE self)
172
+ {
173
+ return INT2BOOL(SDL_IsTextInputActive());
174
+ }
175
+
176
+ static VALUE TextInput_s_start(VALUE self)
177
+ {
178
+ SDL_StartTextInput(); return Qnil;
179
+ }
180
+
181
+ static VALUE TextInput_s_stop(VALUE self)
182
+ {
183
+ SDL_StopTextInput(); return Qnil;
184
+ }
185
+
186
+ static VALUE TextInput_s_set_rect(VALUE self, VALUE rect)
187
+ {
188
+ SDL_Rect *r = Get_SDL_Rect(rect);
189
+ SDL_SetTextInputRect(r);
190
+ return rect;
191
+ }
192
+
193
+ /*
194
+ define(`DEFINE_SCANCODE',`ifelse(`$#',`2',`$2
195
+ ',`/$8* @return [Integer] scancode for "$1" key *$8/
196
+ ')rb_define_const(mScan, "$1", INT2NUM(SDL_SCANCODE_$1))')
197
+
198
+ define(`DEFINE_SCANCODE_NUMBER',`/$8* @return [Integer] scancode for number key "$1" (not on keypad) *$8/
199
+ rb_define_const(mScan, "K$1", INT2NUM(SDL_SCANCODE_$1))')
200
+
201
+ define(`DEFINE_SCANCODE_ALPH',`/$8* @return [Integer] scancode for alphabet key "$1" *$8/
202
+ rb_define_const(mScan, "$1", INT2NUM(SDL_SCANCODE_$1))')
203
+
204
+ define(`DEFINE_KEYCODE', `ifelse(`$#',`2',`$2
205
+ ',`/$8* @return [Integer] keycode for "$1" key *$8/
206
+ ')rb_define_const(mKey, "$1", INT2NUM(SDLK_$1))')
207
+
208
+ define(`DEFINE_KEYCODE_NUMBER',`/$8* @return [Integer] keycode for number key "$1" (not on keypad) *$8/
209
+ rb_define_const(mKey, "K$1", INT2NUM(SDLK_$1))')
210
+
211
+ define(`DEFINE_KEYCODE_ALPH',`/$8* @return [Integer] keycode for alphabet key "$1" *$8/
212
+ rb_define_const(mKey, "translit($1,`a-z',`A-Z')", INT2NUM(SDLK_$1))')
213
+
214
+ define(`DEFINE_KEYMOD',`rb_define_const(mMod, "$1", INT2NUM(KMOD_$1))')
215
+ */
216
+ void rubysdl2_init_key(void)
217
+ {
218
+ mKey = rb_define_module_under(mSDL2, "Key");
219
+ mScan = rb_define_module_under(mKey, "Scan");
220
+ mMod = rb_define_module_under(mKey, "Mod");
221
+ mTextInput = rb_define_module_under(mSDL2, "TextInput");
222
+
223
+ rb_define_module_function(mKey, "name_of", Key_s_name_of, 1);
224
+ rb_define_module_function(mKey, "keycode_from_name", Key_s_keycode_from_name, 1);
225
+ rb_define_module_function(mKey, "keycode_from_scancode", Key_s_keycode_from_scancode, 1);
226
+ rb_define_module_function(mKey, "pressed?", Key_s_pressed_p, 1);
227
+ rb_define_module_function(mScan, "name_of", Scan_s_name_of, 1);
228
+ rb_define_module_function(mScan, "from_name", Scan_s_from_name, 1);
229
+ rb_define_module_function(mScan, "from_keycode", Scan_s_from_keycode, 1);
230
+ rb_define_module_function(mMod, "state", Mod_s_state, 0);
231
+ rb_define_module_function(mMod, "state=", Mod_s_set_state, 1);
232
+ rb_define_module_function(mTextInput, "active?", TextInput_s_active_p, 0);
233
+ rb_define_module_function(mTextInput, "start", TextInput_s_start, 0);
234
+ rb_define_module_function(mTextInput, "stop", TextInput_s_stop, 0);
235
+ rb_define_module_function(mTextInput, "rect=", TextInput_s_set_rect, 1);
236
+
237
+ DEFINE_SCANCODE(UNKNOWN,/* @return [Integer] unused scancode */);
238
+ DEFINE_SCANCODE_ALPH(A);
239
+ DEFINE_SCANCODE_ALPH(B);
240
+ DEFINE_SCANCODE_ALPH(C);
241
+ DEFINE_SCANCODE_ALPH(D);
242
+ DEFINE_SCANCODE_ALPH(E);
243
+ DEFINE_SCANCODE_ALPH(F);
244
+ DEFINE_SCANCODE_ALPH(G);
245
+ DEFINE_SCANCODE_ALPH(H);
246
+ DEFINE_SCANCODE_ALPH(I);
247
+ DEFINE_SCANCODE_ALPH(J);
248
+ DEFINE_SCANCODE_ALPH(K);
249
+ DEFINE_SCANCODE_ALPH(L);
250
+ DEFINE_SCANCODE_ALPH(M);
251
+ DEFINE_SCANCODE_ALPH(N);
252
+ DEFINE_SCANCODE_ALPH(O);
253
+ DEFINE_SCANCODE_ALPH(P);
254
+ DEFINE_SCANCODE_ALPH(Q);
255
+ DEFINE_SCANCODE_ALPH(R);
256
+ DEFINE_SCANCODE_ALPH(S);
257
+ DEFINE_SCANCODE_ALPH(T);
258
+ DEFINE_SCANCODE_ALPH(U);
259
+ DEFINE_SCANCODE_ALPH(V);
260
+ DEFINE_SCANCODE_ALPH(W);
261
+ DEFINE_SCANCODE_ALPH(X);
262
+ DEFINE_SCANCODE_ALPH(Y);
263
+ DEFINE_SCANCODE_ALPH(Z);
264
+
265
+ DEFINE_SCANCODE_NUMBER(1);
266
+ DEFINE_SCANCODE_NUMBER(2);
267
+ DEFINE_SCANCODE_NUMBER(3);
268
+ DEFINE_SCANCODE_NUMBER(4);
269
+ DEFINE_SCANCODE_NUMBER(5);
270
+ DEFINE_SCANCODE_NUMBER(6);
271
+ DEFINE_SCANCODE_NUMBER(7);
272
+ DEFINE_SCANCODE_NUMBER(8);
273
+ DEFINE_SCANCODE_NUMBER(9);
274
+ DEFINE_SCANCODE_NUMBER(0);
275
+
276
+ DEFINE_SCANCODE(RETURN);
277
+ DEFINE_SCANCODE(ESCAPE);
278
+ DEFINE_SCANCODE(BACKSPACE);
279
+ DEFINE_SCANCODE(TAB);
280
+ DEFINE_SCANCODE(SPACE);
281
+
282
+ DEFINE_SCANCODE(MINUS);
283
+ DEFINE_SCANCODE(EQUALS);
284
+ DEFINE_SCANCODE(LEFTBRACKET);
285
+ DEFINE_SCANCODE(RIGHTBRACKET);
286
+ DEFINE_SCANCODE(BACKSLASH);
287
+
288
+ DEFINE_SCANCODE(NONUSHASH);
289
+ DEFINE_SCANCODE(SEMICOLON);
290
+ DEFINE_SCANCODE(APOSTROPHE);
291
+ DEFINE_SCANCODE(GRAVE);
292
+ DEFINE_SCANCODE(COMMA);
293
+ DEFINE_SCANCODE(PERIOD);
294
+ DEFINE_SCANCODE(SLASH);
295
+
296
+ DEFINE_SCANCODE(CAPSLOCK);
297
+
298
+ DEFINE_SCANCODE(F1);
299
+ DEFINE_SCANCODE(F2);
300
+ DEFINE_SCANCODE(F3);
301
+ DEFINE_SCANCODE(F4);
302
+ DEFINE_SCANCODE(F5);
303
+ DEFINE_SCANCODE(F6);
304
+ DEFINE_SCANCODE(F7);
305
+ DEFINE_SCANCODE(F8);
306
+ DEFINE_SCANCODE(F9);
307
+ DEFINE_SCANCODE(F10);
308
+ DEFINE_SCANCODE(F11);
309
+ DEFINE_SCANCODE(F12);
310
+
311
+ DEFINE_SCANCODE(PRINTSCREEN);
312
+ DEFINE_SCANCODE(SCROLLLOCK);
313
+ DEFINE_SCANCODE(PAUSE);
314
+ DEFINE_SCANCODE(INSERT);
315
+
316
+ DEFINE_SCANCODE(HOME);
317
+ DEFINE_SCANCODE(PAGEUP);
318
+ DEFINE_SCANCODE(DELETE);
319
+ DEFINE_SCANCODE(END);
320
+ DEFINE_SCANCODE(PAGEDOWN);
321
+ DEFINE_SCANCODE(RIGHT);
322
+ DEFINE_SCANCODE(LEFT);
323
+ DEFINE_SCANCODE(DOWN);
324
+ DEFINE_SCANCODE(UP);
325
+
326
+ DEFINE_SCANCODE(NUMLOCKCLEAR);
327
+
328
+ DEFINE_SCANCODE(KP_DIVIDE);
329
+ DEFINE_SCANCODE(KP_MULTIPLY);
330
+ DEFINE_SCANCODE(KP_MINUS);
331
+ DEFINE_SCANCODE(KP_PLUS);
332
+ DEFINE_SCANCODE(KP_ENTER);
333
+ DEFINE_SCANCODE(KP_1);
334
+ DEFINE_SCANCODE(KP_2);
335
+ DEFINE_SCANCODE(KP_3);
336
+ DEFINE_SCANCODE(KP_4);
337
+ DEFINE_SCANCODE(KP_5);
338
+ DEFINE_SCANCODE(KP_6);
339
+ DEFINE_SCANCODE(KP_7);
340
+ DEFINE_SCANCODE(KP_8);
341
+ DEFINE_SCANCODE(KP_9);
342
+ DEFINE_SCANCODE(KP_0);
343
+ DEFINE_SCANCODE(KP_PERIOD);
344
+
345
+ DEFINE_SCANCODE(NONUSBACKSLASH);
346
+ DEFINE_SCANCODE(APPLICATION);
347
+ DEFINE_SCANCODE(POWER);
348
+ DEFINE_SCANCODE(KP_EQUALS);
349
+ DEFINE_SCANCODE(F13);
350
+ DEFINE_SCANCODE(F14);
351
+ DEFINE_SCANCODE(F15);
352
+ DEFINE_SCANCODE(F16);
353
+ DEFINE_SCANCODE(F17);
354
+ DEFINE_SCANCODE(F18);
355
+ DEFINE_SCANCODE(F19);
356
+ DEFINE_SCANCODE(F20);
357
+ DEFINE_SCANCODE(F21);
358
+ DEFINE_SCANCODE(F22);
359
+ DEFINE_SCANCODE(F23);
360
+ DEFINE_SCANCODE(F24);
361
+ DEFINE_SCANCODE(EXECUTE);
362
+ DEFINE_SCANCODE(HELP);
363
+ DEFINE_SCANCODE(MENU);
364
+ DEFINE_SCANCODE(SELECT);
365
+ DEFINE_SCANCODE(STOP);
366
+ DEFINE_SCANCODE(AGAIN);
367
+ DEFINE_SCANCODE(UNDO);
368
+ DEFINE_SCANCODE(CUT);
369
+ DEFINE_SCANCODE(COPY);
370
+ DEFINE_SCANCODE(PASTE);
371
+ DEFINE_SCANCODE(FIND);
372
+ DEFINE_SCANCODE(MUTE);
373
+ DEFINE_SCANCODE(VOLUMEUP);
374
+ DEFINE_SCANCODE(VOLUMEDOWN);
375
+ /* not sure whether there's a reason to enable these */
376
+ /* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
377
+ /* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
378
+ /* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
379
+ DEFINE_SCANCODE(KP_COMMA);
380
+ DEFINE_SCANCODE(KP_EQUALSAS400);
381
+
382
+ DEFINE_SCANCODE(INTERNATIONAL1);
383
+
384
+ DEFINE_SCANCODE(INTERNATIONAL2);
385
+ DEFINE_SCANCODE(INTERNATIONAL3);
386
+ DEFINE_SCANCODE(INTERNATIONAL4);
387
+ DEFINE_SCANCODE(INTERNATIONAL5);
388
+ DEFINE_SCANCODE(INTERNATIONAL6);
389
+ DEFINE_SCANCODE(INTERNATIONAL7);
390
+ DEFINE_SCANCODE(INTERNATIONAL8);
391
+ DEFINE_SCANCODE(INTERNATIONAL9);
392
+ DEFINE_SCANCODE(LANG1);
393
+ DEFINE_SCANCODE(LANG2);
394
+ DEFINE_SCANCODE(LANG3);
395
+ DEFINE_SCANCODE(LANG4);
396
+ DEFINE_SCANCODE(LANG5);
397
+ DEFINE_SCANCODE(LANG6);
398
+ DEFINE_SCANCODE(LANG7);
399
+ DEFINE_SCANCODE(LANG8);
400
+ DEFINE_SCANCODE(LANG9);
401
+
402
+ DEFINE_SCANCODE(ALTERASE);
403
+ DEFINE_SCANCODE(SYSREQ);
404
+ DEFINE_SCANCODE(CANCEL);
405
+ DEFINE_SCANCODE(CLEAR);
406
+ DEFINE_SCANCODE(PRIOR);
407
+ DEFINE_SCANCODE(RETURN2);
408
+ DEFINE_SCANCODE(SEPARATOR);
409
+ DEFINE_SCANCODE(OUT);
410
+ DEFINE_SCANCODE(OPER);
411
+ DEFINE_SCANCODE(CLEARAGAIN);
412
+ DEFINE_SCANCODE(CRSEL);
413
+ DEFINE_SCANCODE(EXSEL);
414
+
415
+ DEFINE_SCANCODE(KP_00);
416
+ DEFINE_SCANCODE(KP_000);
417
+ DEFINE_SCANCODE(THOUSANDSSEPARATOR);
418
+ DEFINE_SCANCODE(DECIMALSEPARATOR);
419
+ DEFINE_SCANCODE(CURRENCYUNIT);
420
+ DEFINE_SCANCODE(CURRENCYSUBUNIT);
421
+ DEFINE_SCANCODE(KP_LEFTPAREN);
422
+ DEFINE_SCANCODE(KP_RIGHTPAREN);
423
+ DEFINE_SCANCODE(KP_LEFTBRACE);
424
+ DEFINE_SCANCODE(KP_RIGHTBRACE);
425
+ DEFINE_SCANCODE(KP_TAB);
426
+ DEFINE_SCANCODE(KP_BACKSPACE);
427
+ DEFINE_SCANCODE(KP_A);
428
+ DEFINE_SCANCODE(KP_B);
429
+ DEFINE_SCANCODE(KP_C);
430
+ DEFINE_SCANCODE(KP_D);
431
+ DEFINE_SCANCODE(KP_E);
432
+ DEFINE_SCANCODE(KP_F);
433
+ DEFINE_SCANCODE(KP_XOR);
434
+ DEFINE_SCANCODE(KP_POWER);
435
+ DEFINE_SCANCODE(KP_PERCENT);
436
+ DEFINE_SCANCODE(KP_LESS);
437
+ DEFINE_SCANCODE(KP_GREATER);
438
+ DEFINE_SCANCODE(KP_AMPERSAND);
439
+ DEFINE_SCANCODE(KP_DBLAMPERSAND);
440
+ DEFINE_SCANCODE(KP_VERTICALBAR);
441
+ DEFINE_SCANCODE(KP_DBLVERTICALBAR);
442
+ DEFINE_SCANCODE(KP_COLON);
443
+ DEFINE_SCANCODE(KP_HASH);
444
+ DEFINE_SCANCODE(KP_SPACE);
445
+ DEFINE_SCANCODE(KP_AT);
446
+ DEFINE_SCANCODE(KP_EXCLAM);
447
+ DEFINE_SCANCODE(KP_MEMSTORE);
448
+ DEFINE_SCANCODE(KP_MEMRECALL);
449
+ DEFINE_SCANCODE(KP_MEMCLEAR);
450
+ DEFINE_SCANCODE(KP_MEMADD);
451
+ DEFINE_SCANCODE(KP_MEMSUBTRACT);
452
+ DEFINE_SCANCODE(KP_MEMMULTIPLY);
453
+ DEFINE_SCANCODE(KP_MEMDIVIDE);
454
+ DEFINE_SCANCODE(KP_PLUSMINUS);
455
+ DEFINE_SCANCODE(KP_CLEAR);
456
+ DEFINE_SCANCODE(KP_CLEARENTRY);
457
+ DEFINE_SCANCODE(KP_BINARY);
458
+ DEFINE_SCANCODE(KP_OCTAL);
459
+ DEFINE_SCANCODE(KP_DECIMAL);
460
+ DEFINE_SCANCODE(KP_HEXADECIMAL);
461
+
462
+ DEFINE_SCANCODE(LCTRL);
463
+ DEFINE_SCANCODE(LSHIFT);
464
+ DEFINE_SCANCODE(LALT);
465
+ DEFINE_SCANCODE(LGUI);
466
+ DEFINE_SCANCODE(RCTRL);
467
+ DEFINE_SCANCODE(RSHIFT);
468
+ DEFINE_SCANCODE(RALT);
469
+ DEFINE_SCANCODE(RGUI);
470
+
471
+ DEFINE_SCANCODE(MODE);
472
+
473
+ DEFINE_SCANCODE(AUDIONEXT);
474
+ DEFINE_SCANCODE(AUDIOPREV);
475
+ DEFINE_SCANCODE(AUDIOSTOP);
476
+ DEFINE_SCANCODE(AUDIOPLAY);
477
+ DEFINE_SCANCODE(AUDIOMUTE);
478
+ DEFINE_SCANCODE(MEDIASELECT);
479
+ DEFINE_SCANCODE(WWW);
480
+ DEFINE_SCANCODE(MAIL);
481
+ DEFINE_SCANCODE(CALCULATOR);
482
+ DEFINE_SCANCODE(COMPUTER);
483
+ DEFINE_SCANCODE(AC_SEARCH);
484
+ DEFINE_SCANCODE(AC_HOME);
485
+ DEFINE_SCANCODE(AC_BACK);
486
+ DEFINE_SCANCODE(AC_FORWARD);
487
+ DEFINE_SCANCODE(AC_STOP);
488
+ DEFINE_SCANCODE(AC_REFRESH);
489
+ DEFINE_SCANCODE(AC_BOOKMARKS);
490
+
491
+ DEFINE_SCANCODE(BRIGHTNESSDOWN);
492
+ DEFINE_SCANCODE(BRIGHTNESSUP);
493
+ DEFINE_SCANCODE(DISPLAYSWITCH);
494
+
495
+ DEFINE_SCANCODE(KBDILLUMTOGGLE);
496
+ DEFINE_SCANCODE(KBDILLUMDOWN);
497
+ DEFINE_SCANCODE(KBDILLUMUP);
498
+ DEFINE_SCANCODE(EJECT);
499
+ DEFINE_SCANCODE(SLEEP);
500
+
501
+ DEFINE_SCANCODE(APP1);
502
+ DEFINE_SCANCODE(APP2);
503
+
504
+ DEFINE_KEYCODE(UNKNOWN,/* @return [Integer] unused keycode */);
505
+ DEFINE_KEYCODE(RETURN);
506
+ DEFINE_KEYCODE(ESCAPE);
507
+ DEFINE_KEYCODE(BACKSPACE);
508
+ DEFINE_KEYCODE(TAB);
509
+ DEFINE_KEYCODE(SPACE);
510
+ DEFINE_KEYCODE(EXCLAIM);
511
+ DEFINE_KEYCODE(QUOTEDBL);
512
+ DEFINE_KEYCODE(HASH);
513
+ DEFINE_KEYCODE(PERCENT);
514
+ DEFINE_KEYCODE(DOLLAR);
515
+ DEFINE_KEYCODE(AMPERSAND);
516
+ DEFINE_KEYCODE(QUOTE);
517
+ DEFINE_KEYCODE(LEFTPAREN);
518
+ DEFINE_KEYCODE(RIGHTPAREN);
519
+ DEFINE_KEYCODE(ASTERISK);
520
+ DEFINE_KEYCODE(PLUS);
521
+ DEFINE_KEYCODE(COMMA);
522
+ DEFINE_KEYCODE(MINUS);
523
+ DEFINE_KEYCODE(PERIOD);
524
+ DEFINE_KEYCODE(SLASH);
525
+ DEFINE_KEYCODE_NUMBER(0);
526
+ DEFINE_KEYCODE_NUMBER(1);
527
+ DEFINE_KEYCODE_NUMBER(2);
528
+ DEFINE_KEYCODE_NUMBER(3);
529
+ DEFINE_KEYCODE_NUMBER(4);
530
+ DEFINE_KEYCODE_NUMBER(5);
531
+ DEFINE_KEYCODE_NUMBER(6);
532
+ DEFINE_KEYCODE_NUMBER(7);
533
+ DEFINE_KEYCODE_NUMBER(8);
534
+ DEFINE_KEYCODE_NUMBER(9);
535
+ DEFINE_KEYCODE(COLON);
536
+ DEFINE_KEYCODE(SEMICOLON);
537
+ DEFINE_KEYCODE(LESS);
538
+ DEFINE_KEYCODE(EQUALS);
539
+ DEFINE_KEYCODE(GREATER);
540
+ DEFINE_KEYCODE(QUESTION);
541
+ DEFINE_KEYCODE(AT);
542
+ /*
543
+ Skip uppercase letters
544
+ */
545
+ DEFINE_KEYCODE(LEFTBRACKET);
546
+ DEFINE_KEYCODE(BACKSLASH);
547
+ DEFINE_KEYCODE(RIGHTBRACKET);
548
+ DEFINE_KEYCODE(CARET);
549
+ DEFINE_KEYCODE(UNDERSCORE);
550
+ DEFINE_KEYCODE(BACKQUOTE);
551
+
552
+ DEFINE_KEYCODE_ALPH(a);
553
+ DEFINE_KEYCODE_ALPH(b);
554
+ DEFINE_KEYCODE_ALPH(c);
555
+ DEFINE_KEYCODE_ALPH(d);
556
+ DEFINE_KEYCODE_ALPH(e);
557
+ DEFINE_KEYCODE_ALPH(f);
558
+ DEFINE_KEYCODE_ALPH(g);
559
+ DEFINE_KEYCODE_ALPH(h);
560
+ DEFINE_KEYCODE_ALPH(i);
561
+ DEFINE_KEYCODE_ALPH(j);
562
+ DEFINE_KEYCODE_ALPH(k);
563
+ DEFINE_KEYCODE_ALPH(l);
564
+ DEFINE_KEYCODE_ALPH(m);
565
+ DEFINE_KEYCODE_ALPH(n);
566
+ DEFINE_KEYCODE_ALPH(o);
567
+ DEFINE_KEYCODE_ALPH(p);
568
+ DEFINE_KEYCODE_ALPH(q);
569
+ DEFINE_KEYCODE_ALPH(r);
570
+ DEFINE_KEYCODE_ALPH(s);
571
+ DEFINE_KEYCODE_ALPH(t);
572
+ DEFINE_KEYCODE_ALPH(u);
573
+ DEFINE_KEYCODE_ALPH(v);
574
+ DEFINE_KEYCODE_ALPH(w);
575
+ DEFINE_KEYCODE_ALPH(x);
576
+ DEFINE_KEYCODE_ALPH(y);
577
+ DEFINE_KEYCODE_ALPH(z);
578
+
579
+ DEFINE_KEYCODE(CAPSLOCK);
580
+
581
+ DEFINE_KEYCODE(F1);
582
+ DEFINE_KEYCODE(F2);
583
+ DEFINE_KEYCODE(F3);
584
+ DEFINE_KEYCODE(F4);
585
+ DEFINE_KEYCODE(F5);
586
+ DEFINE_KEYCODE(F6);
587
+ DEFINE_KEYCODE(F7);
588
+ DEFINE_KEYCODE(F8);
589
+ DEFINE_KEYCODE(F9);
590
+ DEFINE_KEYCODE(F10);
591
+ DEFINE_KEYCODE(F11);
592
+ DEFINE_KEYCODE(F12);
593
+
594
+ DEFINE_KEYCODE(PRINTSCREEN);
595
+ DEFINE_KEYCODE(SCROLLLOCK);
596
+ DEFINE_KEYCODE(PAUSE);
597
+ DEFINE_KEYCODE(INSERT);
598
+ DEFINE_KEYCODE(HOME);
599
+ DEFINE_KEYCODE(PAGEUP);
600
+ DEFINE_KEYCODE(DELETE);
601
+ DEFINE_KEYCODE(END);
602
+ DEFINE_KEYCODE(PAGEDOWN);
603
+ DEFINE_KEYCODE(RIGHT);
604
+ DEFINE_KEYCODE(LEFT);
605
+ DEFINE_KEYCODE(DOWN);
606
+ DEFINE_KEYCODE(UP);
607
+
608
+ DEFINE_KEYCODE(NUMLOCKCLEAR);
609
+ DEFINE_KEYCODE(KP_DIVIDE);
610
+ DEFINE_KEYCODE(KP_MULTIPLY);
611
+ DEFINE_KEYCODE(KP_MINUS);
612
+ DEFINE_KEYCODE(KP_PLUS);
613
+ DEFINE_KEYCODE(KP_ENTER);
614
+ DEFINE_KEYCODE(KP_1);
615
+ DEFINE_KEYCODE(KP_2);
616
+ DEFINE_KEYCODE(KP_3);
617
+ DEFINE_KEYCODE(KP_4);
618
+ DEFINE_KEYCODE(KP_5);
619
+ DEFINE_KEYCODE(KP_6);
620
+ DEFINE_KEYCODE(KP_7);
621
+ DEFINE_KEYCODE(KP_8);
622
+ DEFINE_KEYCODE(KP_9);
623
+ DEFINE_KEYCODE(KP_0);
624
+ DEFINE_KEYCODE(KP_PERIOD);
625
+
626
+ DEFINE_KEYCODE(APPLICATION);
627
+ DEFINE_KEYCODE(POWER);
628
+ DEFINE_KEYCODE(KP_EQUALS);
629
+ DEFINE_KEYCODE(F13);
630
+ DEFINE_KEYCODE(F14);
631
+ DEFINE_KEYCODE(F15);
632
+ DEFINE_KEYCODE(F16);
633
+ DEFINE_KEYCODE(F17);
634
+ DEFINE_KEYCODE(F18);
635
+ DEFINE_KEYCODE(F19);
636
+ DEFINE_KEYCODE(F20);
637
+ DEFINE_KEYCODE(F21);
638
+ DEFINE_KEYCODE(F22);
639
+ DEFINE_KEYCODE(F23);
640
+ DEFINE_KEYCODE(F24);
641
+ DEFINE_KEYCODE(EXECUTE);
642
+ DEFINE_KEYCODE(HELP);
643
+ DEFINE_KEYCODE(MENU);
644
+ DEFINE_KEYCODE(SELECT);
645
+ DEFINE_KEYCODE(STOP);
646
+ DEFINE_KEYCODE(AGAIN);
647
+ DEFINE_KEYCODE(UNDO);
648
+ DEFINE_KEYCODE(CUT);
649
+ DEFINE_KEYCODE(COPY);
650
+ DEFINE_KEYCODE(PASTE);
651
+ DEFINE_KEYCODE(FIND);
652
+ DEFINE_KEYCODE(MUTE);
653
+ DEFINE_KEYCODE(VOLUMEUP);
654
+ DEFINE_KEYCODE(VOLUMEDOWN);
655
+ DEFINE_KEYCODE(KP_COMMA);
656
+ DEFINE_KEYCODE(KP_EQUALSAS400);
657
+
658
+ DEFINE_KEYCODE(ALTERASE);
659
+ DEFINE_KEYCODE(SYSREQ);
660
+ DEFINE_KEYCODE(CANCEL);
661
+ DEFINE_KEYCODE(CLEAR);
662
+ DEFINE_KEYCODE(PRIOR);
663
+ DEFINE_KEYCODE(RETURN2);
664
+ DEFINE_KEYCODE(SEPARATOR);
665
+ DEFINE_KEYCODE(OUT);
666
+ DEFINE_KEYCODE(OPER);
667
+ DEFINE_KEYCODE(CLEARAGAIN);
668
+ DEFINE_KEYCODE(CRSEL);
669
+ DEFINE_KEYCODE(EXSEL);
670
+
671
+ DEFINE_KEYCODE(KP_00);
672
+ DEFINE_KEYCODE(KP_000);
673
+ DEFINE_KEYCODE(THOUSANDSSEPARATOR);
674
+
675
+ DEFINE_KEYCODE(DECIMALSEPARATOR);
676
+
677
+ DEFINE_KEYCODE(CURRENCYUNIT);
678
+ DEFINE_KEYCODE(CURRENCYSUBUNIT);
679
+ DEFINE_KEYCODE(KP_LEFTPAREN);
680
+ DEFINE_KEYCODE(KP_RIGHTPAREN);
681
+ DEFINE_KEYCODE(KP_LEFTBRACE);
682
+ DEFINE_KEYCODE(KP_RIGHTBRACE);
683
+ DEFINE_KEYCODE(KP_TAB);
684
+ DEFINE_KEYCODE(KP_BACKSPACE);
685
+ DEFINE_KEYCODE(KP_A);
686
+ DEFINE_KEYCODE(KP_B);
687
+ DEFINE_KEYCODE(KP_C);
688
+ DEFINE_KEYCODE(KP_D);
689
+ DEFINE_KEYCODE(KP_E);
690
+ DEFINE_KEYCODE(KP_F);
691
+ DEFINE_KEYCODE(KP_XOR);
692
+ DEFINE_KEYCODE(KP_POWER);
693
+ DEFINE_KEYCODE(KP_PERCENT);
694
+ DEFINE_KEYCODE(KP_LESS);
695
+ DEFINE_KEYCODE(KP_GREATER);
696
+ DEFINE_KEYCODE(KP_AMPERSAND);
697
+ DEFINE_KEYCODE(KP_DBLAMPERSAND);
698
+ DEFINE_KEYCODE(KP_VERTICALBAR);
699
+ DEFINE_KEYCODE(KP_DBLVERTICALBAR);
700
+ DEFINE_KEYCODE(KP_COLON);
701
+ DEFINE_KEYCODE(KP_HASH);
702
+ DEFINE_KEYCODE(KP_SPACE);
703
+ DEFINE_KEYCODE(KP_AT);
704
+ DEFINE_KEYCODE(KP_EXCLAM);
705
+ DEFINE_KEYCODE(KP_MEMSTORE);
706
+ DEFINE_KEYCODE(KP_MEMRECALL);
707
+ DEFINE_KEYCODE(KP_MEMCLEAR);
708
+ DEFINE_KEYCODE(KP_MEMADD);
709
+ DEFINE_KEYCODE(KP_MEMSUBTRACT);
710
+ DEFINE_KEYCODE(KP_MEMMULTIPLY);
711
+ DEFINE_KEYCODE(KP_MEMDIVIDE);
712
+ DEFINE_KEYCODE(KP_PLUSMINUS);
713
+ DEFINE_KEYCODE(KP_CLEAR);
714
+ DEFINE_KEYCODE(KP_CLEARENTRY);
715
+ DEFINE_KEYCODE(KP_BINARY);
716
+ DEFINE_KEYCODE(KP_OCTAL);
717
+ DEFINE_KEYCODE(KP_DECIMAL);
718
+ DEFINE_KEYCODE(KP_HEXADECIMAL);
719
+
720
+ DEFINE_KEYCODE(LCTRL);
721
+ DEFINE_KEYCODE(LSHIFT);
722
+ DEFINE_KEYCODE(LALT);
723
+ DEFINE_KEYCODE(LGUI);
724
+ DEFINE_KEYCODE(RCTRL);
725
+ DEFINE_KEYCODE(RSHIFT);
726
+ DEFINE_KEYCODE(RALT);
727
+ DEFINE_KEYCODE(RGUI);
728
+
729
+ DEFINE_KEYCODE(MODE);
730
+
731
+ DEFINE_KEYCODE(AUDIONEXT);
732
+ DEFINE_KEYCODE(AUDIOPREV);
733
+ DEFINE_KEYCODE(AUDIOSTOP);
734
+ DEFINE_KEYCODE(AUDIOPLAY);
735
+ DEFINE_KEYCODE(AUDIOMUTE);
736
+ DEFINE_KEYCODE(MEDIASELECT);
737
+ DEFINE_KEYCODE(WWW);
738
+ DEFINE_KEYCODE(MAIL);
739
+ DEFINE_KEYCODE(CALCULATOR);
740
+ DEFINE_KEYCODE(COMPUTER);
741
+ DEFINE_KEYCODE(AC_SEARCH);
742
+ DEFINE_KEYCODE(AC_HOME);
743
+ DEFINE_KEYCODE(AC_BACK);
744
+ DEFINE_KEYCODE(AC_FORWARD);
745
+ DEFINE_KEYCODE(AC_STOP);
746
+ DEFINE_KEYCODE(AC_REFRESH);
747
+ DEFINE_KEYCODE(AC_BOOKMARKS);
748
+
749
+ DEFINE_KEYCODE(BRIGHTNESSDOWN);
750
+
751
+ DEFINE_KEYCODE(BRIGHTNESSUP);
752
+ DEFINE_KEYCODE(DISPLAYSWITCH);
753
+ DEFINE_KEYCODE(KBDILLUMTOGGLE);
754
+
755
+ DEFINE_KEYCODE(KBDILLUMDOWN);
756
+ DEFINE_KEYCODE(KBDILLUMUP);
757
+ DEFINE_KEYCODE(EJECT);
758
+ DEFINE_KEYCODE(SLEEP);
759
+
760
+ /* 0 (no modifier is applicable) */
761
+ DEFINE_KEYMOD(NONE);
762
+ /* the modifier key bit mask for the left shift key */
763
+ DEFINE_KEYMOD(LSHIFT);
764
+ /* the modifier key bit mask for the right shift key */
765
+ DEFINE_KEYMOD(RSHIFT);
766
+ /* the modifier key bit mask for the left control key */
767
+ DEFINE_KEYMOD(LCTRL);
768
+ /* the modifier key bit mask for the right control key */
769
+ DEFINE_KEYMOD(RCTRL);
770
+ /* the modifier key bit mask for the left alt key */
771
+ DEFINE_KEYMOD(LALT);
772
+ /* the modifier key bit mask for the right alt key */
773
+ DEFINE_KEYMOD(RALT);
774
+ /* the modifier key bit mask for the left GUI key (often the window key) */
775
+ DEFINE_KEYMOD(LGUI);
776
+ /* the modifier key bit mask for the right GUI key (often the window key) */
777
+ DEFINE_KEYMOD(RGUI);
778
+ /* the modifier key bit mask for the numlock key */
779
+ DEFINE_KEYMOD(NUM);
780
+ /* the modifier key bit mask for the capslock key */
781
+ DEFINE_KEYMOD(CAPS);
782
+ /* the modifier key bit mask for the mode key (AltGr) */
783
+ DEFINE_KEYMOD(MODE);
784
+ /* the modifier key bit mask for the left and right control key */
785
+ DEFINE_KEYMOD(CTRL);
786
+ /* the modifier key bit mask for the left and right shift key */
787
+ DEFINE_KEYMOD(SHIFT);
788
+ /* the modifier key bit mask for the left and right alt key */
789
+ DEFINE_KEYMOD(ALT);
790
+ /* the modifier key bit mask for the left and right GUI key */
791
+ DEFINE_KEYMOD(GUI);
792
+ /* reserved for future use */
793
+ DEFINE_KEYMOD(RESERVED);
794
+ }