rubygame 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,661 @@
1
+ /*--
2
+ * This file is one part of:
3
+ * Rubygame -- Ruby bindings to SDL to facilitate game creation
4
+ *
5
+ * Copyright (C) 2008 John Croisant
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ *++
21
+ */
22
+
23
+
24
+ #include "rubygame_shared.h"
25
+
26
+ void Rubygame_Init_Event2();
27
+
28
+ VALUE mEvents;
29
+
30
+
31
+
32
+
33
+ /*
34
+ * Make a new event from the given klassname and array of arguments.
35
+ *
36
+ */
37
+ VALUE rg_make_rbevent( char *klassname, int argc, VALUE *argv )
38
+ {
39
+ VALUE klass = rb_const_get( mEvents, rb_intern(klassname) );
40
+ return rb_funcall2( klass, rb_intern("new"), argc, argv );
41
+ }
42
+
43
+
44
+
45
+ /*
46
+ * Convert SDL's ACTIVEEVENT into zero or more of:
47
+ *
48
+ * InputFocusGained or InputFocusLost
49
+ * MouseFocusGained or MouseFocusLost
50
+ * WindowMinimized or WindowUnminimized
51
+ *
52
+ * Returns a ruby Array of the events it generated.
53
+ *
54
+ */
55
+ VALUE rg_convert_activeevent( SDL_Event ev )
56
+ {
57
+ char *klassname;
58
+
59
+ /*
60
+ Uint8 any_state = SDL_APPACTIVE | SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS;
61
+
62
+ if( (ev.active.state & any_state) == 0 )
63
+ {
64
+ rb_raise(eSDLError,
65
+ "unknown ACTIVEEVENT state %d. This is a bug in Rubygame.",
66
+ ev.active.state);
67
+ }
68
+ */
69
+
70
+ VALUE events = rb_ary_new();
71
+
72
+ if( SDL_APPACTIVE & ev.active.state )
73
+ {
74
+ klassname = ev.active.gain ? "WindowUnminimized" : "WindowMinimized";
75
+ rb_ary_push(events, rg_make_rbevent( klassname, 0, (VALUE *)NULL ));
76
+ }
77
+
78
+ if( SDL_APPINPUTFOCUS & ev.active.state )
79
+ {
80
+ klassname = ev.active.gain ? "InputFocusGained" : "InputFocusLost";
81
+ rb_ary_push(events, rg_make_rbevent( klassname, 0, (VALUE *)NULL ));
82
+
83
+ }
84
+
85
+ if( SDL_APPMOUSEFOCUS & ev.active.state )
86
+ {
87
+ klassname = ev.active.gain ? "MouseFocusGained" : "MouseFocusLost";
88
+ rb_ary_push(events, rg_make_rbevent( klassname, 0, (VALUE *)NULL ));
89
+ }
90
+
91
+
92
+ return events;
93
+ }
94
+
95
+
96
+
97
+ /*
98
+ * Convert SDL's ExposeEvent into WindowExposed.
99
+ *
100
+ */
101
+ VALUE rg_convert_exposeevent( SDL_Event ev )
102
+ {
103
+ return rg_make_rbevent( "WindowExposed", 0, (VALUE *)NULL );
104
+ }
105
+
106
+
107
+
108
+
109
+ /*
110
+ * Convert SDL's joystick axis events into JoystickAxisMoved.
111
+ *
112
+ */
113
+ VALUE rg_convert_joyaxisevent( SDL_Event ev )
114
+ {
115
+
116
+ VALUE joystick_id = UINT2NUM( ev.jaxis.which );
117
+
118
+ VALUE axis = UINT2NUM( ev.jaxis.axis );
119
+
120
+
121
+ double dvalue = 0.0;
122
+
123
+ /* Convert value to the -1.0 .. 1.0 range */
124
+ if( ev.jaxis.value > 0 )
125
+ {
126
+ dvalue = (double)(ev.jaxis.value)/32767.f;
127
+ }
128
+ else if( ev.jaxis.value < 0 )
129
+ {
130
+ dvalue = (double)(ev.jaxis.value)/32768.f;
131
+ }
132
+
133
+ VALUE value = rb_float_new( dvalue );
134
+
135
+
136
+ VALUE args[] = { joystick_id, axis, value };
137
+
138
+ return rg_make_rbevent( "JoystickAxisMoved", 3, args);
139
+
140
+ }
141
+
142
+
143
+
144
+
145
+ /*
146
+ * Convert SDL's joystick ball events into JoystickBallMoved.
147
+ *
148
+ */
149
+ VALUE rg_convert_joyballevent( SDL_Event ev )
150
+ {
151
+
152
+ VALUE joystick_id = UINT2NUM( ev.jball.which );
153
+
154
+ VALUE ball = UINT2NUM( ev.jball.ball );
155
+
156
+ VALUE rel = rb_ary_new();
157
+ rb_ary_push( rel, UINT2NUM( ev.jball.xrel ) );
158
+ rb_ary_push( rel, UINT2NUM( ev.jball.yrel ) );
159
+
160
+
161
+ VALUE args[] = { joystick_id, ball, rel };
162
+
163
+ return rg_make_rbevent( "JoystickBallMoved", 3, args);
164
+
165
+ }
166
+
167
+
168
+
169
+
170
+ /*
171
+ * Convert SDL's joystick button events into JoystickButtonPressed or
172
+ * JoystickButtonReleased.
173
+ *
174
+ */
175
+ VALUE rg_convert_joybuttonevent( SDL_Event ev )
176
+ {
177
+
178
+ VALUE joystick_id = UINT2NUM( ev.jball.which );
179
+
180
+ VALUE button = UINT2NUM( ev.jbutton.button );
181
+
182
+ VALUE args[] = { joystick_id, button };
183
+
184
+ switch( ev.jbutton.state )
185
+ {
186
+ case SDL_PRESSED:
187
+ return rg_make_rbevent( "JoystickButtonPressed", 2, args);
188
+
189
+ case SDL_RELEASED:
190
+ return rg_make_rbevent( "JoystickButtonReleased", 2, args);
191
+
192
+ default:
193
+ rb_raise(eSDLError,
194
+ "unknown joystick button state %d. This is a bug in Rubygame.",
195
+ ev.active.state);
196
+ }
197
+
198
+ }
199
+
200
+
201
+
202
+
203
+ VALUE rg_convert_joyhatsymbol( Uint8 value )
204
+ {
205
+ switch(value)
206
+ {
207
+ case SDL_HAT_RIGHTUP: return make_symbol("up_right");
208
+ case SDL_HAT_RIGHTDOWN: return make_symbol("down_right");
209
+ case SDL_HAT_LEFTUP: return make_symbol("up_left");
210
+ case SDL_HAT_LEFTDOWN: return make_symbol("down_left");
211
+ case SDL_HAT_UP: return make_symbol("up");
212
+ case SDL_HAT_RIGHT: return make_symbol("right");
213
+ case SDL_HAT_DOWN: return make_symbol("down");
214
+ case SDL_HAT_LEFT: return make_symbol("left");
215
+ default: return Qnil;
216
+ }
217
+ }
218
+
219
+
220
+ /*
221
+ * Convert SDL's joystick hat events into JoystickHatMoved.
222
+ *
223
+ */
224
+ VALUE rg_convert_joyhatevent( SDL_Event ev )
225
+ {
226
+
227
+ VALUE joystick_id = UINT2NUM( ev.jhat.which );
228
+ VALUE hat = UINT2NUM( ev.jhat.hat );
229
+ VALUE direction = rg_convert_joyhatsymbol( ev.jhat.value );
230
+
231
+ VALUE args[] = { joystick_id, hat, direction };
232
+
233
+ return rg_make_rbevent( "JoystickHatMoved", 3, args);
234
+
235
+ }
236
+
237
+
238
+
239
+
240
+ /* Returns a sanitized symbol for the given key. */
241
+ VALUE rg_convert_key_symbol2( SDLKey key )
242
+ {
243
+ char *name;
244
+
245
+ switch(key)
246
+ {
247
+ #if 1
248
+ case SDLK_1: name = "number 1"; break;
249
+ case SDLK_2: name = "number 2"; break;
250
+ case SDLK_3: name = "number 3"; break;
251
+ case SDLK_4: name = "number 4"; break;
252
+ case SDLK_5: name = "number 5"; break;
253
+ case SDLK_6: name = "number 6"; break;
254
+ case SDLK_7: name = "number 7"; break;
255
+ case SDLK_8: name = "number 8"; break;
256
+ case SDLK_9: name = "number 9"; break;
257
+ case SDLK_0: name = "number 0"; break;
258
+ case SDLK_EXCLAIM: name = "exclamation mark"; break;
259
+ case SDLK_QUOTEDBL: name = "double quote"; break;
260
+ case SDLK_HASH: name = "hash"; break;
261
+ case SDLK_DOLLAR: name = "dollar"; break;
262
+ case SDLK_AMPERSAND: name = "ampersand"; break;
263
+ case SDLK_QUOTE: name = "quote"; break;
264
+ case SDLK_LEFTPAREN: name = "left parenthesis"; break;
265
+ case SDLK_RIGHTPAREN: name = "right parenthesis"; break;
266
+ case SDLK_ASTERISK: name = "asterisk"; break;
267
+ case SDLK_PLUS: name = "plus"; break;
268
+ case SDLK_MINUS: name = "minus"; break;
269
+ case SDLK_PERIOD: name = "period"; break;
270
+ case SDLK_COMMA: name = "comma"; break;
271
+ case SDLK_SLASH: name = "slash"; break;
272
+ case SDLK_SEMICOLON: name = "semicolon"; break;
273
+ case SDLK_LESS: name = "less than"; break;
274
+ case SDLK_EQUALS: name = "equals"; break;
275
+ case SDLK_GREATER: name = "greater than"; break;
276
+ case SDLK_QUESTION: name = "question mark"; break;
277
+ case SDLK_AT: name = "at"; break;
278
+ case SDLK_LEFTBRACKET: name = "left bracket"; break;
279
+ case SDLK_BACKSLASH: name = "backslash"; break;
280
+ case SDLK_RIGHTBRACKET: name = "right bracket"; break;
281
+ case SDLK_CARET: name = "caret"; break;
282
+ case SDLK_UNDERSCORE: name = "underscore"; break;
283
+ case SDLK_BACKQUOTE: name = "backquote"; break;
284
+ case SDLK_KP1: name = "keypad 1"; break;
285
+ case SDLK_KP2: name = "keypad 2"; break;
286
+ case SDLK_KP3: name = "keypad 3"; break;
287
+ case SDLK_KP4: name = "keypad 4"; break;
288
+ case SDLK_KP5: name = "keypad 5"; break;
289
+ case SDLK_KP6: name = "keypad 6"; break;
290
+ case SDLK_KP7: name = "keypad 7"; break;
291
+ case SDLK_KP8: name = "keypad 8"; break;
292
+ case SDLK_KP9: name = "keypad 9"; break;
293
+ case SDLK_KP0: name = "keypad 0"; break;
294
+ case SDLK_KP_PERIOD: name = "keypad period"; break;
295
+ case SDLK_KP_DIVIDE: name = "keypad divide"; break;
296
+ case SDLK_KP_MULTIPLY: name = "keypad multiply"; break;
297
+ case SDLK_KP_MINUS: name = "keypad minus"; break;
298
+ case SDLK_KP_PLUS: name = "keypad plus"; break;
299
+ case SDLK_KP_EQUALS: name = "keypad equals"; break;
300
+ case SDLK_KP_ENTER: name = "keypad enter"; break;
301
+ #endif
302
+ default: name = SDL_GetKeyName(key); break;
303
+ }
304
+
305
+ return sanitized_symbol( name );
306
+ }
307
+
308
+
309
+
310
+ /* Convert an OR'd list of KMODs into a Ruby array of symbols. */
311
+ VALUE rg_convert_keymods2( SDLMod mods )
312
+ {
313
+ VALUE array;
314
+
315
+ array = rb_ary_new();
316
+ if(mods != 0)
317
+ {
318
+ /* KEY MODIFIER SYMBOL */
319
+ if(mods & KMOD_LSHIFT) rb_ary_push(array, make_symbol( "left_shift" ));
320
+ if(mods & KMOD_RSHIFT) rb_ary_push(array, make_symbol( "right_shift" ));
321
+ if(mods & KMOD_LCTRL) rb_ary_push(array, make_symbol( "left_ctrl" ));
322
+ if(mods & KMOD_RCTRL) rb_ary_push(array, make_symbol( "right_ctrl" ));
323
+ if(mods & KMOD_LALT) rb_ary_push(array, make_symbol( "left_alt" ));
324
+ if(mods & KMOD_RALT) rb_ary_push(array, make_symbol( "right_alt" ));
325
+ if(mods & KMOD_LMETA) rb_ary_push(array, make_symbol( "left_meta" ));
326
+ if(mods & KMOD_RMETA) rb_ary_push(array, make_symbol( "right_meta" ));
327
+ if(mods & KMOD_NUM) rb_ary_push(array, make_symbol( "numlock" ));
328
+ if(mods & KMOD_CAPS) rb_ary_push(array, make_symbol( "capslock" ));
329
+ if(mods & KMOD_MODE) rb_ary_push(array, make_symbol( "mode" ));
330
+ }
331
+ return array;
332
+ }
333
+
334
+
335
+
336
+ /* Convert a unicode char into a UTF8 ruby byte-string. */
337
+ VALUE rg_convert_unicode2( Uint16 unicode )
338
+ {
339
+ if( unicode > 0 )
340
+ {
341
+ char str[32];
342
+ snprintf(str, 32, "[%d].pack('U')", unicode);
343
+
344
+ return rb_eval_string( str );
345
+ }
346
+ else
347
+ {
348
+ return rb_str_new("", 0);
349
+ }
350
+ }
351
+
352
+
353
+
354
+ /*
355
+ * Convert SDL's keyboard events into KeyPressed / KeyReleased.
356
+ *
357
+ */
358
+ VALUE rg_convert_keyboardevent( SDL_Event ev )
359
+ {
360
+ VALUE key = rg_convert_key_symbol2( ev.key.keysym.sym );
361
+ VALUE mods = rg_convert_keymods2( ev.key.keysym.mod );
362
+
363
+ switch( ev.key.state )
364
+ {
365
+ case SDL_PRESSED: {
366
+ VALUE unicode = rg_convert_unicode2( ev.key.keysym.unicode );
367
+ VALUE args[] = { key, mods, unicode };
368
+
369
+ return rg_make_rbevent( "KeyPressed", 3, args);
370
+ }
371
+
372
+ case SDL_RELEASED: {
373
+ VALUE args[] = { key, mods };
374
+
375
+ return rg_make_rbevent( "KeyReleased", 2, args );
376
+ }
377
+
378
+ default:
379
+ rb_raise(eSDLError,
380
+ "unknown keyboard event state %d. This is a bug in Rubygame.",
381
+ ev.active.state);
382
+ }
383
+ }
384
+
385
+
386
+
387
+
388
+
389
+ /*
390
+ * Return a descriptive symbol for the given mouse button.
391
+ * e.g. :mouse_left, :mouse_wheel_up, etc.
392
+ *
393
+ */
394
+ VALUE rg_convert_mouse_symbol2( Uint8 button )
395
+ {
396
+ switch( button )
397
+ {
398
+ case SDL_BUTTON_LEFT:
399
+ return make_symbol("mouse_left");
400
+ case SDL_BUTTON_MIDDLE:
401
+ return make_symbol("mouse_middle");
402
+ case SDL_BUTTON_RIGHT:
403
+ return make_symbol("mouse_right");
404
+ case SDL_BUTTON_WHEELUP:
405
+ return make_symbol("mouse_wheel_up");
406
+ case SDL_BUTTON_WHEELDOWN:
407
+ return make_symbol("mouse_wheel_down");
408
+ default: {
409
+ int size = 32;
410
+ char *name = (char *)malloc(size);
411
+ snprintf( name, size, "mouse_%d", button );
412
+ return make_symbol(name);
413
+ }
414
+ }
415
+ }
416
+
417
+
418
+
419
+ /*
420
+ * Convert SDL's mouse click events into MousePressed / MouseReleased.
421
+ *
422
+ */
423
+ VALUE rg_convert_mouseclickevent( SDL_Event ev )
424
+ {
425
+
426
+ VALUE button = rg_convert_mouse_symbol2( ev.button.button );
427
+
428
+ VALUE pos = rb_ary_new();
429
+ rb_ary_push( pos, UINT2NUM( ev.button.x ) );
430
+ rb_ary_push( pos, UINT2NUM( ev.button.y ) );
431
+
432
+ VALUE args[] = { pos, button };
433
+
434
+
435
+ switch( ev.button.state )
436
+ {
437
+ case SDL_PRESSED:
438
+ return rg_make_rbevent( "MousePressed", 2, args);
439
+
440
+ case SDL_RELEASED:
441
+ return rg_make_rbevent( "MouseReleased", 2, args );
442
+
443
+ default:
444
+ rb_raise(eSDLError,
445
+ "unknown mouse event state %d. This is a bug in Rubygame.",
446
+ ev.active.state);
447
+ }
448
+
449
+ }
450
+
451
+
452
+
453
+ /*
454
+ * Convert a button state into a list of mouse button symbols.
455
+ *
456
+ */
457
+ VALUE rg_convert_mousebuttons2( Uint8 state )
458
+ {
459
+ VALUE buttons;
460
+
461
+ buttons = rb_ary_new();
462
+ if(state & SDL_BUTTON(SDL_BUTTON_LEFT))
463
+ rb_ary_push(buttons, make_symbol("mouse_left"));
464
+ if(state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
465
+ rb_ary_push(buttons, make_symbol("mouse_middle"));
466
+ if(state & SDL_BUTTON(SDL_BUTTON_RIGHT))
467
+ rb_ary_push(buttons, make_symbol("mouse_right"));
468
+ if(state & SDL_BUTTON(SDL_BUTTON_WHEELUP))
469
+ rb_ary_push(buttons, make_symbol("mouse_wheel_up"));
470
+ if(state & SDL_BUTTON(SDL_BUTTON_WHEELDOWN))
471
+ rb_ary_push(buttons, make_symbol("mouse_wheel_down"));
472
+ return buttons;
473
+ }
474
+
475
+
476
+ /*
477
+ * Convert SDL's mouse motion events into MouseMoved
478
+ *
479
+ */
480
+ VALUE rg_convert_mousemotionevent( SDL_Event ev )
481
+ {
482
+
483
+ VALUE buttons = rg_convert_mousebuttons2( ev.motion.state );
484
+
485
+
486
+ VALUE pos = rb_ary_new();
487
+ rb_ary_push( pos, UINT2NUM( ev.motion.x ) );
488
+ rb_ary_push( pos, UINT2NUM( ev.motion.y ) );
489
+
490
+
491
+ VALUE rel = rb_ary_new();
492
+ rb_ary_push( rel, UINT2NUM( ev.motion.xrel ) );
493
+ rb_ary_push( rel, UINT2NUM( ev.motion.yrel ) );
494
+
495
+
496
+ VALUE args[] = { pos, rel, buttons };
497
+
498
+ return rg_make_rbevent( "MouseMoved", 3, args);
499
+
500
+ }
501
+
502
+
503
+
504
+
505
+ /*
506
+ * Convert SDL's resize events into WindowResized
507
+ *
508
+ */
509
+ VALUE rg_convert_resizeevent( SDL_Event ev )
510
+ {
511
+
512
+ VALUE size = rb_ary_new();
513
+ rb_ary_push( size, UINT2NUM( ev.resize.w ) );
514
+ rb_ary_push( size, UINT2NUM( ev.resize.h ) );
515
+
516
+ VALUE args[] = { size };
517
+
518
+ return rg_make_rbevent( "WindowResized", 1, args);
519
+
520
+ }
521
+
522
+
523
+
524
+
525
+ /*
526
+ * Convert SDL's quit event into QuitRequested
527
+ *
528
+ */
529
+ VALUE rg_convert_quitevent( SDL_Event ev )
530
+ {
531
+ return rg_make_rbevent( "QuitRequested", 0, (VALUE *)NULL );
532
+ }
533
+
534
+
535
+
536
+
537
+ /*--
538
+ *
539
+ * call-seq:
540
+ * rg_convert_sdlevent2( SDL_Event ) -> VALUE rubygame_event
541
+ *
542
+ * Converts an SDL_Event (C type) into a Rubygame event of the corresponding
543
+ * class.
544
+ *
545
+ *++
546
+ */
547
+
548
+ VALUE rg_convert_sdlevent2( SDL_Event ev )
549
+ {
550
+
551
+ switch(ev.type)
552
+ {
553
+
554
+ case SDL_ACTIVEEVENT:
555
+ return rg_convert_activeevent(ev);
556
+
557
+ case SDL_VIDEOEXPOSE:
558
+ return rg_convert_exposeevent(ev);
559
+
560
+ case SDL_JOYAXISMOTION:
561
+ return rg_convert_joyaxisevent(ev);
562
+
563
+ case SDL_JOYBALLMOTION:
564
+ return rg_convert_joyballevent(ev);
565
+
566
+ case SDL_JOYBUTTONDOWN:
567
+ case SDL_JOYBUTTONUP:
568
+ return rg_convert_joybuttonevent(ev);
569
+
570
+ case SDL_JOYHATMOTION:
571
+ return rg_convert_joyhatevent(ev);
572
+
573
+ case SDL_KEYDOWN:
574
+ case SDL_KEYUP:
575
+ return rg_convert_keyboardevent(ev);
576
+
577
+ case SDL_MOUSEBUTTONDOWN:
578
+ case SDL_MOUSEBUTTONUP:
579
+ return rg_convert_mouseclickevent(ev);
580
+
581
+ case SDL_MOUSEMOTION:
582
+ return rg_convert_mousemotionevent(ev);
583
+
584
+ case SDL_VIDEORESIZE:
585
+ return rg_convert_resizeevent(ev);
586
+
587
+ case SDL_QUIT:
588
+ return rg_convert_quitevent(ev);
589
+
590
+ default:
591
+ rb_warn("Cannot convert unknown event type (%d).", ev.type);
592
+ return Qnil;
593
+
594
+ }
595
+
596
+ }
597
+
598
+
599
+
600
+
601
+ /*
602
+ * call-seq:
603
+ * fetch_sdl_events -> [event, ...]
604
+ *
605
+ * NOTE: This method converts the SDL events into the new-style event
606
+ * classes, located in the Rubygame::Events module. For converting to
607
+ * the older (deprecated) events, see Rubygame.fetch_sdl_events.
608
+ *
609
+ * Retrieves all pending events from SDL's event stack and converts them
610
+ * into Rubygame event objects. Returns an Array of all the events, in
611
+ * the order they were read.
612
+ *
613
+ * This method is used by the EventQueue class (among others), so
614
+ * don't call it if you are using any of Rubygame's event management
615
+ * classes (e.g. EventQueue)! If you do, they will not receive all
616
+ * the events, because some events will have been removed from SDL's
617
+ * event stack by this method.
618
+ *
619
+ * However, if you aren't using EventQueue, you can safely use this method
620
+ * to make your own event management system.
621
+ *
622
+ */
623
+ VALUE rg_fetch_sdl_events2( VALUE module )
624
+ {
625
+ SDL_Event event;
626
+ VALUE events = rb_ary_new();
627
+ VALUE thing;
628
+
629
+ while(SDL_PollEvent(&event)==1)
630
+ {
631
+ /* Either an event or array of zero or more events. */
632
+ thing = rg_convert_sdlevent2( event );
633
+
634
+ if( TYPE(thing) == T_ARRAY )
635
+ {
636
+ rb_ary_concat( events, thing );
637
+ }
638
+ else
639
+ {
640
+ rb_ary_push( events, thing );
641
+ }
642
+ }
643
+
644
+ return events;
645
+ }
646
+
647
+
648
+
649
+
650
+ void Rubygame_Init_Event2()
651
+ {
652
+ #if 0
653
+ mRubygame = rb_define_module("Rubygame");
654
+ #endif
655
+
656
+ mEvents = rb_define_module_under( mRubygame, "Events" );
657
+
658
+ rb_define_singleton_method( mEvents, "fetch_sdl_events",
659
+ rg_fetch_sdl_events2, 0);
660
+
661
+ }