rubysdl 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +505 -0
- data/MANIFEST +81 -0
- data/NEWS.en +144 -0
- data/NEWS.ja +151 -0
- data/README.en +117 -0
- data/README.ja +166 -0
- data/SDL_kanji.c +403 -0
- data/SDL_kanji.h +48 -0
- data/depend +18 -0
- data/doc/Makefile +18 -0
- data/doc/cdrom.rsd +431 -0
- data/doc/collision.rsd +162 -0
- data/doc/event.rsd +1487 -0
- data/doc/font.rsd +839 -0
- data/doc/general.rsd +49 -0
- data/doc/init.rsd +175 -0
- data/doc/joystick.rsd +387 -0
- data/doc/mixer.rsd +837 -0
- data/doc/mpeg.rsd +595 -0
- data/doc/rsd.rb +125 -0
- data/doc/sdlskk.rsd +496 -0
- data/doc/time.rsd +45 -0
- data/doc/video.rsd +2499 -0
- data/doc/wm.rsd +113 -0
- data/extconf.rb +92 -0
- data/lib/rubysdl_aliases.rb +431 -0
- data/lib/sdl.rb +271 -0
- data/rubysdl.h +109 -0
- data/rubysdl_cdrom.c +176 -0
- data/rubysdl_const_list.txt +280 -0
- data/rubysdl_doc.en.rd +2180 -0
- data/rubysdl_doc_old.rd +2402 -0
- data/rubysdl_event.c +346 -0
- data/rubysdl_event2.c +417 -0
- data/rubysdl_event_key.c +356 -0
- data/rubysdl_image.c +53 -0
- data/rubysdl_joystick.c +156 -0
- data/rubysdl_kanji.c +135 -0
- data/rubysdl_main.c +202 -0
- data/rubysdl_mixer.c +422 -0
- data/rubysdl_mouse.c +96 -0
- data/rubysdl_opengl.c +63 -0
- data/rubysdl_pixel.c +133 -0
- data/rubysdl_ref.html +5550 -0
- data/rubysdl_ref.rd +6163 -0
- data/rubysdl_rwops.c +90 -0
- data/rubysdl_sdlskk.c +312 -0
- data/rubysdl_sge_video.c +622 -0
- data/rubysdl_smpeg.c +341 -0
- data/rubysdl_time.c +36 -0
- data/rubysdl_ttf.c +324 -0
- data/rubysdl_video.c +749 -0
- data/rubysdl_wm.c +71 -0
- data/sample/aadraw.rb +24 -0
- data/sample/alpha.rb +27 -0
- data/sample/alphadraw.rb +25 -0
- data/sample/bfont.rb +24 -0
- data/sample/cdrom.rb +17 -0
- data/sample/collision.rb +97 -0
- data/sample/cursor.bmp +0 -0
- data/sample/cursor.rb +22 -0
- data/sample/ellipses.rb +35 -0
- data/sample/event2.rb +32 -0
- data/sample/font.bmp +0 -0
- data/sample/font.rb +25 -0
- data/sample/fpstimer.rb +175 -0
- data/sample/icon.bmp +0 -0
- data/sample/joy2.rb +81 -0
- data/sample/kanji.rb +36 -0
- data/sample/movesp.rb +93 -0
- data/sample/playmod.rb +14 -0
- data/sample/plaympeg.rb +48 -0
- data/sample/playwave.rb +16 -0
- data/sample/randrect.rb +40 -0
- data/sample/sample.ttf +0 -0
- data/sample/sdlskk.rb +70 -0
- data/sample/sgetest.rb +31 -0
- data/sample/stetris.rb +275 -0
- data/sample/testgl.rb +166 -0
- data/sample/testsprite.rb +68 -0
- data/sample/transformblit.rb +41 -0
- metadata +121 -0
data/rubysdl_event.c
ADDED
@@ -0,0 +1,346 @@
|
|
1
|
+
/*
|
2
|
+
Ruby/SDL Ruby extension library for SDL
|
3
|
+
|
4
|
+
Copyright (C) 2001-2007 Ohbayashi Ippei
|
5
|
+
|
6
|
+
This library is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU Lesser General Public
|
8
|
+
License as published by the Free Software Foundation; either
|
9
|
+
version 2.1 of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This library is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public
|
17
|
+
License along with this library; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
*/
|
20
|
+
#include "rubysdl.h"
|
21
|
+
|
22
|
+
void eventCheck(int pred,char *msg)
|
23
|
+
{
|
24
|
+
if(!pred)
|
25
|
+
rb_raise(eSDLError,"this event is not %s event",msg) ;
|
26
|
+
}
|
27
|
+
|
28
|
+
static VALUE createEventObject(VALUE class)
|
29
|
+
{
|
30
|
+
SDL_Event *event;
|
31
|
+
|
32
|
+
return Data_Make_Struct(class,SDL_Event,0,free,event);
|
33
|
+
}
|
34
|
+
|
35
|
+
static VALUE sdl_pollEvent(VALUE obj)
|
36
|
+
{
|
37
|
+
SDL_Event *event;
|
38
|
+
|
39
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
40
|
+
return INT2NUM(SDL_PollEvent(event));
|
41
|
+
}
|
42
|
+
static VALUE sdl_waitEvent(VALUE obj)
|
43
|
+
{
|
44
|
+
SDL_Event *event;
|
45
|
+
|
46
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
47
|
+
if( SDL_WaitEvent(event)==0 )
|
48
|
+
rb_raise(eSDLError,"SDL_WaitEvent Failed :%s",SDL_GetError());
|
49
|
+
return Qnil;
|
50
|
+
}
|
51
|
+
|
52
|
+
static VALUE sdl_eventType(VALUE obj)
|
53
|
+
{
|
54
|
+
SDL_Event *event;
|
55
|
+
|
56
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
57
|
+
return INT2FIX(event->type);
|
58
|
+
}
|
59
|
+
|
60
|
+
/* --KeyboardEvent-- */
|
61
|
+
static VALUE sdl_eventKeyPressed(VALUE obj)
|
62
|
+
{
|
63
|
+
SDL_Event *event;
|
64
|
+
|
65
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
66
|
+
eventCheck((event->type == SDL_KEYDOWN)||(event->type == SDL_KEYUP),"key");
|
67
|
+
if( event->key.state==SDL_PRESSED )
|
68
|
+
return Qtrue;
|
69
|
+
else
|
70
|
+
return Qfalse;
|
71
|
+
}
|
72
|
+
static VALUE sdl_eventKeyMod(VALUE obj)
|
73
|
+
{
|
74
|
+
SDL_Event *event;
|
75
|
+
|
76
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
77
|
+
eventCheck((event->type == SDL_KEYDOWN)||(event->type == SDL_KEYUP),"key");
|
78
|
+
return INT2NUM(event->key.keysym.mod);
|
79
|
+
}
|
80
|
+
static VALUE sdl_eventKeySym(VALUE obj)
|
81
|
+
{
|
82
|
+
SDL_Event *event;
|
83
|
+
|
84
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
85
|
+
eventCheck((event->type == SDL_KEYDOWN)||(event->type == SDL_KEYUP),"key");
|
86
|
+
return INT2FIX(event->key.keysym.sym);
|
87
|
+
}
|
88
|
+
|
89
|
+
/* --ActiveEvent-- */
|
90
|
+
static VALUE sdl_eventActiveGained(VALUE obj)
|
91
|
+
{
|
92
|
+
SDL_Event *event;
|
93
|
+
|
94
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
95
|
+
eventCheck( event->type == SDL_ACTIVEEVENT , "active" );
|
96
|
+
return (event->active.gain)?Qtrue:Qfalse;
|
97
|
+
}
|
98
|
+
static VALUE sdl_eventActiveState(VALUE obj)
|
99
|
+
{
|
100
|
+
SDL_Event *event;
|
101
|
+
|
102
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
103
|
+
eventCheck( event->type == SDL_ACTIVEEVENT , "active" );
|
104
|
+
return INT2NUM(event->active.state);
|
105
|
+
}
|
106
|
+
|
107
|
+
/* --MouseMotionEvent-- */
|
108
|
+
static VALUE sdl_eventMouseX(VALUE obj)
|
109
|
+
{
|
110
|
+
SDL_Event *event;
|
111
|
+
|
112
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
113
|
+
switch (event->type){
|
114
|
+
case SDL_MOUSEMOTION:
|
115
|
+
return INT2NUM(event->motion.x);
|
116
|
+
case SDL_MOUSEBUTTONUP:
|
117
|
+
case SDL_MOUSEBUTTONDOWN:
|
118
|
+
return INT2NUM(event->button.x);
|
119
|
+
default:
|
120
|
+
eventCheck(0,"mouse"); /* raise exception */
|
121
|
+
}
|
122
|
+
return Qnil; /* never reach */
|
123
|
+
}
|
124
|
+
static VALUE sdl_eventMouseY(VALUE obj)
|
125
|
+
{
|
126
|
+
SDL_Event *event;
|
127
|
+
|
128
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
129
|
+
switch (event->type){
|
130
|
+
case SDL_MOUSEMOTION:
|
131
|
+
return INT2NUM(event->motion.y);
|
132
|
+
case SDL_MOUSEBUTTONUP:
|
133
|
+
case SDL_MOUSEBUTTONDOWN:
|
134
|
+
return INT2NUM(event->button.y);
|
135
|
+
default:
|
136
|
+
eventCheck(0,"mouse"); /* raise exception */
|
137
|
+
}
|
138
|
+
return Qnil; /* never reach */
|
139
|
+
}
|
140
|
+
static VALUE sdl_eventMouseXrel(VALUE obj)
|
141
|
+
{
|
142
|
+
SDL_Event *event;
|
143
|
+
|
144
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
145
|
+
eventCheck(event->type==SDL_MOUSEMOTION,"mouse motion");
|
146
|
+
return INT2NUM(event->motion.xrel);
|
147
|
+
}
|
148
|
+
static VALUE sdl_eventMouseYrel(VALUE obj)
|
149
|
+
{
|
150
|
+
SDL_Event *event;
|
151
|
+
|
152
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
153
|
+
eventCheck(event->type==SDL_MOUSEMOTION,"mouse motion");
|
154
|
+
return INT2NUM(event->motion.yrel);
|
155
|
+
}
|
156
|
+
|
157
|
+
/* --SDL_MouseButtonEvent-- */
|
158
|
+
static VALUE sdl_eventMouseButton(VALUE obj)
|
159
|
+
{
|
160
|
+
SDL_Event *event;
|
161
|
+
|
162
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
163
|
+
eventCheck( (event->type==SDL_MOUSEBUTTONUP)||
|
164
|
+
(event->type==SDL_MOUSEBUTTONDOWN) , "mouse button" );
|
165
|
+
return INT2NUM( event->button.button );
|
166
|
+
}
|
167
|
+
static VALUE sdl_eventMousePressed(VALUE obj)
|
168
|
+
{
|
169
|
+
SDL_Event *event;
|
170
|
+
|
171
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
172
|
+
eventCheck( (event->type==SDL_MOUSEBUTTONUP)||
|
173
|
+
( event->type==SDL_MOUSEBUTTONDOWN) , "mouse button" );
|
174
|
+
return (event->button.state==SDL_PRESSED)?Qtrue:Qfalse;
|
175
|
+
}
|
176
|
+
|
177
|
+
static VALUE sdl_eventInfo(VALUE obj)
|
178
|
+
{
|
179
|
+
SDL_Event *event;
|
180
|
+
|
181
|
+
Data_Get_Struct(obj,SDL_Event,event);
|
182
|
+
switch(event->type){
|
183
|
+
case SDL_ACTIVEEVENT:
|
184
|
+
return rb_ary_new3(3,INT2FIX(SDL_ACTIVEEVENT),BOOL(event->active.gain),
|
185
|
+
INT2FIX(event->active.state));
|
186
|
+
case SDL_KEYDOWN:
|
187
|
+
case SDL_KEYUP:
|
188
|
+
return rb_ary_new3( 4, INT2FIX(event->type),
|
189
|
+
BOOL(event->key.state==SDL_PRESSED),
|
190
|
+
INT2FIX(event->key.keysym.sym),
|
191
|
+
UINT2NUM(event->key.keysym.mod)
|
192
|
+
);
|
193
|
+
case SDL_MOUSEMOTION:
|
194
|
+
return rb_ary_new3( 6, INT2FIX(SDL_MOUSEMOTION),
|
195
|
+
INT2FIX(event->motion.state),
|
196
|
+
INT2FIX(event->motion.x),
|
197
|
+
INT2FIX(event->motion.y),
|
198
|
+
INT2FIX(event->motion.xrel),
|
199
|
+
INT2FIX(event->motion.yrel)
|
200
|
+
);
|
201
|
+
case SDL_MOUSEBUTTONDOWN:
|
202
|
+
case SDL_MOUSEBUTTONUP:
|
203
|
+
return rb_ary_new3( 5, INT2FIX(event->type),
|
204
|
+
INT2FIX(event->button.button),
|
205
|
+
BOOL(event->button.state==SDL_PRESSED),
|
206
|
+
INT2FIX(event->button.x),
|
207
|
+
INT2FIX(event->button.y)
|
208
|
+
);
|
209
|
+
case SDL_JOYAXISMOTION:
|
210
|
+
return rb_ary_new3( 4, INT2FIX(SDL_JOYAXISMOTION),
|
211
|
+
INT2FIX(event->jaxis.which),
|
212
|
+
INT2FIX(event->jaxis.axis),
|
213
|
+
INT2FIX(event->jaxis.value)
|
214
|
+
);
|
215
|
+
case SDL_JOYBALLMOTION:
|
216
|
+
return rb_ary_new3( 5, INT2FIX(SDL_JOYBALLMOTION),
|
217
|
+
INT2FIX(event->jball.which),
|
218
|
+
INT2FIX(event->jball.ball),
|
219
|
+
INT2FIX(event->jball.xrel),
|
220
|
+
INT2FIX(event->jball.yrel)
|
221
|
+
);
|
222
|
+
case SDL_JOYHATMOTION:
|
223
|
+
return rb_ary_new3( 4, INT2FIX(SDL_JOYHATMOTION),
|
224
|
+
INT2FIX(event->jhat.which),
|
225
|
+
INT2FIX(event->jhat.hat),
|
226
|
+
INT2FIX(event->jhat.value)
|
227
|
+
);
|
228
|
+
case SDL_JOYBUTTONDOWN:
|
229
|
+
case SDL_JOYBUTTONUP:
|
230
|
+
return rb_ary_new3( 4, INT2FIX(event->type),
|
231
|
+
INT2FIX(event->jbutton.which),
|
232
|
+
INT2FIX(event->jbutton.button),
|
233
|
+
BOOL(event->jbutton.state==SDL_PRESSED)
|
234
|
+
);
|
235
|
+
case SDL_QUIT:
|
236
|
+
return rb_ary_new3( 1, INT2FIX(SDL_QUIT));
|
237
|
+
case SDL_SYSWMEVENT:
|
238
|
+
return rb_ary_new3( 1, INT2FIX(SDL_SYSWMEVENT));
|
239
|
+
case SDL_VIDEORESIZE:
|
240
|
+
return rb_ary_new3( 3, INT2FIX(SDL_VIDEORESIZE),
|
241
|
+
INT2FIX(event->resize.w),
|
242
|
+
INT2FIX(event->resize.h)
|
243
|
+
);
|
244
|
+
}
|
245
|
+
return Qnil;
|
246
|
+
}
|
247
|
+
|
248
|
+
static VALUE sdl_getAppState(VALUE class)
|
249
|
+
{
|
250
|
+
return INT2FIX(SDL_GetAppState());
|
251
|
+
}
|
252
|
+
|
253
|
+
static VALUE sdl_enableUNICODE(VALUE class)
|
254
|
+
{
|
255
|
+
SDL_EnableUNICODE(1);
|
256
|
+
return Qnil;
|
257
|
+
}
|
258
|
+
static VALUE sdl_disableUNICODE(VALUE class)
|
259
|
+
{
|
260
|
+
SDL_EnableUNICODE(0);
|
261
|
+
return Qnil;
|
262
|
+
}
|
263
|
+
static VALUE sdl_is_enableUNICODE(VALUE class)
|
264
|
+
{
|
265
|
+
return BOOL(SDL_EnableUNICODE(-1));
|
266
|
+
}
|
267
|
+
|
268
|
+
static void defineConstForEvent()
|
269
|
+
{
|
270
|
+
rb_define_const(cEvent,"NOEVENT",INT2NUM(SDL_NOEVENT));
|
271
|
+
rb_define_const(cEvent,"ACTIVEEVENT",INT2NUM(SDL_ACTIVEEVENT));
|
272
|
+
rb_define_const(cEvent,"KEYDOWN",INT2NUM(SDL_KEYDOWN));
|
273
|
+
rb_define_const(cEvent,"KEYUP",INT2NUM(SDL_KEYUP));
|
274
|
+
rb_define_const(cEvent,"MOUSEMOTION",INT2NUM(SDL_MOUSEMOTION));
|
275
|
+
rb_define_const(cEvent,"MOUSEBUTTONDOWN",INT2NUM(SDL_MOUSEBUTTONDOWN));
|
276
|
+
rb_define_const(cEvent,"MOUSEBUTTONUP",INT2NUM(SDL_MOUSEBUTTONUP));
|
277
|
+
rb_define_const(cEvent,"JOYAXISMOTION",INT2NUM(SDL_JOYAXISMOTION));
|
278
|
+
rb_define_const(cEvent,"JOYBALLMOTION",INT2NUM(SDL_JOYBALLMOTION));
|
279
|
+
rb_define_const(cEvent,"JOYHATMOTION",INT2NUM(SDL_JOYHATMOTION));
|
280
|
+
rb_define_const(cEvent,"JOYBUTTONDOWN",INT2NUM(SDL_JOYBUTTONDOWN));
|
281
|
+
rb_define_const(cEvent,"JOYBUTTONUP",INT2NUM(SDL_JOYBUTTONUP));
|
282
|
+
rb_define_const(cEvent,"QUIT",INT2NUM(SDL_QUIT));
|
283
|
+
rb_define_const(cEvent,"SYSWMEVENT",INT2NUM(SDL_SYSWMEVENT));
|
284
|
+
rb_define_const(cEvent,"EVENT_RESERVEDA",INT2NUM(SDL_EVENT_RESERVEDA));
|
285
|
+
rb_define_const(cEvent,"EVENT_RESERVEDB",INT2NUM(SDL_EVENT_RESERVEDB));
|
286
|
+
rb_define_const(cEvent,"VIDEORESIZE",INT2NUM(SDL_VIDEORESIZE));
|
287
|
+
#if SDL_VERSION_ATLEAST(1,2,0)
|
288
|
+
rb_define_const(cEvent,"VIDEOEXPOSE",INT2NUM(SDL_VIDEOEXPOSE));
|
289
|
+
#else
|
290
|
+
rb_define_const(cEvent,"EVENT_RESERVED1",INT2NUM(SDL_EVENT_RESERVED1));
|
291
|
+
#endif
|
292
|
+
rb_define_const(cEvent,"EVENT_RESERVED2",INT2NUM(SDL_EVENT_RESERVED2));
|
293
|
+
rb_define_const(cEvent,"EVENT_RESERVED3",INT2NUM(SDL_EVENT_RESERVED3));
|
294
|
+
rb_define_const(cEvent,"EVENT_RESERVED4",INT2NUM(SDL_EVENT_RESERVED4));
|
295
|
+
rb_define_const(cEvent,"EVENT_RESERVED5",INT2NUM(SDL_EVENT_RESERVED5));
|
296
|
+
rb_define_const(cEvent,"EVENT_RESERVED6",INT2NUM(SDL_EVENT_RESERVED6));
|
297
|
+
rb_define_const(cEvent,"EVENT_RESERVED7",INT2NUM(SDL_EVENT_RESERVED7));
|
298
|
+
/* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
|
299
|
+
rb_define_const(cEvent,"USEREVENT",INT2NUM(SDL_USEREVENT));
|
300
|
+
/* This last event is only for bounding internal arrays
|
301
|
+
It is the number of bits in the event mask datatype -- Uint32
|
302
|
+
*/
|
303
|
+
rb_define_const(cEvent,"NUMEVENTS",INT2NUM(SDL_NUMEVENTS));
|
304
|
+
|
305
|
+
/* The available application states */
|
306
|
+
rb_define_const(cEvent,"APPMOUSEFOCUS",UINT2NUM(SDL_APPMOUSEFOCUS));
|
307
|
+
rb_define_const(cEvent,"APPINPUTFOCUS",UINT2NUM(SDL_APPINPUTFOCUS));
|
308
|
+
rb_define_const(cEvent,"APPACTIVE",UINT2NUM(SDL_APPACTIVE));
|
309
|
+
|
310
|
+
}
|
311
|
+
|
312
|
+
|
313
|
+
void init_event()
|
314
|
+
{
|
315
|
+
cEvent = rb_define_class_under(mSDL,"Event",rb_cObject);
|
316
|
+
rb_define_singleton_method(cEvent,"new",createEventObject,0);
|
317
|
+
|
318
|
+
rb_define_singleton_method(cEvent,"appState",sdl_getAppState,0);
|
319
|
+
rb_define_singleton_method(cEvent,"enableUNICODE",sdl_enableUNICODE,0);
|
320
|
+
rb_define_singleton_method(cEvent,"disableUNICODE",sdl_disableUNICODE,0);
|
321
|
+
rb_define_singleton_method(cEvent,"enableUNICODE?",sdl_is_enableUNICODE,0);
|
322
|
+
|
323
|
+
rb_define_method(cEvent,"poll",sdl_pollEvent,0);
|
324
|
+
rb_define_method(cEvent,"wait",sdl_waitEvent,0);
|
325
|
+
|
326
|
+
rb_define_method(cEvent,"type",sdl_eventType,0);
|
327
|
+
|
328
|
+
rb_define_method(cEvent,"keyPress?",sdl_eventKeyPressed,0);
|
329
|
+
rb_define_method(cEvent,"keySym",sdl_eventKeySym,0);
|
330
|
+
rb_define_method(cEvent,"keyMod",sdl_eventKeyMod,0);
|
331
|
+
|
332
|
+
rb_define_method(cEvent,"gain?",sdl_eventActiveGained,0);
|
333
|
+
rb_define_method(cEvent,"appState",sdl_eventActiveState,0);
|
334
|
+
|
335
|
+
rb_define_method(cEvent,"mouseX",sdl_eventMouseX,0);
|
336
|
+
rb_define_method(cEvent,"mouseY",sdl_eventMouseY,0);
|
337
|
+
rb_define_method(cEvent,"mouseXrel",sdl_eventMouseXrel,0);
|
338
|
+
rb_define_method(cEvent,"mouseYrel",sdl_eventMouseYrel,0);
|
339
|
+
|
340
|
+
rb_define_method(cEvent,"mouseButton",sdl_eventMouseButton,0);
|
341
|
+
rb_define_method(cEvent,"mousePress?",sdl_eventMousePressed,0);
|
342
|
+
|
343
|
+
rb_define_method(cEvent,"info",sdl_eventInfo,0);
|
344
|
+
defineConstForEvent();
|
345
|
+
|
346
|
+
}
|
data/rubysdl_event2.c
ADDED
@@ -0,0 +1,417 @@
|
|
1
|
+
/*
|
2
|
+
Ruby/SDL Ruby extension library for SDL
|
3
|
+
|
4
|
+
Copyright (C) 2001-2007 Ohbayashi Ippei
|
5
|
+
|
6
|
+
This library is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU Lesser General Public
|
8
|
+
License as published by the Free Software Foundation; either
|
9
|
+
version 2.1 of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This library is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public
|
17
|
+
License along with this library; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
*/
|
20
|
+
|
21
|
+
#ifdef DEF_EVENT2
|
22
|
+
|
23
|
+
#include "rubysdl.h"
|
24
|
+
|
25
|
+
typedef VALUE (*createEventObjFunc)(SDL_Event *);
|
26
|
+
static createEventObjFunc createEventObj[SDL_NUMEVENTS];
|
27
|
+
|
28
|
+
static VALUE createNoEvent(SDL_Event *event)
|
29
|
+
{
|
30
|
+
return Qnil;
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE createActiveEvent(SDL_Event *event)
|
34
|
+
{
|
35
|
+
VALUE obj=rb_obj_alloc(cActiveEvent);
|
36
|
+
rb_iv_set(obj,"@gain",BOOL(event->active.gain));
|
37
|
+
rb_iv_set(obj,"@state",INT2FIX(event->active.state));
|
38
|
+
return obj;
|
39
|
+
}
|
40
|
+
|
41
|
+
static VALUE createKeyEvent(VALUE obj,SDL_Event *event)
|
42
|
+
{
|
43
|
+
rb_iv_set(obj,"@press",BOOL(event->key.state==SDL_PRESSED));
|
44
|
+
rb_iv_set(obj,"@sym",INT2FIX(event->key.keysym.sym));
|
45
|
+
rb_iv_set(obj,"@mod",UINT2NUM(event->key.keysym.mod));
|
46
|
+
rb_iv_set(obj,"@unicode",UINT2NUM(event->key.keysym.unicode));
|
47
|
+
return obj;
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE createKeyDownEvent(SDL_Event *event)
|
51
|
+
{
|
52
|
+
VALUE obj=rb_obj_alloc(cKeyDownEvent);
|
53
|
+
return createKeyEvent(obj,event);
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE createKeyUpEvent(SDL_Event *event)
|
57
|
+
{
|
58
|
+
VALUE obj=rb_obj_alloc(cKeyUpEvent);
|
59
|
+
return createKeyEvent(obj,event);
|
60
|
+
}
|
61
|
+
|
62
|
+
static VALUE createMouseMotionEvent(SDL_Event *event)
|
63
|
+
{
|
64
|
+
VALUE obj=rb_obj_alloc(cMouseMotionEvent);
|
65
|
+
rb_iv_set(obj,"@state",INT2FIX(event->motion.state));
|
66
|
+
rb_iv_set(obj,"@x",INT2FIX(event->motion.x));
|
67
|
+
rb_iv_set(obj,"@y",INT2FIX(event->motion.y));
|
68
|
+
rb_iv_set(obj,"@xrel",INT2FIX(event->motion.xrel));
|
69
|
+
rb_iv_set(obj,"@yrel",INT2FIX(event->motion.yrel));
|
70
|
+
return obj;
|
71
|
+
}
|
72
|
+
|
73
|
+
static VALUE createMouseButtonEvent(VALUE obj,SDL_Event *event)
|
74
|
+
{
|
75
|
+
rb_iv_set(obj,"@button",INT2FIX(event->button.button));
|
76
|
+
rb_iv_set(obj,"@press",BOOL(event->button.state==SDL_PRESSED));
|
77
|
+
rb_iv_set(obj,"@x",INT2FIX(event->button.x));
|
78
|
+
rb_iv_set(obj,"@y",INT2FIX(event->button.y));
|
79
|
+
return obj;
|
80
|
+
}
|
81
|
+
|
82
|
+
static VALUE createMouseButtonDownEvent(SDL_Event *event)
|
83
|
+
{
|
84
|
+
VALUE obj=rb_obj_alloc(cMouseButtonDownEvent);
|
85
|
+
return createMouseButtonEvent(obj,event);
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE createMouseButtonUpEvent(SDL_Event *event)
|
89
|
+
{
|
90
|
+
VALUE obj=rb_obj_alloc(cMouseButtonUpEvent);
|
91
|
+
return createMouseButtonEvent(obj,event);
|
92
|
+
}
|
93
|
+
|
94
|
+
static VALUE createJoyAxisEvent(SDL_Event *event)
|
95
|
+
{
|
96
|
+
VALUE obj=rb_obj_alloc(cJoyAxisEvent);
|
97
|
+
rb_iv_set(obj,"@which",INT2FIX(event->jaxis.which));
|
98
|
+
rb_iv_set(obj,"@axis",INT2FIX(event->jaxis.axis));
|
99
|
+
rb_iv_set(obj,"@value",INT2FIX(event->jaxis.value));
|
100
|
+
return obj;
|
101
|
+
}
|
102
|
+
|
103
|
+
static VALUE createJoyBallEvent(SDL_Event *event)
|
104
|
+
{
|
105
|
+
VALUE obj=rb_obj_alloc(cJoyBallEvent);
|
106
|
+
rb_iv_set(obj,"@which",INT2FIX(event->jball.which));
|
107
|
+
rb_iv_set(obj,"@ball",INT2FIX(event->jball.ball));
|
108
|
+
rb_iv_set(obj,"@xrel",INT2FIX(event->jball.xrel));
|
109
|
+
rb_iv_set(obj,"@yrel",INT2FIX(event->jball.yrel));
|
110
|
+
return obj;
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE createJoyHatEvent(SDL_Event *event)
|
114
|
+
{
|
115
|
+
VALUE obj=rb_obj_alloc(cJoyHatEvent);
|
116
|
+
rb_iv_set(obj,"@which",INT2FIX(event->jhat.which));
|
117
|
+
rb_iv_set(obj,"@hat",INT2FIX(event->jhat.hat));
|
118
|
+
rb_iv_set(obj,"@value",INT2FIX(event->jhat.value));
|
119
|
+
return obj;
|
120
|
+
}
|
121
|
+
|
122
|
+
static VALUE createJoyButtonEvent(VALUE obj,SDL_Event *event)
|
123
|
+
{
|
124
|
+
rb_iv_set(obj,"@which",INT2FIX(event->jbutton.which));
|
125
|
+
rb_iv_set(obj,"@button",INT2FIX(event->jbutton.button));
|
126
|
+
rb_iv_set(obj,"@press",BOOL(event->jbutton.state==SDL_PRESSED));
|
127
|
+
return obj;
|
128
|
+
}
|
129
|
+
static VALUE createJoyButtonUpEvent(SDL_Event *event)
|
130
|
+
{
|
131
|
+
VALUE obj=rb_obj_alloc(cJoyButtonUpEvent);
|
132
|
+
return createJoyButtonEvent(obj,event);
|
133
|
+
}
|
134
|
+
|
135
|
+
static VALUE createJoyButtonDownEvent(SDL_Event *event)
|
136
|
+
{
|
137
|
+
VALUE obj=rb_obj_alloc(cJoyButtonDownEvent);
|
138
|
+
return createJoyButtonEvent(obj,event);
|
139
|
+
}
|
140
|
+
|
141
|
+
static VALUE createQuitEvent(SDL_Event *event)
|
142
|
+
{
|
143
|
+
VALUE obj=rb_obj_alloc(cQuitEvent);
|
144
|
+
return obj;
|
145
|
+
}
|
146
|
+
|
147
|
+
static VALUE createSysWMEvent(SDL_Event *event)
|
148
|
+
{
|
149
|
+
VALUE obj=rb_obj_alloc(cSysWMEvent);
|
150
|
+
return obj;
|
151
|
+
}
|
152
|
+
|
153
|
+
static VALUE createVideoResizeEvent(SDL_Event *event)
|
154
|
+
{
|
155
|
+
VALUE obj=rb_obj_alloc(cVideoResizeEvent);
|
156
|
+
rb_iv_set(obj,"@w",INT2FIX(event->resize.w));
|
157
|
+
rb_iv_set(obj,"@h",INT2FIX(event->resize.h));
|
158
|
+
return obj;
|
159
|
+
}
|
160
|
+
|
161
|
+
static VALUE createVideoExposeEvent(SDL_Event *event)
|
162
|
+
{
|
163
|
+
return rb_obj_alloc(cVideoExposeEvent);
|
164
|
+
}
|
165
|
+
|
166
|
+
static VALUE sdl_event2_poll(VALUE class)
|
167
|
+
{
|
168
|
+
SDL_Event event;
|
169
|
+
if( SDL_PollEvent(&event)==1)
|
170
|
+
return createEventObj[event.type](&event);
|
171
|
+
else
|
172
|
+
return Qnil;
|
173
|
+
}
|
174
|
+
static VALUE sdl_event2_wait(VALUE class)
|
175
|
+
{
|
176
|
+
SDL_Event event;
|
177
|
+
if( SDL_WaitEvent(&event)==1)
|
178
|
+
return createEventObj[event.type](&event);
|
179
|
+
else
|
180
|
+
rb_raise(eSDLError,"Event handling error");
|
181
|
+
}
|
182
|
+
static VALUE sdl_event2_pump(VALUE class)
|
183
|
+
{
|
184
|
+
SDL_PumpEvents();
|
185
|
+
return Qnil;
|
186
|
+
}
|
187
|
+
|
188
|
+
static VALUE sdl_event2_new(VALUE class)
|
189
|
+
{
|
190
|
+
return rb_obj_alloc(class);
|
191
|
+
}
|
192
|
+
|
193
|
+
static VALUE sdl_event2_push(VALUE class,VALUE event)
|
194
|
+
{
|
195
|
+
SDL_Event e;
|
196
|
+
VALUE eventClass=CLASS_OF(event);
|
197
|
+
if(eventClass==cActiveEvent){
|
198
|
+
e.type=SDL_ACTIVEEVENT;
|
199
|
+
e.active.gain=rb_iv_get(event,"@gain");
|
200
|
+
e.active.state=NUM2INT(rb_iv_get(event,"@state"));
|
201
|
+
}else if(eventClass==cKeyDownEvent){
|
202
|
+
e.type=SDL_KEYDOWN;
|
203
|
+
e.key.state=(rb_iv_get(event,"@press"))?SDL_PRESSED:SDL_RELEASED;
|
204
|
+
e.key.keysym.sym=NUM2INT(rb_iv_get(event,"@sym"));
|
205
|
+
e.key.keysym.mod=NUM2UINT(rb_iv_get(event,"@mod"));
|
206
|
+
e.key.keysym.unicode = NUM2UINT( rb_iv_get(event,"@unicode") );
|
207
|
+
}else if(eventClass==cKeyUpEvent){
|
208
|
+
e.type=SDL_KEYUP;
|
209
|
+
e.key.state=(rb_iv_get(event,"@press"))?SDL_PRESSED:SDL_RELEASED;
|
210
|
+
e.key.keysym.sym=NUM2INT(rb_iv_get(event,"@sym"));
|
211
|
+
e.key.keysym.mod=NUM2UINT(rb_iv_get(event,"@mod"));
|
212
|
+
e.key.keysym.unicode = NUM2UINT( rb_iv_get(event,"@unicode") );
|
213
|
+
}else if(eventClass==cMouseMotionEvent){
|
214
|
+
e.type=SDL_MOUSEMOTION;
|
215
|
+
e.motion.state=NUM2INT(rb_iv_get(event,"@state"));
|
216
|
+
e.motion.x=NUM2INT(rb_iv_get(event,"@x"));
|
217
|
+
e.motion.y=NUM2INT(rb_iv_get(event,"@y"));
|
218
|
+
e.motion.xrel=NUM2INT(rb_iv_get(event,"@xrel"));
|
219
|
+
e.motion.yrel=NUM2INT(rb_iv_get(event,"@yrel"));
|
220
|
+
}else if(eventClass==cMouseButtonDownEvent){
|
221
|
+
e.type=SDL_MOUSEBUTTONDOWN;
|
222
|
+
e.button.button=NUM2INT(rb_iv_get(event,"@button"));
|
223
|
+
e.button.state=(rb_iv_get(event,"@press"))?SDL_PRESSED:SDL_RELEASED;
|
224
|
+
e.button.x=NUM2INT(rb_iv_get(event,"@x"));
|
225
|
+
e.button.y=NUM2INT(rb_iv_get(event,"@y"));
|
226
|
+
}else if(eventClass==cMouseButtonUpEvent){
|
227
|
+
e.type=SDL_MOUSEBUTTONUP;
|
228
|
+
e.button.button=NUM2INT(rb_iv_get(event,"@button"));
|
229
|
+
e.button.state=(rb_iv_get(event,"@press"))?SDL_PRESSED:SDL_RELEASED;
|
230
|
+
e.button.x=NUM2INT(rb_iv_get(event,"@x"));
|
231
|
+
e.button.y=NUM2INT(rb_iv_get(event,"@y"));\
|
232
|
+
}else if(eventClass==cJoyAxisEvent){
|
233
|
+
e.type=SDL_JOYAXISMOTION;
|
234
|
+
e.jaxis.which=NUM2INT(rb_iv_get(event,"@which"));
|
235
|
+
e.jaxis.axis=NUM2INT(rb_iv_get(event,"@axis"));
|
236
|
+
e.jaxis.value=NUM2INT(rb_iv_get(event,"@value"));
|
237
|
+
}else if(eventClass==cJoyBallEvent){
|
238
|
+
e.type=SDL_JOYBALLMOTION;
|
239
|
+
e.jball.which=NUM2INT(rb_iv_get(event,"@which"));
|
240
|
+
e.jball.ball=NUM2INT(rb_iv_get(event,"@ball"));
|
241
|
+
e.jball.xrel=NUM2INT(rb_iv_get(event,"@xrel"));
|
242
|
+
e.jball.yrel=NUM2INT(rb_iv_get(event,"@yrel"));
|
243
|
+
}else if(eventClass==cJoyHatEvent){
|
244
|
+
e.type=SDL_JOYHATMOTION;
|
245
|
+
e.jhat.which=NUM2INT(rb_iv_get(event,"@which"));
|
246
|
+
e.jhat.hat=NUM2INT(rb_iv_get(event,"@hat"));
|
247
|
+
e.jhat.value=NUM2INT(rb_iv_get(event,"@value"));
|
248
|
+
}else if(eventClass==cJoyButtonUpEvent){
|
249
|
+
e.type=SDL_JOYBUTTONUP;
|
250
|
+
e.jbutton.which=NUM2INT(rb_iv_get(event,"@which"));
|
251
|
+
e.jbutton.button=NUM2INT(rb_iv_get(event,"@button"));
|
252
|
+
e.jbutton.state=(rb_iv_get(event,"@press"))?SDL_PRESSED:SDL_RELEASED;
|
253
|
+
}else if(eventClass==cJoyButtonDownEvent){
|
254
|
+
e.type=SDL_JOYBUTTONDOWN;
|
255
|
+
e.jbutton.which=NUM2INT(rb_iv_get(event,"@which"));
|
256
|
+
e.jbutton.button=NUM2INT(rb_iv_get(event,"@button"));
|
257
|
+
e.jbutton.state=(rb_iv_get(event,"@press"))?SDL_PRESSED:SDL_RELEASED;
|
258
|
+
}else if(eventClass==cQuitEvent){
|
259
|
+
e.type=SDL_QUIT;
|
260
|
+
}else if(eventClass==cSysWMEvent){
|
261
|
+
e.type=SDL_SYSWMEVENT;
|
262
|
+
}else if(eventClass==cVideoResizeEvent){
|
263
|
+
e.type=SDL_VIDEORESIZE;
|
264
|
+
e.resize.w=NUM2INT(rb_iv_get(event,"@w"));
|
265
|
+
e.resize.h=NUM2INT(rb_iv_get(event,"@h"));
|
266
|
+
}else if(eventClass==cVideoExposeEvent){
|
267
|
+
e.type=SDL_VIDEOEXPOSE;
|
268
|
+
}else {
|
269
|
+
rb_raise(eSDLError,"This object couldn't be pushed");
|
270
|
+
}
|
271
|
+
if(SDL_PushEvent(&e)==-1)
|
272
|
+
rb_raise(eSDLError,"the event couldn't be pushed");
|
273
|
+
return Qnil;
|
274
|
+
}
|
275
|
+
static VALUE sdl_event2_getAppState(VALUE class)
|
276
|
+
{
|
277
|
+
return INT2FIX(SDL_GetAppState());
|
278
|
+
}
|
279
|
+
|
280
|
+
static VALUE sdl_event2_enableUNICODE(VALUE class)
|
281
|
+
{
|
282
|
+
SDL_EnableUNICODE(1);
|
283
|
+
return Qnil;
|
284
|
+
}
|
285
|
+
static VALUE sdl_event2_disableUNICODE(VALUE class)
|
286
|
+
{
|
287
|
+
SDL_EnableUNICODE(0);
|
288
|
+
return Qnil;
|
289
|
+
}
|
290
|
+
static VALUE sdl_event2_is_enableUNICODE(VALUE class)
|
291
|
+
{
|
292
|
+
return BOOL(SDL_EnableUNICODE(-1));
|
293
|
+
}
|
294
|
+
|
295
|
+
void init_event2(void)
|
296
|
+
{
|
297
|
+
int i;
|
298
|
+
|
299
|
+
cEvent2=rb_define_class_under(mSDL,"Event2",rb_cObject);
|
300
|
+
rb_define_singleton_method(cEvent2,"poll",sdl_event2_poll,0);
|
301
|
+
rb_define_singleton_method(cEvent2,"wait",sdl_event2_wait,0);
|
302
|
+
rb_define_singleton_method(cEvent2, "pump",sdl_event2_pump, 0);
|
303
|
+
/*rb_define_attr(cEvent2,"type",1,0);*/
|
304
|
+
rb_define_singleton_method(cEvent2,"new",sdl_event2_new,0);
|
305
|
+
rb_define_singleton_method(cEvent2,"push",sdl_event2_push,1);
|
306
|
+
rb_define_singleton_method(cEvent2,"appState",sdl_event2_getAppState,0);
|
307
|
+
rb_define_singleton_method(cEvent2,"enableUNICODE",sdl_event2_enableUNICODE,0);
|
308
|
+
rb_define_singleton_method(cEvent2,"disableUNICODE",sdl_event2_disableUNICODE,0);
|
309
|
+
rb_define_singleton_method(cEvent2,"enableUNICODE?",sdl_event2_is_enableUNICODE,0);
|
310
|
+
cActiveEvent=rb_define_class_under(cEvent2,"Active",cEvent2);
|
311
|
+
rb_define_attr(cActiveEvent,"gain",1,1);
|
312
|
+
rb_define_attr(cActiveEvent,"state",1,1);
|
313
|
+
|
314
|
+
cKeyDownEvent=rb_define_class_under(cEvent2,"KeyDown",cEvent2);
|
315
|
+
rb_define_attr(cKeyDownEvent,"press",1,1);
|
316
|
+
rb_define_attr(cKeyDownEvent,"sym",1,1);
|
317
|
+
rb_define_attr(cKeyDownEvent,"mod",1,1);
|
318
|
+
rb_define_attr(cKeyDownEvent,"unicode",1,1);
|
319
|
+
|
320
|
+
cKeyUpEvent=rb_define_class_under(cEvent2,"KeyUp",cEvent2);
|
321
|
+
rb_define_attr(cKeyUpEvent,"press",1,1);
|
322
|
+
rb_define_attr(cKeyUpEvent,"sym",1,1);
|
323
|
+
rb_define_attr(cKeyUpEvent,"mod",1,1);
|
324
|
+
rb_define_attr(cKeyUpEvent,"unicode",1,1);
|
325
|
+
|
326
|
+
cMouseMotionEvent=rb_define_class_under(cEvent2,"MouseMotion",cEvent2);
|
327
|
+
rb_define_attr(cMouseMotionEvent,"state",1,1);
|
328
|
+
rb_define_attr(cMouseMotionEvent,"x",1,1);
|
329
|
+
rb_define_attr(cMouseMotionEvent,"y",1,1);
|
330
|
+
rb_define_attr(cMouseMotionEvent,"xrel",1,1);
|
331
|
+
rb_define_attr(cMouseMotionEvent,"yrel",1,1);
|
332
|
+
|
333
|
+
cMouseButtonDownEvent=rb_define_class_under(cEvent2,"MouseButtonDown",cEvent2);
|
334
|
+
rb_define_attr(cMouseButtonDownEvent,"button",1,1);
|
335
|
+
rb_define_attr(cMouseButtonDownEvent,"press",1,1);
|
336
|
+
rb_define_attr(cMouseButtonDownEvent,"x",1,1);
|
337
|
+
rb_define_attr(cMouseButtonDownEvent,"y",1,1);
|
338
|
+
|
339
|
+
cMouseButtonUpEvent=rb_define_class_under(cEvent2,"MouseButtonUp",cEvent2);
|
340
|
+
rb_define_attr(cMouseButtonUpEvent,"button",1,1);
|
341
|
+
rb_define_attr(cMouseButtonUpEvent,"press",1,1);
|
342
|
+
rb_define_attr(cMouseButtonUpEvent,"x",1,1);
|
343
|
+
rb_define_attr(cMouseButtonUpEvent,"y",1,1);
|
344
|
+
|
345
|
+
cJoyAxisEvent=rb_define_class_under(cEvent2,"JoyAxis",cEvent2);
|
346
|
+
rb_define_attr(cJoyAxisEvent,"which",1,1);
|
347
|
+
rb_define_attr(cJoyAxisEvent,"axis",1,1);
|
348
|
+
rb_define_attr(cJoyAxisEvent,"value",1,1);
|
349
|
+
|
350
|
+
cJoyBallEvent=rb_define_class_under(cEvent2,"JoyBall",cEvent2);
|
351
|
+
rb_define_attr(cJoyBallEvent,"which",1,1);
|
352
|
+
rb_define_attr(cJoyBallEvent,"ball",1,1);
|
353
|
+
rb_define_attr(cJoyBallEvent,"xrel",1,1);
|
354
|
+
rb_define_attr(cJoyBallEvent,"yrel",1,1);
|
355
|
+
|
356
|
+
cJoyHatEvent=rb_define_class_under(cEvent2,"JoyHat",cEvent2);
|
357
|
+
rb_define_attr(cJoyHatEvent,"which",1,1);
|
358
|
+
rb_define_attr(cJoyHatEvent,"hat",1,1);
|
359
|
+
rb_define_attr(cJoyHatEvent,"value",1,1);
|
360
|
+
|
361
|
+
cJoyButtonUpEvent=rb_define_class_under(cEvent2,"JoyButtonUp",cEvent2);
|
362
|
+
rb_define_attr(cJoyButtonUpEvent,"which",1,1);
|
363
|
+
rb_define_attr(cJoyButtonUpEvent,"button",1,1);
|
364
|
+
rb_define_attr(cJoyButtonUpEvent,"press",1,1);
|
365
|
+
|
366
|
+
cJoyButtonDownEvent=rb_define_class_under(cEvent2,"JoyButtonDown",cEvent2);
|
367
|
+
rb_define_attr(cJoyButtonDownEvent,"which",1,1);
|
368
|
+
rb_define_attr(cJoyButtonDownEvent,"button",1,1);
|
369
|
+
rb_define_attr(cJoyButtonDownEvent,"press",1,1);
|
370
|
+
|
371
|
+
cQuitEvent=rb_define_class_under(cEvent2,"Quit",cEvent2);
|
372
|
+
|
373
|
+
cSysWMEvent=rb_define_class_under(cEvent2,"SysWM",cEvent2);
|
374
|
+
|
375
|
+
cVideoResizeEvent=rb_define_class_under(cEvent2,"VideoResize",cEvent2);
|
376
|
+
rb_define_attr(cVideoResizeEvent,"w",1,1);
|
377
|
+
rb_define_attr(cVideoResizeEvent,"h",1,1);
|
378
|
+
|
379
|
+
cVideoExposeEvent=rb_define_class_under(cEvent2,"VideoExpose",cEvent2);
|
380
|
+
|
381
|
+
for(i=0;i<SDL_NUMEVENTS;++i)
|
382
|
+
createEventObj[i]=createNoEvent;
|
383
|
+
createEventObj[SDL_ACTIVEEVENT]=createActiveEvent;
|
384
|
+
createEventObj[SDL_KEYDOWN]=createKeyDownEvent;
|
385
|
+
createEventObj[SDL_KEYUP]=createKeyUpEvent;
|
386
|
+
createEventObj[SDL_MOUSEMOTION]=createMouseMotionEvent;
|
387
|
+
createEventObj[SDL_MOUSEBUTTONDOWN]=createMouseButtonDownEvent;
|
388
|
+
createEventObj[SDL_MOUSEBUTTONUP]=createMouseButtonUpEvent;
|
389
|
+
createEventObj[SDL_JOYAXISMOTION]=createJoyAxisEvent;
|
390
|
+
createEventObj[SDL_JOYBALLMOTION]=createJoyBallEvent;
|
391
|
+
createEventObj[SDL_JOYHATMOTION]=createJoyHatEvent;
|
392
|
+
createEventObj[SDL_JOYBUTTONDOWN]=createJoyButtonDownEvent;
|
393
|
+
createEventObj[SDL_JOYBUTTONUP]=createJoyButtonUpEvent;
|
394
|
+
createEventObj[SDL_QUIT]=createQuitEvent;
|
395
|
+
createEventObj[SDL_SYSWMEVENT]=createSysWMEvent;
|
396
|
+
createEventObj[SDL_VIDEORESIZE]=createVideoResizeEvent;
|
397
|
+
createEventObj[SDL_VIDEOEXPOSE]=createVideoExposeEvent;
|
398
|
+
|
399
|
+
}
|
400
|
+
/*
|
401
|
+
Active;
|
402
|
+
KeyDown;
|
403
|
+
KeyUp;
|
404
|
+
MouseMotion;
|
405
|
+
MouseButtonDown;
|
406
|
+
MouseButtonUp;
|
407
|
+
JoyAxis;
|
408
|
+
JoyBall;
|
409
|
+
JoyHat;
|
410
|
+
JoyButtonUp;
|
411
|
+
JoyButtonDown;
|
412
|
+
Quit;
|
413
|
+
SysWM;
|
414
|
+
VideoResize;
|
415
|
+
*/
|
416
|
+
|
417
|
+
#endif /* DEF_EVENT2 */
|