rubygame 2.5.3 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/CREDITS +6 -4
  2. data/NEWS +79 -0
  3. data/README +55 -72
  4. data/ROADMAP +20 -13
  5. data/doc/custom_sdl_load_paths.rdoc +79 -0
  6. data/doc/getting_started.rdoc +65 -36
  7. data/doc/keyboard_symbols.rdoc +243 -0
  8. data/doc/macosx_install.rdoc +49 -35
  9. data/doc/windows_install.rdoc +36 -108
  10. data/lib/rubygame.rb +62 -24
  11. data/lib/rubygame/audio.rb +147 -0
  12. data/lib/rubygame/clock.rb +164 -1
  13. data/lib/rubygame/color.rb +40 -7
  14. data/lib/rubygame/color/models/hsl.rb +1 -1
  15. data/lib/rubygame/color/models/hsv.rb +1 -1
  16. data/lib/rubygame/color/models/rgb.rb +1 -1
  17. data/lib/rubygame/color/palettes/css.rb +1 -3
  18. data/lib/rubygame/color/palettes/x11.rb +1 -2
  19. data/lib/rubygame/constants.rb +297 -0
  20. data/lib/rubygame/deprecated_mixer.rb +555 -0
  21. data/lib/rubygame/event.rb +122 -6
  22. data/lib/rubygame/event_handler.rb +3 -1
  23. data/lib/rubygame/event_hook.rb +6 -2
  24. data/lib/rubygame/event_triggers.rb +1 -1
  25. data/lib/rubygame/events.rb +416 -1
  26. data/lib/rubygame/ftor.rb +1 -7
  27. data/lib/rubygame/gfx.rb +583 -0
  28. data/lib/rubygame/gl.rb +107 -0
  29. data/lib/rubygame/image.rb +140 -0
  30. data/lib/rubygame/joystick.rb +184 -0
  31. data/lib/rubygame/main.rb +82 -0
  32. data/lib/rubygame/mediabag.rb +1 -1
  33. data/lib/rubygame/mixer.rb +30 -0
  34. data/lib/rubygame/music.rb +493 -0
  35. data/lib/rubygame/queue.rb +3 -1
  36. data/lib/rubygame/rect.rb +9 -9
  37. data/lib/rubygame/screen.rb +357 -0
  38. data/lib/rubygame/shared.rb +40 -4
  39. data/lib/rubygame/sound.rb +428 -0
  40. data/lib/rubygame/surface.rb +626 -0
  41. data/lib/rubygame/ttf.rb +311 -0
  42. data/samples/FreeSans.ttf +0 -0
  43. data/samples/README +6 -5
  44. data/samples/demo_draw.rb +1 -1
  45. data/samples/demo_gl.rb +3 -1
  46. data/samples/demo_gl_tex.rb +4 -2
  47. data/samples/demo_rubygame.rb +114 -105
  48. data/samples/demo_sfont.rb +1 -1
  49. data/samples/demo_ttf.rb +3 -1
  50. data/samples/demo_utf8.rb +1 -1
  51. data/samples/image_viewer.rb +118 -0
  52. data/samples/load_and_blit.rb +1 -1
  53. data/samples/rubygame.png +0 -0
  54. metadata +34 -40
  55. data/Rakefile +0 -537
  56. data/doc/extended_readme.rdoc +0 -49
  57. data/ext/body/rubygame_body.so +0 -0
  58. data/ext/rubygame/rubygame_clock.c +0 -301
  59. data/ext/rubygame/rubygame_clock.h +0 -32
  60. data/ext/rubygame/rubygame_event.c +0 -760
  61. data/ext/rubygame/rubygame_event.h +0 -48
  62. data/ext/rubygame/rubygame_event2.c +0 -661
  63. data/ext/rubygame/rubygame_event2.h +0 -29
  64. data/ext/rubygame/rubygame_gfx.c +0 -942
  65. data/ext/rubygame/rubygame_gfx.h +0 -101
  66. data/ext/rubygame/rubygame_gl.c +0 -154
  67. data/ext/rubygame/rubygame_gl.h +0 -32
  68. data/ext/rubygame/rubygame_image.c +0 -252
  69. data/ext/rubygame/rubygame_image.h +0 -41
  70. data/ext/rubygame/rubygame_joystick.c +0 -336
  71. data/ext/rubygame/rubygame_joystick.h +0 -41
  72. data/ext/rubygame/rubygame_main.c +0 -158
  73. data/ext/rubygame/rubygame_main.h +0 -36
  74. data/ext/rubygame/rubygame_mixer.c +0 -1024
  75. data/ext/rubygame/rubygame_mixer.h +0 -36
  76. data/ext/rubygame/rubygame_music.c +0 -1017
  77. data/ext/rubygame/rubygame_music.h +0 -29
  78. data/ext/rubygame/rubygame_screen.c +0 -572
  79. data/ext/rubygame/rubygame_screen.h +0 -45
  80. data/ext/rubygame/rubygame_shared.c +0 -269
  81. data/ext/rubygame/rubygame_shared.h +0 -69
  82. data/ext/rubygame/rubygame_sound.c +0 -863
  83. data/ext/rubygame/rubygame_sound.h +0 -29
  84. data/ext/rubygame/rubygame_surface.c +0 -1153
  85. data/ext/rubygame/rubygame_surface.h +0 -62
  86. data/ext/rubygame/rubygame_ttf.c +0 -599
  87. data/ext/rubygame/rubygame_ttf.h +0 -69
  88. data/samples/keys.rb +0 -52
@@ -1,49 +0,0 @@
1
- = Extended README
2
-
3
- (Stuff that didn't make it into the main README file.)
4
-
5
- == Internal structure of Rubygame
6
-
7
- Rubygame's core is a low-level extension written in C; it
8
- provides a basic interface to SDL and its companion libraries.
9
- Building upon that is a ruby library which implements high-level
10
- concepts like game objects, event management, etc.
11
-
12
- Rubygame is modular, meaning you can pick and choose which parts to use.
13
- For example, if you don't need TrueType font support, SDL_ttf is not
14
- required to compile Rubygame. It is possible for a game to detect at
15
- run-time which features are present, and behave accordingly (for example,
16
- the game might disable certain optional features).
17
-
18
- Rubygame is multi-tiered, meaning you can access Rubygame's functionality
19
- on a number of levels, each level being built on the level below it.
20
- Each higher level is closer to a complete game, but is also less flexible.
21
- The idea here is that developers will use the higher levels most of the
22
- time, but be free to hack lower levels when they need to do something
23
- special.
24
-
25
- == About the version number
26
-
27
- The version number of Rubygame has a strict meaning, to help you decide
28
- whether the new version might break your application. The version number has
29
- 3 parts: the major version number, the minor version number, and the patch
30
- number. For the example of Rubygame 2.0.0:
31
-
32
- 2 . 0 . 0
33
- MAJOR . MINOR . PATCH
34
-
35
- When a new release of Rubygame is made, one of the version numbers will
36
- go up, and the numbers that come after it will be reset to 0. Which number
37
- will go up depends on how much the Rubygame API changed:
38
-
39
- - *MAJOR*: API has changed, and old apps must be updated.
40
- An example of this is when a class has been significantly changed, or a
41
- method has renamed/moved to another module and the old name is removed.
42
-
43
- - *MINOR*: API has changed, but old apps will still work.
44
- An example of this is when a new feature has been added, or a
45
- method has been renamed but the old name is still supported.
46
-
47
- - *PATCH*: API has not changed at all.
48
- An example of this is when a bug has been fixed, or existing code has
49
- been improved beneath the surface.
Binary file
@@ -1,301 +0,0 @@
1
- /*
2
- * Functions for getting the time since initialization and delaying execution
3
- * for a specified amounts of time.
4
- *
5
- * --
6
- *
7
- * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
8
- * Copyright (C) 2004-2009 John Croisant
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public
21
- * License along with this library; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
- *
24
- * ++
25
- */
26
-
27
- #include "rubygame_shared.h"
28
- #include "rubygame_clock.h"
29
-
30
- void Rubygame_Init_Clock();
31
-
32
- VALUE cClock;
33
-
34
- VALUE rbgm_clock_wait(int, VALUE*, VALUE);
35
- VALUE rbgm_clock_delay(int, VALUE*, VALUE);
36
- VALUE rbgm_clock_runtime(VALUE);
37
-
38
-
39
- /* Initialize the SDL timer system, if it hasn't been already. */
40
- void rg_init_sdl_timer()
41
- {
42
- if(!SDL_WasInit(SDL_INIT_TIMER))
43
- {
44
- if(SDL_InitSubSystem(SDL_INIT_TIMER))
45
- {
46
- rb_raise(eSDLError,"Could not initialize timer system: %s",\
47
- SDL_GetError());
48
- }
49
- }
50
- }
51
-
52
-
53
- /* NOTICE: if you change this value "officially", don't forget to update the
54
- * documentation for rbgm_time_delay!!
55
- */
56
- #define WORST_CLOCK_ACCURACY 12
57
-
58
-
59
-
60
- /* Delays for the given amount of time, but possibly split into small
61
- * parts. Control is given to ruby between each part, so that other
62
- * threads can run.
63
- *
64
- * delay: How many milliseconds to delay.
65
- * nice: If 1 (true), split the delay into smaller parts and allow
66
- * other ruby threads to run between each part.
67
- *
68
- */
69
- Uint32 rg_threaded_delay( Uint32 delay, int nice )
70
- {
71
- Uint32 start;
72
-
73
- start = SDL_GetTicks();
74
-
75
- if( nice )
76
- {
77
- while( SDL_GetTicks() < start + delay )
78
- {
79
- SDL_Delay(1);
80
- rb_thread_schedule(); /* give control to ruby */
81
- }
82
- }
83
- else
84
- {
85
- SDL_Delay( delay );
86
- }
87
-
88
- return SDL_GetTicks() - start;
89
- }
90
-
91
-
92
- /*
93
- * call-seq:
94
- * Clock.wait( time, nice=false ) -> Integer
95
- *
96
- * time:: The target wait time, in milliseconds.
97
- * (Non-negative Integer. Required.)
98
- * nice:: If true, try to let other ruby threads run during the delay.
99
- * (true or false. Optional.)
100
- *
101
- * Returns:: The actual wait time, in milliseconds.
102
- *
103
- * Pause the program for approximately +time+ milliseconds. Both this
104
- * function and Clock.delay can be used to slow down the framerate so
105
- * that the application doesn't use too much CPU time. See also
106
- * Clock#tick for a good and easy way to limit the framerate.
107
- *
108
- * The accuracy of this function depends on processor scheduling,
109
- * which varies with operating system and hardware. The actual delay
110
- * time may be up to 10ms longer than +time+. If you need more
111
- * accuracy use Clock.delay, which is more accurate but uses slightly
112
- * more CPU time.
113
- *
114
- * If +nice+ is true, this function will try to allow other ruby
115
- * threads to run during this function. Otherwise, other ruby threads
116
- * will probably also be paused. Setting +nice+ to true is only
117
- * useful if your application is multithreaded. It's safe (but
118
- * pointless) to use this feature for single threaded applications.
119
- *
120
- * The Rubygame timer system will be initialized when you call this
121
- * function, if it has not been already. See Clock.runtime.
122
- *
123
- */
124
- VALUE rbgm_clock_wait(int argc, VALUE *argv, VALUE module)
125
- {
126
- rg_init_sdl_timer();
127
-
128
- VALUE vtime, vnice;
129
-
130
- rb_scan_args(argc,argv,"11", &vtime, &vnice);
131
-
132
- int delay = NUM2INT(vtime);
133
- if( delay < 0 )
134
- {
135
- delay = 0;
136
- }
137
-
138
- int nice = (vnice == Qtrue) ? 1 : 0;
139
-
140
- return UINT2NUM( rg_threaded_delay(delay, nice) );
141
- }
142
-
143
-
144
-
145
- /*--
146
- * From pygame code, with a few modifications:
147
- * - takes 'accuracy' argument
148
- * - ruby syntax for raising exceptions
149
- * - uses rg_threaded_delay
150
- *++
151
- */
152
- static Uint32 accurate_delay(Uint32 ticks, Uint32 accuracy, int nice)
153
- {
154
- Uint32 funcstart;
155
- int delay;
156
-
157
- if( accuracy <= 0 )
158
- {
159
- /* delay with no accuracy is like wait (no busy waiting) */
160
- return rg_threaded_delay(ticks, nice);
161
- }
162
-
163
- funcstart = SDL_GetTicks();
164
-
165
- if(ticks >= accuracy)
166
- {
167
- delay = ticks - (ticks % accuracy);
168
- delay -= 2; /* Aim low so we don't overshoot. */
169
-
170
- if(delay >= accuracy && delay > 0)
171
- {
172
- rg_threaded_delay(delay, nice);
173
- }
174
- }
175
-
176
- do{
177
- delay = ticks - (SDL_GetTicks() - funcstart);
178
-
179
- if( nice == 1 )
180
- {
181
- rb_thread_schedule(); /* give control to ruby */
182
- }
183
- }while(delay > 0);
184
-
185
- return SDL_GetTicks() - funcstart;
186
- }
187
-
188
-
189
-
190
- /*
191
- * call-seq:
192
- * Clock.delay( time, gran=12, nice=false ) -> Integer
193
- *
194
- * time:: The target delay time, in milliseconds.
195
- * (Non-negative integer. Required.)
196
- * gran:: The assumed granularity (in ms) of the system clock.
197
- * (Non-negative integer. Optional. Default: 12.)
198
- * nice:: If true, try to let other ruby threads run during the delay.
199
- * (true or false. Optional. Default: false.)
200
- *
201
- * Returns:: The actual delay time, in milliseconds.
202
- *
203
- * Pause the program for +time+ milliseconds. This function is more
204
- * accurate than Clock.wait, but uses slightly more CPU time. Both
205
- * this function and Clock.wait can be used to slow down the
206
- * framerate so that the application doesn't use too much CPU time.
207
- * See also Clock#tick for a good and easy way to limit the
208
- * framerate.
209
- *
210
- * This function uses "busy waiting" during the last part
211
- * of the delay, for increased accuracy. The value of +gran+ affects
212
- * how many milliseconds of the delay are spent in busy waiting, and thus
213
- * how much CPU it uses. A smaller +gran+ value uses less CPU, but if
214
- * it's smaller than the true system granularity, this function may
215
- * delay a few milliseconds too long. The default value (12ms) is very
216
- * safe, but a value of approximately 5ms would give a better balance
217
- * between accuracy and CPU usage on most modern computers.
218
- * A granularity of 0ms makes this method act the same as Clock.wait
219
- * (i.e. no busy waiting at all, very low CPU usage).
220
- *
221
- * If +nice+ is true, this function will try to allow other ruby
222
- * threads to run during this function. Otherwise, other ruby threads
223
- * will probably also be paused. Setting +nice+ to true is only
224
- * useful if your application is multithreaded. It's safe (but
225
- * pointless) to use this feature for single threaded applications.
226
- *
227
- * The Rubygame timer system will be initialized when you call this
228
- * function, if it has not been already. See Clock.runtime.
229
- *
230
- */
231
- VALUE rbgm_clock_delay(int argc, VALUE *argv, VALUE module)
232
- {
233
- rg_init_sdl_timer();
234
-
235
- VALUE vtime, vgran, vnice;
236
-
237
- rb_scan_args(argc,argv,"12", &vtime, &vgran, &vnice);
238
-
239
- int delay = NUM2INT(vtime);
240
- if( delay < 0 )
241
- {
242
- delay = 0;
243
- }
244
-
245
- int gran;
246
- if( RTEST(vgran) )
247
- {
248
- gran = NUM2UINT(vgran);
249
- if( gran < 0 )
250
- {
251
- gran = 0;
252
- }
253
- }
254
- else
255
- {
256
- gran = WORST_CLOCK_ACCURACY;
257
- }
258
-
259
- int nice = (vnice == Qtrue) ? 1 : 0;
260
-
261
- return UINT2NUM( accurate_delay(delay, gran, nice) );
262
- }
263
-
264
-
265
-
266
- /*
267
- * call-seq:
268
- * runtime -> Integer
269
- *
270
- * Return the number of milliseconds since the Rubygame timer system
271
- * was initialized.
272
- *
273
- * The Rubygame timer system will be initialized when you call this function,
274
- * if it has not been already.
275
- */
276
- VALUE rbgm_clock_runtime( VALUE module )
277
- {
278
- rg_init_sdl_timer();
279
-
280
- return UINT2NUM(SDL_GetTicks());
281
- }
282
-
283
-
284
-
285
- void Rubygame_Init_Clock()
286
- {
287
- #if 0
288
- mRubygame = rb_define_module("Rubygame");
289
- #endif
290
-
291
- /* Clock class */
292
- cClock = rb_define_class_under(mRubygame, "Clock", rb_cObject);
293
-
294
- /* Clock class methods */
295
- rb_define_singleton_method(cClock, "wait", rbgm_clock_wait, -1);
296
- rb_define_singleton_method(cClock, "delay", rbgm_clock_delay, -1);
297
- rb_define_singleton_method(cClock, "runtime",rbgm_clock_runtime, 0);
298
-
299
- /* Clock instance methods are defined in clock.rb. */
300
-
301
- }
@@ -1,32 +0,0 @@
1
- /*
2
- * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
- * Copyright (C) 2004-2009 John Croisant
4
- *
5
- * This library is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU Lesser General Public
7
- * License as published by the Free Software Foundation; either
8
- * version 2.1 of the License, or (at your option) any later version.
9
- *
10
- * This library is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * Lesser General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
- *
19
- */
20
-
21
- #ifndef _RUBYGAME_CLOCK_H
22
- #define _RUBYGAME_CLOCK_H
23
-
24
- extern void Rubygame_Init_Clock();
25
-
26
- extern VALUE cClock;
27
-
28
- extern VALUE rbgm_clock_wait(int, VALUE*, VALUE);
29
- extern VALUE rbgm_clock_delay(int, VALUE*, VALUE);
30
- extern VALUE rbgm_clock_runtime(VALUE);
31
-
32
- #endif
@@ -1,760 +0,0 @@
1
- /*--
2
- * Rubygame -- Ruby bindings to SDL to facilitate game creation
3
- * Copyright (C) 2004-2007 John Croisant
4
- *
5
- * This library is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU Lesser General Public
7
- * License as published by the Free Software Foundation; either
8
- * version 2.1 of the License, or (at your option) any later version.
9
- *
10
- * This library is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * Lesser General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
- *++
19
- */
20
-
21
- #include "rubygame_shared.h"
22
- #include "rubygame_event.h"
23
-
24
- void Rubygame_Init_Event();
25
-
26
- VALUE cEvent;
27
- VALUE cActiveEvent;
28
- VALUE cKeyDownEvent;
29
- VALUE cKeyUpEvent;
30
- VALUE cMouseMotionEvent;
31
- VALUE cMouseDownEvent;
32
- VALUE cMouseUpEvent;
33
- VALUE cJoyAxisEvent;
34
- VALUE cJoyBallEvent;
35
- VALUE cJoyHatEvent;
36
- VALUE cJoyDownEvent;
37
- VALUE cJoyUpEvent;
38
- VALUE cQuitEvent;
39
- VALUE cSysWMEvent;
40
- VALUE cResizeEvent;
41
- VALUE cExposeEvent;
42
- VALUE convert_active(Uint8);
43
- VALUE convert_keymod(SDLMod);
44
- VALUE convert_mousebuttons(Uint8);
45
- VALUE rbgm_convert_sdlevent(SDL_Event);
46
- VALUE rbgm_queue_getsdl(VALUE);
47
-
48
- /*
49
- *--
50
- *
51
- * SDL Type Ruby type Ruby new() args
52
- * ---------------------------------------------------------------------------
53
- * SDL_ACTIVEEVENT ActiveEvent gain,state
54
- * SDL_KEYDOWN KeyDownEvent key,[mods,...]
55
- * SDL_KEYUP KeyUpEvent key,[mods,...]
56
- * SDL_MOUSEMOTION MouseMotionEvent [x,y],[xrel,yrel],[buttons,...]
57
- * SDL_MOUSEBUTTONDOWN MouseDownEvent [x,y],button
58
- * SDL_MOUSEBUTTONUP MouseUpEvent [x,y],button
59
- * SDL_JOYAXISMOTION JoyAxisEvent joy,axis,value
60
- * SDL_JOYBALLMOTION JoyBallEvent joy,ball,[xrel,yrel]
61
- * SDL_JOYHATMOTION JoyHatEvent joy,hat,value
62
- * SDL_JOYBUTTONDOWN JoyDownEvent joy,button
63
- * SDL_JOYBUTTONUP JoyUpEvent joy,button
64
- * SDL_VIDEORESIZE VideoResizeEvent [w,h]
65
- * SDL_QUIT QuitEvent (no args)
66
- * --------------------------------------------------------------------------
67
- *
68
- *++
69
- */
70
-
71
- /* Convert info about whether the window has mouse/keyboard focus */
72
- VALUE convert_active( Uint8 state )
73
- {
74
- VALUE array;
75
-
76
- array = rb_ary_new();
77
- if(state != 0)
78
- {
79
- if(state & SDL_APPMOUSEFOCUS)
80
- rb_ary_push(array,rb_str_new2("mouse\0"));
81
- if(state & SDL_APPINPUTFOCUS)
82
- rb_ary_push(array,rb_str_new2("keyboard\0"));
83
- if(state & SDL_APPACTIVE)
84
- rb_ary_push(array,rb_str_new2("active\0"));
85
- }
86
- return array;
87
- }
88
-
89
- /* Convert an OR'd list of KMODs into a Ruby array of keysyms. */
90
- VALUE convert_keymod( SDLMod mods )
91
- {
92
- VALUE array;
93
-
94
- array = rb_ary_new();
95
- if(mods != 0)
96
- {
97
- /* KEY MODIFIER KEY SYM */
98
- if(mods & KMOD_LSHIFT) rb_ary_push(array,INT2NUM( SDLK_LSHIFT ));
99
- if(mods & KMOD_RSHIFT) rb_ary_push(array,INT2NUM( SDLK_RSHIFT ));
100
- if(mods & KMOD_LCTRL) rb_ary_push(array,INT2NUM( SDLK_LCTRL ));
101
- if(mods & KMOD_RCTRL) rb_ary_push(array,INT2NUM( SDLK_RCTRL ));
102
- if(mods & KMOD_LALT) rb_ary_push(array,INT2NUM( SDLK_LALT ));
103
- if(mods & KMOD_RALT) rb_ary_push(array,INT2NUM( SDLK_RALT ));
104
- if(mods & KMOD_LMETA) rb_ary_push(array,INT2NUM( SDLK_LMETA ));
105
- if(mods & KMOD_RMETA) rb_ary_push(array,INT2NUM( SDLK_RMETA ));
106
- if(mods & KMOD_NUM) rb_ary_push(array,INT2NUM( SDLK_NUMLOCK ));
107
- if(mods & KMOD_CAPS) rb_ary_push(array,INT2NUM( SDLK_CAPSLOCK ));
108
- if(mods & KMOD_MODE) rb_ary_push(array,INT2NUM( SDLK_MODE ));
109
- }
110
- return array;
111
- }
112
-
113
- /* convert a button state into a list of mouse button sym */
114
- VALUE convert_mousebuttons( Uint8 state )
115
- {
116
- VALUE buttons;
117
-
118
- buttons = rb_ary_new();
119
- if(state & SDL_BUTTON(1))
120
- rb_ary_push(buttons, INT2NUM(SDL_BUTTON_LEFT));
121
- if(state & SDL_BUTTON(2))
122
- rb_ary_push(buttons, INT2NUM(SDL_BUTTON_MIDDLE));
123
- if(state & SDL_BUTTON(3))
124
- rb_ary_push(buttons, INT2NUM(SDL_BUTTON_RIGHT));
125
- return buttons;
126
- }
127
-
128
-
129
- #if 0
130
- /*
131
- * (This method is no longer used, as it depends on unicode enabled in SDL,
132
- * and doesn't work for KeyUpEvents)
133
- */
134
- /* Convert a unicode char into an ascii string or hex if it is not ascii */
135
- VALUE convert_unicode( Uint16 unicode )
136
- {
137
- char *str;
138
- if( unicode < 0x80 && unicode > 0 )
139
- asprintf( &str,"%c\0",(char)unicode );
140
- else
141
- asprintf( &str,"0x%04X\0",unicode );
142
- return rb_str_new2(str);
143
- }
144
- #endif
145
-
146
-
147
- /*--
148
- *
149
- * Queue-related functions.
150
- *
151
- *++
152
- */
153
-
154
- /*--
155
- *
156
- * call-seq:
157
- * rbgm_convert_sdlevent( SDL_Event ) -> Rubygame_Event
158
- *
159
- * Converts an SDL_Event (C type) into a Rubygame Event of the corresponding
160
- * class.
161
- *
162
- *++
163
- */
164
-
165
- VALUE rbgm_convert_sdlevent( SDL_Event ev )
166
- {
167
- VALUE new = rb_intern("new"); /* to call new() for any class */
168
-
169
- /*
170
- switch for each particular type, call new() for the corresponding
171
- Rubygame class, with the proper arguments.
172
- */
173
- switch(ev.type)
174
- {
175
- case SDL_ACTIVEEVENT:
176
- /* ActiveEvent.new(gain,state) */
177
- return rb_funcall(cActiveEvent,new,2,\
178
- ev.active.gain, convert_active(ev.active.state));
179
- break;
180
- case SDL_KEYDOWN:
181
- /* KeyDownEvent.new(keysym,[mods,...]) */
182
- return rb_funcall(cKeyDownEvent,new,2,\
183
- /* keysym, string version is set in new()*/
184
- INT2NUM(ev.key.keysym.sym),\
185
- /* convert OR'd list of mods into Array of keysyms */
186
- convert_keymod(ev.key.keysym.mod)\
187
- );
188
- break;
189
- case SDL_KEYUP: /* Same as SDL_KEYDOWN */
190
- /* KeyUpEvent.new(keysym,[mods,...]) */
191
- return rb_funcall(cKeyUpEvent,new,2,\
192
- INT2NUM(ev.key.keysym.sym),\
193
- convert_keymod(ev.key.keysym.mod));
194
- break;
195
- case SDL_MOUSEMOTION:;
196
-
197
- /* MouseMotionEvent.new([x,y],[xrel,yrel],[buttons,...]) */
198
- return rb_funcall(cMouseMotionEvent,new,3,\
199
- rb_ary_new3(2,INT2NUM(ev.motion.x),INT2NUM(ev.motion.y)),\
200
- rb_ary_new3(2,INT2NUM(ev.motion.xrel),\
201
- INT2NUM(ev.motion.yrel)),\
202
- /* Prepare list of buttons from OR'd list */
203
- convert_mousebuttons(ev.motion.state));
204
- break;
205
- case SDL_MOUSEBUTTONDOWN:
206
- /* MouseDownEvent.new([x,y],button) */
207
- return rb_funcall(cMouseDownEvent,new,2,\
208
- rb_ary_new3(2,INT2NUM(ev.button.x),INT2NUM(ev.button.y)),\
209
- INT2NUM(ev.button.button));
210
- break;
211
- case SDL_MOUSEBUTTONUP:
212
- /* MouseUpEvent.new([x,y],button) */
213
- return rb_funcall(cMouseUpEvent,new,2,\
214
- rb_ary_new3(2,INT2NUM(ev.button.x),INT2NUM(ev.button.y)),\
215
- INT2NUM(ev.button.button));
216
- break;
217
- case SDL_JOYAXISMOTION:
218
- /* JoyAxisEvent.new(joy,axis,value) */
219
- /* Eventually, joy might be a reference to a Joystick instance? */
220
- return rb_funcall(cJoyAxisEvent,new,3,\
221
- INT2NUM(ev.jaxis.which),INT2NUM(ev.jaxis.axis),\
222
- INT2NUM(ev.jaxis.value));
223
- break;
224
- case SDL_JOYBALLMOTION:
225
- /* JoyBallEvent.new(joy,ball,) */
226
- /* Eventually, joy might be a reference to a Joystick instance? */
227
- return rb_funcall(cJoyBallEvent,new,3,\
228
- INT2NUM(ev.jball.which),INT2NUM(ev.jball.ball),
229
- rb_ary_new3(2,INT2NUM(ev.jball.xrel),INT2NUM(ev.jball.yrel)));
230
- break;
231
- case SDL_JOYHATMOTION:
232
- /* JoyHatEvent.new(joy,hat,value) */
233
- /* Eventually, joy might be a reference to a Joystick instance? */
234
- return rb_funcall(cJoyHatEvent,new,3,\
235
- INT2NUM(ev.jhat.which),INT2NUM(ev.jhat.hat),\
236
- INT2NUM(ev.jhat.value));
237
- break;
238
- case SDL_JOYBUTTONDOWN:
239
- /* JoyDownEvent.new(joy,button) */
240
- /* Eventually, joy might be a reference to a Joystick instance? */
241
- return rb_funcall(cJoyDownEvent,new,2,\
242
- INT2NUM(ev.jbutton.which),INT2NUM(ev.jbutton.button));
243
- break;
244
- case SDL_JOYBUTTONUP:
245
- /* JoyUp.new(joy,button) */
246
- /* Eventually, joy might be a reference to a Joystick instance? */
247
- return rb_funcall(cJoyUpEvent,new,2,\
248
- INT2NUM(ev.jbutton.which),INT2NUM(ev.jbutton.button));
249
- break;
250
- case SDL_VIDEORESIZE:
251
- /* ResizeEvent.new([w,h]) */
252
- return rb_funcall(cResizeEvent,new,1,\
253
- rb_ary_new3(2,INT2NUM(ev.resize.w),INT2NUM(ev.resize.h)));
254
- break;
255
- case SDL_VIDEOEXPOSE:
256
- /* ExposeEvent.new( ) */
257
- return rb_funcall(cExposeEvent,new,0);
258
- break;
259
- case SDL_QUIT:
260
- /* QuitEvent.new( ) */
261
- return rb_funcall(cQuitEvent,new,0);
262
- break;
263
- default:
264
- rb_warn("Cannot convert unknown event type (%d).", ev.type);
265
- return Qnil;
266
- break;
267
- }
268
- return Qnil; /* should never get here */
269
- }
270
-
271
- /*
272
- * call-seq:
273
- * fetch_sdl_events -> [Event, ...]
274
- *
275
- * Retrieves all pending events from SDL's event stack and converts them
276
- * into Rubygame Event objects. Returns an Array of all the events, in
277
- * the order they were read.
278
- *
279
- * This method is used by the EventQueue class, so don't call it if you are
280
- * using EventQueue for event management! If you do, the EventQueue will not
281
- * receive all the events, because they will have been removed from SDL's
282
- * event stack by this method.
283
- *
284
- * However, if you aren't using EventQueue, you can safely use this method
285
- * to make your own event management system.
286
- */
287
- VALUE rbgm_fetchevents(VALUE self)
288
- {
289
- SDL_Event event;
290
- VALUE event_array;
291
-
292
- event_array = rb_ary_new();
293
- /* put each in *event until no pending events are in SDL's queue */
294
- /* for now, we don't care what type the event in. Filtering comes later */
295
- while(SDL_PollEvent(&event)==1)
296
- {
297
- rb_ary_push(event_array, rbgm_convert_sdlevent(event) );
298
- }
299
- return event_array;
300
- }
301
-
302
-
303
-
304
- /* Convert an argument to #enable_key_repeat into an integer
305
- * number of milliseconds.
306
- *
307
- * Argument must be nil, :default, or a numeric greater than 0.001.
308
- */
309
- int rg_get_keyrepeat_value( VALUE vvalue, int default_value, char *name )
310
- {
311
-
312
- int value;
313
-
314
- if( NIL_P(vvalue) )
315
- {
316
- return default_value;
317
- }
318
-
319
- switch( TYPE(vvalue) ){
320
- case T_SYMBOL: {
321
- if( make_symbol("default") == vvalue )
322
- {
323
- return default_value;
324
- }
325
- else
326
- {
327
- rb_raise( rb_eArgError, "unsupported symbol '%s' for %s",
328
- RSTRING_PTR(rb_inspect(vvalue)), name );
329
- }
330
- }
331
-
332
- default: {
333
- int value = NUM2INT(vvalue) * 1000; /* seconds -> milleseconds */
334
-
335
- if( value < 1 )
336
- {
337
- rb_raise( rb_eArgError, "%s must be at least 0.001 seconds (got %s)",
338
- name, RSTRING_PTR(rb_inspect(vvalue)));
339
- }
340
-
341
- return value;
342
- }
343
- }
344
- }
345
-
346
-
347
-
348
- /*
349
- * call-seq:
350
- * enable_key_repeat( delay=:default, interval=:default )
351
- *
352
- * Enable key repeat, so that additional keyboard release and press
353
- * events are automatically generated for as long as the key is held
354
- * down. See also #disable_key_repeat.
355
- *
356
- * delay:: how many seconds to wait before starting to repeat.
357
- * Default is 0.5 seconds. (Numeric or :default, optional)
358
- *
359
- * interval:: how many seconds to wait in between repetitions after
360
- * the first one. Default is 0.03 seconds.
361
- * (Numeric or :default, optional)
362
- *
363
- */
364
- VALUE rg_enable_key_repeat(int argc, VALUE *argv, VALUE module)
365
- {
366
-
367
- VALUE vdelay, vinterval;
368
- rb_scan_args(argc, argv, "02", &vdelay, &vinterval);
369
-
370
-
371
- int delay = rg_get_keyrepeat_value( vdelay,
372
- SDL_DEFAULT_REPEAT_DELAY,
373
- "delay" );
374
-
375
- int interval = rg_get_keyrepeat_value( vinterval,
376
- SDL_DEFAULT_REPEAT_INTERVAL,
377
- "interval" );
378
-
379
-
380
- int result = SDL_EnableKeyRepeat( delay, interval );
381
-
382
- if (result != 0) {
383
- rb_raise(eSDLError, "Could not enable key repeat: %s",
384
- SDL_GetError());
385
- }
386
-
387
- return Qnil;
388
- }
389
-
390
-
391
-
392
- /*
393
- * call-seq:
394
- * disable_key_repeat
395
- *
396
- * Disable key repeat, undoing the effect of #enable_key_repeat.
397
- *
398
- */
399
- VALUE rg_disable_key_repeat(VALUE module)
400
- {
401
- int result = SDL_EnableKeyRepeat( 0, 0 );
402
-
403
- if (result != 0) {
404
- rb_raise(eSDLError, "Could not disable key repeat: %s",
405
- SDL_GetError());
406
- }
407
-
408
- return Qnil;
409
- }
410
-
411
-
412
-
413
- /*
414
- *--
415
- * The event documentation is in rubygame/lib/rubygame/event.rb
416
- *++
417
- */
418
- void Rubygame_Init_Event()
419
- {
420
- #if 0
421
- mRubygame = rb_define_module("Rubygame");
422
- #endif
423
-
424
- rb_define_singleton_method(mRubygame, "fetch_sdl_events",rbgm_fetchevents,0);
425
- rb_define_singleton_method(mRubygame, "enable_key_repeat",
426
- rg_enable_key_repeat, -1);
427
- rb_define_singleton_method(mRubygame, "disable_key_repeat",
428
- rg_disable_key_repeat, 0);
429
-
430
- cEvent = rb_define_class_under(mRubygame,"Event",rb_cObject);
431
- cActiveEvent = rb_define_class_under(mRubygame,"ActiveEvent",cEvent);
432
- cKeyDownEvent = rb_define_class_under(mRubygame,"KeyDownEvent",cEvent);
433
- cKeyUpEvent = rb_define_class_under(mRubygame,"KeyUpEvent",cEvent);
434
- cMouseMotionEvent = rb_define_class_under(mRubygame,"MouseMotionEvent",\
435
- cEvent);
436
- cMouseDownEvent = rb_define_class_under(mRubygame,"MouseDownEvent",cEvent);
437
- cMouseUpEvent = rb_define_class_under(mRubygame,"MouseUpEvent",cEvent);
438
- cJoyAxisEvent = rb_define_class_under(mRubygame,"JoyAxisEvent",cEvent);
439
- cJoyBallEvent = rb_define_class_under(mRubygame,"JoyBallEvent",cEvent);
440
- cJoyHatEvent = rb_define_class_under(mRubygame,"JoyHatEvent",cEvent);
441
- cJoyDownEvent = rb_define_class_under(mRubygame,"JoyDownEvent",cEvent);
442
- cJoyUpEvent = rb_define_class_under(mRubygame,"JoyUpEvent",cEvent);
443
- cQuitEvent = rb_define_class_under(mRubygame,"QuitEvent",cEvent);
444
- cResizeEvent = rb_define_class_under(mRubygame,"ResizeEvent",cEvent);
445
- cExposeEvent = rb_define_class_under(mRubygame,"ExposeEvent",cEvent);
446
-
447
- /* Event constants */
448
- rb_define_const(mRubygame,"NOEVENT",UINT2NUM(SDL_NOEVENT));
449
- rb_define_const(mRubygame,"ACTIVEEVENT",UINT2NUM(SDL_ACTIVEEVENT));
450
- rb_define_const(mRubygame,"KEYDOWN",UINT2NUM(SDL_KEYDOWN));
451
- rb_define_const(mRubygame,"KEYUP",UINT2NUM(SDL_KEYUP));
452
- rb_define_const(mRubygame,"MOUSEMOTION",UINT2NUM(SDL_MOUSEMOTION));
453
- rb_define_const(mRubygame,"MOUSEBUTTONDOWN",UINT2NUM(SDL_MOUSEBUTTONDOWN));
454
- rb_define_const(mRubygame,"MOUSEBUTTONUP",UINT2NUM(SDL_MOUSEBUTTONUP));
455
- rb_define_const(mRubygame,"JOYAXISMOTION",UINT2NUM(SDL_JOYAXISMOTION));
456
- rb_define_const(mRubygame,"JOYBALLMOTION",UINT2NUM(SDL_JOYBALLMOTION));
457
- rb_define_const(mRubygame,"JOYHATMOTION",UINT2NUM(SDL_JOYHATMOTION));
458
- rb_define_const(mRubygame,"JOYBUTTONDOWN",UINT2NUM(SDL_JOYBUTTONDOWN));
459
- rb_define_const(mRubygame,"JOYBUTTONUP",UINT2NUM(SDL_JOYBUTTONUP));
460
- rb_define_const(mRubygame,"QUIT",UINT2NUM(SDL_QUIT));
461
- rb_define_const(mRubygame,"SYSWMEVENT",UINT2NUM(SDL_SYSWMEVENT));
462
- rb_define_const(mRubygame,"VIDEORESIZE",UINT2NUM(SDL_VIDEORESIZE));
463
- rb_define_const(mRubygame,"VIDEOEXPOSE",UINT2NUM(SDL_VIDEOEXPOSE));
464
- rb_define_const(mRubygame,"USEREVENT",UINT2NUM(SDL_USEREVENT));
465
-
466
- /* Joystick constants */
467
- rb_define_const(mRubygame,"HAT_CENTERED",UINT2NUM(SDL_HAT_CENTERED));
468
- rb_define_const(mRubygame,"HAT_UP",UINT2NUM(SDL_HAT_UP));
469
- rb_define_const(mRubygame,"HAT_RIGHT",UINT2NUM(SDL_HAT_RIGHT));
470
- rb_define_const(mRubygame,"HAT_DOWN",UINT2NUM(SDL_HAT_DOWN));
471
- rb_define_const(mRubygame,"HAT_LEFT",UINT2NUM(SDL_HAT_LEFT));
472
- rb_define_const(mRubygame,"HAT_RIGHTUP",UINT2NUM(SDL_HAT_RIGHTUP));
473
- rb_define_const(mRubygame,"HAT_RIGHTDOWN",UINT2NUM(SDL_HAT_RIGHTDOWN));
474
- rb_define_const(mRubygame,"HAT_LEFTUP",UINT2NUM(SDL_HAT_LEFTUP));
475
- rb_define_const(mRubygame,"HAT_LEFTDOWN",UINT2NUM(SDL_HAT_LEFTDOWN));
476
-
477
-
478
- /* Mouse constants */
479
- rb_define_const(mRubygame,"MOUSE_LEFT",UINT2NUM(SDL_BUTTON_LEFT));
480
- rb_define_const(mRubygame,"MOUSE_MIDDLE",UINT2NUM(SDL_BUTTON_MIDDLE));
481
- rb_define_const(mRubygame,"MOUSE_RIGHT",UINT2NUM(SDL_BUTTON_RIGHT));
482
- rb_define_const(mRubygame,"MOUSE_LMASK",UINT2NUM(SDL_BUTTON_LMASK));
483
- rb_define_const(mRubygame,"MOUSE_MMASK",UINT2NUM(SDL_BUTTON_MMASK));
484
- rb_define_const(mRubygame,"MOUSE_RMASK",UINT2NUM(SDL_BUTTON_RMASK));
485
-
486
- /* ASCII key symbols */
487
- rb_define_const(mRubygame,"K_UNKNOWN",UINT2NUM(SDLK_UNKNOWN));
488
- rb_define_const(mRubygame,"K_FIRST",UINT2NUM(SDLK_FIRST));
489
- rb_define_const(mRubygame,"K_BACKSPACE",UINT2NUM(SDLK_BACKSPACE));
490
- rb_define_const(mRubygame,"K_TAB",UINT2NUM(SDLK_TAB));
491
- rb_define_const(mRubygame,"K_CLEAR",UINT2NUM(SDLK_CLEAR));
492
- rb_define_const(mRubygame,"K_RETURN",UINT2NUM(SDLK_RETURN));
493
- rb_define_const(mRubygame,"K_PAUSE",UINT2NUM(SDLK_PAUSE));
494
- rb_define_const(mRubygame,"K_ESCAPE",UINT2NUM(SDLK_ESCAPE));
495
- rb_define_const(mRubygame,"K_SPACE",UINT2NUM(SDLK_SPACE));
496
- rb_define_const(mRubygame,"K_EXCLAIM",UINT2NUM(SDLK_EXCLAIM));
497
- rb_define_const(mRubygame,"K_QUOTEDBL",UINT2NUM(SDLK_QUOTEDBL));
498
- rb_define_const(mRubygame,"K_HASH",UINT2NUM(SDLK_HASH));
499
- rb_define_const(mRubygame,"K_DOLLAR",UINT2NUM(SDLK_DOLLAR));
500
- rb_define_const(mRubygame,"K_AMPERSAND",UINT2NUM(SDLK_AMPERSAND));
501
- rb_define_const(mRubygame,"K_QUOTE",UINT2NUM(SDLK_QUOTE));
502
- rb_define_const(mRubygame,"K_LEFTPAREN",UINT2NUM(SDLK_LEFTPAREN));
503
- rb_define_const(mRubygame,"K_RIGHTPAREN",UINT2NUM(SDLK_RIGHTPAREN));
504
- rb_define_const(mRubygame,"K_ASTERISK",UINT2NUM(SDLK_ASTERISK));
505
- rb_define_const(mRubygame,"K_PLUS",UINT2NUM(SDLK_PLUS));
506
- rb_define_const(mRubygame,"K_COMMA",UINT2NUM(SDLK_COMMA));
507
- rb_define_const(mRubygame,"K_MINUS",UINT2NUM(SDLK_MINUS));
508
- rb_define_const(mRubygame,"K_PERIOD",UINT2NUM(SDLK_PERIOD));
509
- rb_define_const(mRubygame,"K_SLASH",UINT2NUM(SDLK_SLASH));
510
- rb_define_const(mRubygame,"K_0",UINT2NUM(SDLK_0));
511
- rb_define_const(mRubygame,"K_1",UINT2NUM(SDLK_1));
512
- rb_define_const(mRubygame,"K_2",UINT2NUM(SDLK_2));
513
- rb_define_const(mRubygame,"K_3",UINT2NUM(SDLK_3));
514
- rb_define_const(mRubygame,"K_4",UINT2NUM(SDLK_4));
515
- rb_define_const(mRubygame,"K_5",UINT2NUM(SDLK_5));
516
- rb_define_const(mRubygame,"K_6",UINT2NUM(SDLK_6));
517
- rb_define_const(mRubygame,"K_7",UINT2NUM(SDLK_7));
518
- rb_define_const(mRubygame,"K_8",UINT2NUM(SDLK_8));
519
- rb_define_const(mRubygame,"K_9",UINT2NUM(SDLK_9));
520
- rb_define_const(mRubygame,"K_COLON",UINT2NUM(SDLK_COLON));
521
- rb_define_const(mRubygame,"K_SEMICOLON",UINT2NUM(SDLK_SEMICOLON));
522
- rb_define_const(mRubygame,"K_LESS",UINT2NUM(SDLK_LESS));
523
- rb_define_const(mRubygame,"K_EQUALS",UINT2NUM(SDLK_EQUALS));
524
- rb_define_const(mRubygame,"K_GREATER",UINT2NUM(SDLK_GREATER));
525
- rb_define_const(mRubygame,"K_QUESTION",UINT2NUM(SDLK_QUESTION));
526
- rb_define_const(mRubygame,"K_AT",UINT2NUM(SDLK_AT));
527
- rb_define_const(mRubygame,"K_LEFTBRACKET",UINT2NUM(SDLK_LEFTBRACKET));
528
- rb_define_const(mRubygame,"K_BACKSLASH",UINT2NUM(SDLK_BACKSLASH));
529
- rb_define_const(mRubygame,"K_RIGHTBRACKET",UINT2NUM(SDLK_RIGHTBRACKET));
530
- rb_define_const(mRubygame,"K_CARET",UINT2NUM(SDLK_CARET));
531
- rb_define_const(mRubygame,"K_UNDERSCORE",UINT2NUM(SDLK_UNDERSCORE));
532
- rb_define_const(mRubygame,"K_BACKQUOTE",UINT2NUM(SDLK_BACKQUOTE));
533
- rb_define_const(mRubygame,"K_A",UINT2NUM(SDLK_a));
534
- rb_define_const(mRubygame,"K_B",UINT2NUM(SDLK_b));
535
- rb_define_const(mRubygame,"K_C",UINT2NUM(SDLK_c));
536
- rb_define_const(mRubygame,"K_D",UINT2NUM(SDLK_d));
537
- rb_define_const(mRubygame,"K_E",UINT2NUM(SDLK_e));
538
- rb_define_const(mRubygame,"K_F",UINT2NUM(SDLK_f));
539
- rb_define_const(mRubygame,"K_G",UINT2NUM(SDLK_g));
540
- rb_define_const(mRubygame,"K_H",UINT2NUM(SDLK_h));
541
- rb_define_const(mRubygame,"K_I",UINT2NUM(SDLK_i));
542
- rb_define_const(mRubygame,"K_J",UINT2NUM(SDLK_j));
543
- rb_define_const(mRubygame,"K_K",UINT2NUM(SDLK_k));
544
- rb_define_const(mRubygame,"K_L",UINT2NUM(SDLK_l));
545
- rb_define_const(mRubygame,"K_M",UINT2NUM(SDLK_m));
546
- rb_define_const(mRubygame,"K_N",UINT2NUM(SDLK_n));
547
- rb_define_const(mRubygame,"K_O",UINT2NUM(SDLK_o));
548
- rb_define_const(mRubygame,"K_P",UINT2NUM(SDLK_p));
549
- rb_define_const(mRubygame,"K_Q",UINT2NUM(SDLK_q));
550
- rb_define_const(mRubygame,"K_R",UINT2NUM(SDLK_r));
551
- rb_define_const(mRubygame,"K_S",UINT2NUM(SDLK_s));
552
- rb_define_const(mRubygame,"K_T",UINT2NUM(SDLK_t));
553
- rb_define_const(mRubygame,"K_U",UINT2NUM(SDLK_u));
554
- rb_define_const(mRubygame,"K_V",UINT2NUM(SDLK_v));
555
- rb_define_const(mRubygame,"K_W",UINT2NUM(SDLK_w));
556
- rb_define_const(mRubygame,"K_X",UINT2NUM(SDLK_x));
557
- rb_define_const(mRubygame,"K_Y",UINT2NUM(SDLK_y));
558
- rb_define_const(mRubygame,"K_Z",UINT2NUM(SDLK_z));
559
- rb_define_const(mRubygame,"K_DELETE",UINT2NUM(SDLK_DELETE));
560
-
561
-
562
- /* International keyboard symbols */
563
- rb_define_const(mRubygame,"K_WORLD_0",UINT2NUM(SDLK_WORLD_0));
564
- rb_define_const(mRubygame,"K_WORLD_1",UINT2NUM(SDLK_WORLD_1));
565
- rb_define_const(mRubygame,"K_WORLD_2",UINT2NUM(SDLK_WORLD_2));
566
- rb_define_const(mRubygame,"K_WORLD_3",UINT2NUM(SDLK_WORLD_3));
567
- rb_define_const(mRubygame,"K_WORLD_4",UINT2NUM(SDLK_WORLD_4));
568
- rb_define_const(mRubygame,"K_WORLD_5",UINT2NUM(SDLK_WORLD_5));
569
- rb_define_const(mRubygame,"K_WORLD_6",UINT2NUM(SDLK_WORLD_6));
570
- rb_define_const(mRubygame,"K_WORLD_7",UINT2NUM(SDLK_WORLD_7));
571
- rb_define_const(mRubygame,"K_WORLD_8",UINT2NUM(SDLK_WORLD_8));
572
- rb_define_const(mRubygame,"K_WORLD_9",UINT2NUM(SDLK_WORLD_9));
573
- rb_define_const(mRubygame,"K_WORLD_10",UINT2NUM(SDLK_WORLD_10));
574
- rb_define_const(mRubygame,"K_WORLD_11",UINT2NUM(SDLK_WORLD_11));
575
- rb_define_const(mRubygame,"K_WORLD_12",UINT2NUM(SDLK_WORLD_12));
576
- rb_define_const(mRubygame,"K_WORLD_13",UINT2NUM(SDLK_WORLD_13));
577
- rb_define_const(mRubygame,"K_WORLD_14",UINT2NUM(SDLK_WORLD_14));
578
- rb_define_const(mRubygame,"K_WORLD_15",UINT2NUM(SDLK_WORLD_15));
579
- rb_define_const(mRubygame,"K_WORLD_16",UINT2NUM(SDLK_WORLD_16));
580
- rb_define_const(mRubygame,"K_WORLD_17",UINT2NUM(SDLK_WORLD_17));
581
- rb_define_const(mRubygame,"K_WORLD_18",UINT2NUM(SDLK_WORLD_18));
582
- rb_define_const(mRubygame,"K_WORLD_19",UINT2NUM(SDLK_WORLD_19));
583
- rb_define_const(mRubygame,"K_WORLD_20",UINT2NUM(SDLK_WORLD_20));
584
- rb_define_const(mRubygame,"K_WORLD_21",UINT2NUM(SDLK_WORLD_21));
585
- rb_define_const(mRubygame,"K_WORLD_22",UINT2NUM(SDLK_WORLD_22));
586
- rb_define_const(mRubygame,"K_WORLD_23",UINT2NUM(SDLK_WORLD_23));
587
- rb_define_const(mRubygame,"K_WORLD_24",UINT2NUM(SDLK_WORLD_24));
588
- rb_define_const(mRubygame,"K_WORLD_25",UINT2NUM(SDLK_WORLD_25));
589
- rb_define_const(mRubygame,"K_WORLD_26",UINT2NUM(SDLK_WORLD_26));
590
- rb_define_const(mRubygame,"K_WORLD_27",UINT2NUM(SDLK_WORLD_27));
591
- rb_define_const(mRubygame,"K_WORLD_28",UINT2NUM(SDLK_WORLD_28));
592
- rb_define_const(mRubygame,"K_WORLD_29",UINT2NUM(SDLK_WORLD_29));
593
- rb_define_const(mRubygame,"K_WORLD_30",UINT2NUM(SDLK_WORLD_30));
594
- rb_define_const(mRubygame,"K_WORLD_31",UINT2NUM(SDLK_WORLD_31));
595
- rb_define_const(mRubygame,"K_WORLD_32",UINT2NUM(SDLK_WORLD_32));
596
- rb_define_const(mRubygame,"K_WORLD_33",UINT2NUM(SDLK_WORLD_33));
597
- rb_define_const(mRubygame,"K_WORLD_34",UINT2NUM(SDLK_WORLD_34));
598
- rb_define_const(mRubygame,"K_WORLD_35",UINT2NUM(SDLK_WORLD_35));
599
- rb_define_const(mRubygame,"K_WORLD_36",UINT2NUM(SDLK_WORLD_36));
600
- rb_define_const(mRubygame,"K_WORLD_37",UINT2NUM(SDLK_WORLD_37));
601
- rb_define_const(mRubygame,"K_WORLD_38",UINT2NUM(SDLK_WORLD_38));
602
- rb_define_const(mRubygame,"K_WORLD_39",UINT2NUM(SDLK_WORLD_39));
603
- rb_define_const(mRubygame,"K_WORLD_40",UINT2NUM(SDLK_WORLD_40));
604
- rb_define_const(mRubygame,"K_WORLD_41",UINT2NUM(SDLK_WORLD_41));
605
- rb_define_const(mRubygame,"K_WORLD_42",UINT2NUM(SDLK_WORLD_42));
606
- rb_define_const(mRubygame,"K_WORLD_43",UINT2NUM(SDLK_WORLD_43));
607
- rb_define_const(mRubygame,"K_WORLD_44",UINT2NUM(SDLK_WORLD_44));
608
- rb_define_const(mRubygame,"K_WORLD_45",UINT2NUM(SDLK_WORLD_45));
609
- rb_define_const(mRubygame,"K_WORLD_46",UINT2NUM(SDLK_WORLD_46));
610
- rb_define_const(mRubygame,"K_WORLD_47",UINT2NUM(SDLK_WORLD_47));
611
- rb_define_const(mRubygame,"K_WORLD_48",UINT2NUM(SDLK_WORLD_48));
612
- rb_define_const(mRubygame,"K_WORLD_49",UINT2NUM(SDLK_WORLD_49));
613
- rb_define_const(mRubygame,"K_WORLD_50",UINT2NUM(SDLK_WORLD_50));
614
- rb_define_const(mRubygame,"K_WORLD_51",UINT2NUM(SDLK_WORLD_51));
615
- rb_define_const(mRubygame,"K_WORLD_52",UINT2NUM(SDLK_WORLD_52));
616
- rb_define_const(mRubygame,"K_WORLD_53",UINT2NUM(SDLK_WORLD_53));
617
- rb_define_const(mRubygame,"K_WORLD_54",UINT2NUM(SDLK_WORLD_54));
618
- rb_define_const(mRubygame,"K_WORLD_55",UINT2NUM(SDLK_WORLD_55));
619
- rb_define_const(mRubygame,"K_WORLD_56",UINT2NUM(SDLK_WORLD_56));
620
- rb_define_const(mRubygame,"K_WORLD_57",UINT2NUM(SDLK_WORLD_57));
621
- rb_define_const(mRubygame,"K_WORLD_58",UINT2NUM(SDLK_WORLD_58));
622
- rb_define_const(mRubygame,"K_WORLD_59",UINT2NUM(SDLK_WORLD_59));
623
- rb_define_const(mRubygame,"K_WORLD_60",UINT2NUM(SDLK_WORLD_60));
624
- rb_define_const(mRubygame,"K_WORLD_61",UINT2NUM(SDLK_WORLD_61));
625
- rb_define_const(mRubygame,"K_WORLD_62",UINT2NUM(SDLK_WORLD_62));
626
- rb_define_const(mRubygame,"K_WORLD_63",UINT2NUM(SDLK_WORLD_63));
627
- rb_define_const(mRubygame,"K_WORLD_64",UINT2NUM(SDLK_WORLD_64));
628
- rb_define_const(mRubygame,"K_WORLD_65",UINT2NUM(SDLK_WORLD_65));
629
- rb_define_const(mRubygame,"K_WORLD_66",UINT2NUM(SDLK_WORLD_66));
630
- rb_define_const(mRubygame,"K_WORLD_67",UINT2NUM(SDLK_WORLD_67));
631
- rb_define_const(mRubygame,"K_WORLD_68",UINT2NUM(SDLK_WORLD_68));
632
- rb_define_const(mRubygame,"K_WORLD_69",UINT2NUM(SDLK_WORLD_69));
633
- rb_define_const(mRubygame,"K_WORLD_70",UINT2NUM(SDLK_WORLD_70));
634
- rb_define_const(mRubygame,"K_WORLD_71",UINT2NUM(SDLK_WORLD_71));
635
- rb_define_const(mRubygame,"K_WORLD_72",UINT2NUM(SDLK_WORLD_72));
636
- rb_define_const(mRubygame,"K_WORLD_73",UINT2NUM(SDLK_WORLD_73));
637
- rb_define_const(mRubygame,"K_WORLD_74",UINT2NUM(SDLK_WORLD_74));
638
- rb_define_const(mRubygame,"K_WORLD_75",UINT2NUM(SDLK_WORLD_75));
639
- rb_define_const(mRubygame,"K_WORLD_76",UINT2NUM(SDLK_WORLD_76));
640
- rb_define_const(mRubygame,"K_WORLD_77",UINT2NUM(SDLK_WORLD_77));
641
- rb_define_const(mRubygame,"K_WORLD_78",UINT2NUM(SDLK_WORLD_78));
642
- rb_define_const(mRubygame,"K_WORLD_79",UINT2NUM(SDLK_WORLD_79));
643
- rb_define_const(mRubygame,"K_WORLD_80",UINT2NUM(SDLK_WORLD_80));
644
- rb_define_const(mRubygame,"K_WORLD_81",UINT2NUM(SDLK_WORLD_81));
645
- rb_define_const(mRubygame,"K_WORLD_82",UINT2NUM(SDLK_WORLD_82));
646
- rb_define_const(mRubygame,"K_WORLD_83",UINT2NUM(SDLK_WORLD_83));
647
- rb_define_const(mRubygame,"K_WORLD_84",UINT2NUM(SDLK_WORLD_84));
648
- rb_define_const(mRubygame,"K_WORLD_85",UINT2NUM(SDLK_WORLD_85));
649
- rb_define_const(mRubygame,"K_WORLD_86",UINT2NUM(SDLK_WORLD_86));
650
- rb_define_const(mRubygame,"K_WORLD_87",UINT2NUM(SDLK_WORLD_87));
651
- rb_define_const(mRubygame,"K_WORLD_88",UINT2NUM(SDLK_WORLD_88));
652
- rb_define_const(mRubygame,"K_WORLD_89",UINT2NUM(SDLK_WORLD_89));
653
- rb_define_const(mRubygame,"K_WORLD_90",UINT2NUM(SDLK_WORLD_90));
654
- rb_define_const(mRubygame,"K_WORLD_91",UINT2NUM(SDLK_WORLD_91));
655
- rb_define_const(mRubygame,"K_WORLD_92",UINT2NUM(SDLK_WORLD_92));
656
- rb_define_const(mRubygame,"K_WORLD_93",UINT2NUM(SDLK_WORLD_93));
657
- rb_define_const(mRubygame,"K_WORLD_94",UINT2NUM(SDLK_WORLD_94));
658
- rb_define_const(mRubygame,"K_WORLD_95",UINT2NUM(SDLK_WORLD_95));
659
-
660
-
661
- /* Numeric keypad symbols */
662
- rb_define_const(mRubygame,"K_KP0",UINT2NUM(SDLK_KP0));
663
- rb_define_const(mRubygame,"K_KP1",UINT2NUM(SDLK_KP1));
664
- rb_define_const(mRubygame,"K_KP2",UINT2NUM(SDLK_KP2));
665
- rb_define_const(mRubygame,"K_KP3",UINT2NUM(SDLK_KP3));
666
- rb_define_const(mRubygame,"K_KP4",UINT2NUM(SDLK_KP4));
667
- rb_define_const(mRubygame,"K_KP5",UINT2NUM(SDLK_KP5));
668
- rb_define_const(mRubygame,"K_KP6",UINT2NUM(SDLK_KP6));
669
- rb_define_const(mRubygame,"K_KP7",UINT2NUM(SDLK_KP7));
670
- rb_define_const(mRubygame,"K_KP8",UINT2NUM(SDLK_KP8));
671
- rb_define_const(mRubygame,"K_KP9",UINT2NUM(SDLK_KP9));
672
- rb_define_const(mRubygame,"K_KP_PERIOD",UINT2NUM(SDLK_KP_PERIOD));
673
- rb_define_const(mRubygame,"K_KP_DIVIDE",UINT2NUM(SDLK_KP_DIVIDE));
674
- rb_define_const(mRubygame,"K_KP_MULTIPLY",UINT2NUM(SDLK_KP_MULTIPLY));
675
- rb_define_const(mRubygame,"K_KP_MINUS",UINT2NUM(SDLK_KP_MINUS));
676
- rb_define_const(mRubygame,"K_KP_PLUS",UINT2NUM(SDLK_KP_PLUS));
677
- rb_define_const(mRubygame,"K_KP_ENTER",UINT2NUM(SDLK_KP_ENTER));
678
- rb_define_const(mRubygame,"K_KP_EQUALS",UINT2NUM(SDLK_KP_EQUALS));
679
-
680
-
681
- /* Arrows + Home/End pad */
682
- rb_define_const(mRubygame,"K_UP",UINT2NUM(SDLK_UP));
683
- rb_define_const(mRubygame,"K_DOWN",UINT2NUM(SDLK_DOWN));
684
- rb_define_const(mRubygame,"K_RIGHT",UINT2NUM(SDLK_RIGHT));
685
- rb_define_const(mRubygame,"K_LEFT",UINT2NUM(SDLK_LEFT));
686
- rb_define_const(mRubygame,"K_INSERT",UINT2NUM(SDLK_INSERT));
687
- rb_define_const(mRubygame,"K_HOME",UINT2NUM(SDLK_HOME));
688
- rb_define_const(mRubygame,"K_END",UINT2NUM(SDLK_END));
689
- rb_define_const(mRubygame,"K_PAGEUP",UINT2NUM(SDLK_PAGEUP));
690
- rb_define_const(mRubygame,"K_PAGEDOWN",UINT2NUM(SDLK_PAGEDOWN));
691
-
692
-
693
- /* Function keys */
694
- rb_define_const(mRubygame,"K_F1",UINT2NUM(SDLK_F1));
695
- rb_define_const(mRubygame,"K_F2",UINT2NUM(SDLK_F2));
696
- rb_define_const(mRubygame,"K_F3",UINT2NUM(SDLK_F3));
697
- rb_define_const(mRubygame,"K_F4",UINT2NUM(SDLK_F4));
698
- rb_define_const(mRubygame,"K_F5",UINT2NUM(SDLK_F5));
699
- rb_define_const(mRubygame,"K_F6",UINT2NUM(SDLK_F6));
700
- rb_define_const(mRubygame,"K_F7",UINT2NUM(SDLK_F7));
701
- rb_define_const(mRubygame,"K_F8",UINT2NUM(SDLK_F8));
702
- rb_define_const(mRubygame,"K_F9",UINT2NUM(SDLK_F9));
703
- rb_define_const(mRubygame,"K_F10",UINT2NUM(SDLK_F10));
704
- rb_define_const(mRubygame,"K_F11",UINT2NUM(SDLK_F11));
705
- rb_define_const(mRubygame,"K_F12",UINT2NUM(SDLK_F12));
706
- rb_define_const(mRubygame,"K_F13",UINT2NUM(SDLK_F13));
707
- rb_define_const(mRubygame,"K_F14",UINT2NUM(SDLK_F14));
708
- rb_define_const(mRubygame,"K_F15",UINT2NUM(SDLK_F15));
709
-
710
-
711
- /* Key state modifier keys */
712
- rb_define_const(mRubygame,"K_NUMLOCK",UINT2NUM(SDLK_NUMLOCK));
713
- rb_define_const(mRubygame,"K_CAPSLOCK",UINT2NUM(SDLK_CAPSLOCK));
714
- rb_define_const(mRubygame,"K_SCROLLOCK",UINT2NUM(SDLK_SCROLLOCK));
715
- rb_define_const(mRubygame,"K_RSHIFT",UINT2NUM(SDLK_RSHIFT));
716
- rb_define_const(mRubygame,"K_LSHIFT",UINT2NUM(SDLK_LSHIFT));
717
- rb_define_const(mRubygame,"K_RCTRL",UINT2NUM(SDLK_RCTRL));
718
- rb_define_const(mRubygame,"K_LCTRL",UINT2NUM(SDLK_LCTRL));
719
- rb_define_const(mRubygame,"K_RALT",UINT2NUM(SDLK_RALT));
720
- rb_define_const(mRubygame,"K_LALT",UINT2NUM(SDLK_LALT));
721
- rb_define_const(mRubygame,"K_RMETA",UINT2NUM(SDLK_RMETA));
722
- rb_define_const(mRubygame,"K_LMETA",UINT2NUM(SDLK_LMETA));
723
- rb_define_const(mRubygame,"K_LSUPER",UINT2NUM(SDLK_LSUPER));
724
- rb_define_const(mRubygame,"K_RSUPER",UINT2NUM(SDLK_RSUPER));
725
- rb_define_const(mRubygame,"K_MODE",UINT2NUM(SDLK_MODE));
726
-
727
-
728
- /* Miscellaneous keys */
729
- rb_define_const(mRubygame,"K_HELP",UINT2NUM(SDLK_HELP));
730
- rb_define_const(mRubygame,"K_PRINT",UINT2NUM(SDLK_PRINT));
731
- rb_define_const(mRubygame,"K_SYSREQ",UINT2NUM(SDLK_SYSREQ));
732
- rb_define_const(mRubygame,"K_BREAK",UINT2NUM(SDLK_BREAK));
733
- rb_define_const(mRubygame,"K_MENU",UINT2NUM(SDLK_MENU));
734
- rb_define_const(mRubygame,"K_POWER",UINT2NUM(SDLK_POWER));
735
- rb_define_const(mRubygame,"K_EURO",UINT2NUM(SDLK_EURO));
736
- rb_define_const(mRubygame,"K_LAST",UINT2NUM(SDLK_LAST));
737
-
738
-
739
- #if 0
740
- /* key mods */
741
- /* rb_define_const(mRubygame,"K_MOD_NONE",UINT2NUM(KMOD_NONE)); */
742
- /* rb_define_const(mRubygame,"K_MOD_LSHIFT",UINT2NUM(KMOD_LSHIFT)); */
743
- /* rb_define_const(mRubygame,"K_MOD_RSHIFT",UINT2NUM(KMOD_RSHIFT)); */
744
- /* rb_define_const(mRubygame,"K_MOD_LCTRL",UINT2NUM(KMOD_LCTRL)); */
745
- /* rb_define_const(mRubygame,"K_MOD_RCTRL",UINT2NUM(KMOD_RCTRL)); */
746
- /* rb_define_const(mRubygame,"K_MOD_LALT",UINT2NUM(KMOD_LALT)); */
747
- /* rb_define_const(mRubygame,"K_MOD_RALT",UINT2NUM(KMOD_RALT)); */
748
- /* rb_define_const(mRubygame,"K_MOD_LMETA",UINT2NUM(KMOD_LMETA)); */
749
- /* rb_define_const(mRubygame,"K_MOD_RMETA",UINT2NUM(KMOD_RMETA)); */
750
- /* rb_define_const(mRubygame,"K_MOD_NUM",UINT2NUM(KMOD_NUM)); */
751
- /* rb_define_const(mRubygame,"K_MOD_CAPS",UINT2NUM(KMOD_CAPS)); */
752
- /* rb_define_const(mRubygame,"K_MOD_MODE",UINT2NUM(KMOD_MODE)); */
753
- /* rb_define_const(mRubygame,"K_MOD_RESERVED",UINT2NUM(KMOD_RESERVED)); */
754
-
755
- /* rb_define_const(mRubygame,"K_MOD_CTRL",UINT2NUM(KMOD_CTRL)); */
756
- /* rb_define_const(mRubygame,"K_MOD_SHIFT",UINT2NUM(KMOD_SHIFT)); */
757
- /* rb_define_const(mRubygame,"K_MOD_ALT",UINT2NUM(KMOD_ALT)); */
758
- /* rb_define_const(mRubygame,"K_MOD_META",UINT2NUM(KMOD_META)); */
759
- #endif
760
- }