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_key.c
ADDED
@@ -0,0 +1,356 @@
|
|
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
|
+
static Uint8 *keyState;
|
23
|
+
static SDLMod modState;
|
24
|
+
|
25
|
+
void defineConstForKey()
|
26
|
+
{
|
27
|
+
rb_define_const(mKey,"UNKNOWN",INT2NUM(SDLK_UNKNOWN));
|
28
|
+
rb_define_const(mKey,"FIRST",INT2NUM(SDLK_FIRST));
|
29
|
+
rb_define_const(mKey,"BACKSPACE",INT2NUM(SDLK_BACKSPACE));
|
30
|
+
rb_define_const(mKey,"TAB",INT2NUM(SDLK_TAB));
|
31
|
+
rb_define_const(mKey,"CLEAR",INT2NUM(SDLK_CLEAR));
|
32
|
+
rb_define_const(mKey,"RETURN",INT2NUM(SDLK_RETURN));
|
33
|
+
rb_define_const(mKey,"PAUSE",INT2NUM(SDLK_PAUSE));
|
34
|
+
rb_define_const(mKey,"ESCAPE",INT2NUM(SDLK_ESCAPE));
|
35
|
+
rb_define_const(mKey,"SPACE",INT2NUM(SDLK_SPACE));
|
36
|
+
rb_define_const(mKey,"EXCLAIM",INT2NUM(SDLK_EXCLAIM));
|
37
|
+
rb_define_const(mKey,"QUOTEDBL",INT2NUM(SDLK_QUOTEDBL));
|
38
|
+
rb_define_const(mKey,"HASH",INT2NUM(SDLK_HASH));
|
39
|
+
rb_define_const(mKey,"DOLLAR",INT2NUM(SDLK_DOLLAR));
|
40
|
+
rb_define_const(mKey,"AMPERSAND",INT2NUM(SDLK_AMPERSAND));
|
41
|
+
rb_define_const(mKey,"QUOTE",INT2NUM(SDLK_QUOTE));
|
42
|
+
rb_define_const(mKey,"LEFTPAREN",INT2NUM(SDLK_LEFTPAREN));
|
43
|
+
rb_define_const(mKey,"RIGHTPAREN",INT2NUM(SDLK_RIGHTPAREN));
|
44
|
+
rb_define_const(mKey,"ASTERISK",INT2NUM(SDLK_ASTERISK));
|
45
|
+
rb_define_const(mKey,"PLUS",INT2NUM(SDLK_PLUS));
|
46
|
+
rb_define_const(mKey,"COMMA",INT2NUM(SDLK_COMMA));
|
47
|
+
rb_define_const(mKey,"MINUS",INT2NUM(SDLK_MINUS));
|
48
|
+
rb_define_const(mKey,"PERIOD",INT2NUM(SDLK_PERIOD));
|
49
|
+
rb_define_const(mKey,"SLASH",INT2NUM(SDLK_SLASH));
|
50
|
+
rb_define_const(mKey,"K0",INT2NUM(SDLK_0));
|
51
|
+
rb_define_const(mKey,"K1",INT2NUM(SDLK_1));
|
52
|
+
rb_define_const(mKey,"K2",INT2NUM(SDLK_2));
|
53
|
+
rb_define_const(mKey,"K3",INT2NUM(SDLK_3));
|
54
|
+
rb_define_const(mKey,"K4",INT2NUM(SDLK_4));
|
55
|
+
rb_define_const(mKey,"K5",INT2NUM(SDLK_5));
|
56
|
+
rb_define_const(mKey,"K6",INT2NUM(SDLK_6));
|
57
|
+
rb_define_const(mKey,"K7",INT2NUM(SDLK_7));
|
58
|
+
rb_define_const(mKey,"K8",INT2NUM(SDLK_8));
|
59
|
+
rb_define_const(mKey,"K9",INT2NUM(SDLK_9));
|
60
|
+
rb_define_const(mKey,"COLON",INT2NUM(SDLK_COLON));
|
61
|
+
rb_define_const(mKey,"SEMICOLON",INT2NUM(SDLK_SEMICOLON));
|
62
|
+
rb_define_const(mKey,"LESS",INT2NUM(SDLK_LESS));
|
63
|
+
rb_define_const(mKey,"EQUALS",INT2NUM(SDLK_EQUALS));
|
64
|
+
rb_define_const(mKey,"GREATER",INT2NUM(SDLK_GREATER));
|
65
|
+
rb_define_const(mKey,"QUESTION",INT2NUM(SDLK_QUESTION));
|
66
|
+
rb_define_const(mKey,"AT",INT2NUM(SDLK_AT));
|
67
|
+
/*
|
68
|
+
Skip uppercase letters
|
69
|
+
*/
|
70
|
+
rb_define_const(mKey,"LEFTBRACKET",INT2NUM(SDLK_LEFTBRACKET));
|
71
|
+
rb_define_const(mKey,"BACKSLASH",INT2NUM(SDLK_BACKSLASH));
|
72
|
+
rb_define_const(mKey,"RIGHTBRACKET",INT2NUM(SDLK_RIGHTBRACKET));
|
73
|
+
rb_define_const(mKey,"CARET",INT2NUM(SDLK_CARET));
|
74
|
+
rb_define_const(mKey,"UNDERSCORE",INT2NUM(SDLK_UNDERSCORE));
|
75
|
+
rb_define_const(mKey,"BACKQUOTE",INT2NUM(SDLK_BACKQUOTE));
|
76
|
+
rb_define_const(mKey,"A",INT2NUM(SDLK_a));
|
77
|
+
rb_define_const(mKey,"B",INT2NUM(SDLK_b));
|
78
|
+
rb_define_const(mKey,"C",INT2NUM(SDLK_c));
|
79
|
+
rb_define_const(mKey,"D",INT2NUM(SDLK_d));
|
80
|
+
rb_define_const(mKey,"E",INT2NUM(SDLK_e));
|
81
|
+
rb_define_const(mKey,"F",INT2NUM(SDLK_f));
|
82
|
+
rb_define_const(mKey,"G",INT2NUM(SDLK_g));
|
83
|
+
rb_define_const(mKey,"H",INT2NUM(SDLK_h));
|
84
|
+
rb_define_const(mKey,"I",INT2NUM(SDLK_i));
|
85
|
+
rb_define_const(mKey,"J",INT2NUM(SDLK_j));
|
86
|
+
rb_define_const(mKey,"K",INT2NUM(SDLK_k));
|
87
|
+
rb_define_const(mKey,"L",INT2NUM(SDLK_l));
|
88
|
+
rb_define_const(mKey,"M",INT2NUM(SDLK_m));
|
89
|
+
rb_define_const(mKey,"N",INT2NUM(SDLK_n));
|
90
|
+
rb_define_const(mKey,"O",INT2NUM(SDLK_o));
|
91
|
+
rb_define_const(mKey,"P",INT2NUM(SDLK_p));
|
92
|
+
rb_define_const(mKey,"Q",INT2NUM(SDLK_q));
|
93
|
+
rb_define_const(mKey,"R",INT2NUM(SDLK_r));
|
94
|
+
rb_define_const(mKey,"S",INT2NUM(SDLK_s));
|
95
|
+
rb_define_const(mKey,"T",INT2NUM(SDLK_t));
|
96
|
+
rb_define_const(mKey,"U",INT2NUM(SDLK_u));
|
97
|
+
rb_define_const(mKey,"V",INT2NUM(SDLK_v));
|
98
|
+
rb_define_const(mKey,"W",INT2NUM(SDLK_w));
|
99
|
+
rb_define_const(mKey,"X",INT2NUM(SDLK_x));
|
100
|
+
rb_define_const(mKey,"Y",INT2NUM(SDLK_y));
|
101
|
+
rb_define_const(mKey,"Z",INT2NUM(SDLK_z));
|
102
|
+
rb_define_const(mKey,"DELETE",INT2NUM(SDLK_DELETE));
|
103
|
+
/* End of ASCII mapped keysyms */
|
104
|
+
|
105
|
+
/* International keyboard syms */
|
106
|
+
rb_define_const(mKey,"WORLD_0",INT2NUM(SDLK_WORLD_0));
|
107
|
+
rb_define_const(mKey,"WORLD_1",INT2NUM(SDLK_WORLD_1));
|
108
|
+
rb_define_const(mKey,"WORLD_2",INT2NUM(SDLK_WORLD_2));
|
109
|
+
rb_define_const(mKey,"WORLD_3",INT2NUM(SDLK_WORLD_3));
|
110
|
+
rb_define_const(mKey,"WORLD_4",INT2NUM(SDLK_WORLD_4));
|
111
|
+
rb_define_const(mKey,"WORLD_5",INT2NUM(SDLK_WORLD_5));
|
112
|
+
rb_define_const(mKey,"WORLD_6",INT2NUM(SDLK_WORLD_6));
|
113
|
+
rb_define_const(mKey,"WORLD_7",INT2NUM(SDLK_WORLD_7));
|
114
|
+
rb_define_const(mKey,"WORLD_8",INT2NUM(SDLK_WORLD_8));
|
115
|
+
rb_define_const(mKey,"WORLD_9",INT2NUM(SDLK_WORLD_9));
|
116
|
+
rb_define_const(mKey,"WORLD_10",INT2NUM(SDLK_WORLD_10));
|
117
|
+
rb_define_const(mKey,"WORLD_11",INT2NUM(SDLK_WORLD_11));
|
118
|
+
rb_define_const(mKey,"WORLD_12",INT2NUM(SDLK_WORLD_12));
|
119
|
+
rb_define_const(mKey,"WORLD_13",INT2NUM(SDLK_WORLD_13));
|
120
|
+
rb_define_const(mKey,"WORLD_14",INT2NUM(SDLK_WORLD_14));
|
121
|
+
rb_define_const(mKey,"WORLD_15",INT2NUM(SDLK_WORLD_15));
|
122
|
+
rb_define_const(mKey,"WORLD_16",INT2NUM(SDLK_WORLD_16));
|
123
|
+
rb_define_const(mKey,"WORLD_17",INT2NUM(SDLK_WORLD_17));
|
124
|
+
rb_define_const(mKey,"WORLD_18",INT2NUM(SDLK_WORLD_18));
|
125
|
+
rb_define_const(mKey,"WORLD_19",INT2NUM(SDLK_WORLD_19));
|
126
|
+
rb_define_const(mKey,"WORLD_20",INT2NUM(SDLK_WORLD_20));
|
127
|
+
rb_define_const(mKey,"WORLD_21",INT2NUM(SDLK_WORLD_21));
|
128
|
+
rb_define_const(mKey,"WORLD_22",INT2NUM(SDLK_WORLD_22));
|
129
|
+
rb_define_const(mKey,"WORLD_23",INT2NUM(SDLK_WORLD_23));
|
130
|
+
rb_define_const(mKey,"WORLD_24",INT2NUM(SDLK_WORLD_24));
|
131
|
+
rb_define_const(mKey,"WORLD_25",INT2NUM(SDLK_WORLD_25));
|
132
|
+
rb_define_const(mKey,"WORLD_26",INT2NUM(SDLK_WORLD_26));
|
133
|
+
rb_define_const(mKey,"WORLD_27",INT2NUM(SDLK_WORLD_27));
|
134
|
+
rb_define_const(mKey,"WORLD_28",INT2NUM(SDLK_WORLD_28));
|
135
|
+
rb_define_const(mKey,"WORLD_29",INT2NUM(SDLK_WORLD_29));
|
136
|
+
rb_define_const(mKey,"WORLD_30",INT2NUM(SDLK_WORLD_30));
|
137
|
+
rb_define_const(mKey,"WORLD_31",INT2NUM(SDLK_WORLD_31));
|
138
|
+
rb_define_const(mKey,"WORLD_32",INT2NUM(SDLK_WORLD_32));
|
139
|
+
rb_define_const(mKey,"WORLD_33",INT2NUM(SDLK_WORLD_33));
|
140
|
+
rb_define_const(mKey,"WORLD_34",INT2NUM(SDLK_WORLD_34));
|
141
|
+
rb_define_const(mKey,"WORLD_35",INT2NUM(SDLK_WORLD_35));
|
142
|
+
rb_define_const(mKey,"WORLD_36",INT2NUM(SDLK_WORLD_36));
|
143
|
+
rb_define_const(mKey,"WORLD_37",INT2NUM(SDLK_WORLD_37));
|
144
|
+
rb_define_const(mKey,"WORLD_38",INT2NUM(SDLK_WORLD_38));
|
145
|
+
rb_define_const(mKey,"WORLD_39",INT2NUM(SDLK_WORLD_39));
|
146
|
+
rb_define_const(mKey,"WORLD_40",INT2NUM(SDLK_WORLD_40));
|
147
|
+
rb_define_const(mKey,"WORLD_41",INT2NUM(SDLK_WORLD_41));
|
148
|
+
rb_define_const(mKey,"WORLD_42",INT2NUM(SDLK_WORLD_42));
|
149
|
+
rb_define_const(mKey,"WORLD_43",INT2NUM(SDLK_WORLD_43));
|
150
|
+
rb_define_const(mKey,"WORLD_44",INT2NUM(SDLK_WORLD_44));
|
151
|
+
rb_define_const(mKey,"WORLD_45",INT2NUM(SDLK_WORLD_45));
|
152
|
+
rb_define_const(mKey,"WORLD_46",INT2NUM(SDLK_WORLD_46));
|
153
|
+
rb_define_const(mKey,"WORLD_47",INT2NUM(SDLK_WORLD_47));
|
154
|
+
rb_define_const(mKey,"WORLD_48",INT2NUM(SDLK_WORLD_48));
|
155
|
+
rb_define_const(mKey,"WORLD_49",INT2NUM(SDLK_WORLD_49));
|
156
|
+
rb_define_const(mKey,"WORLD_50",INT2NUM(SDLK_WORLD_50));
|
157
|
+
rb_define_const(mKey,"WORLD_51",INT2NUM(SDLK_WORLD_51));
|
158
|
+
rb_define_const(mKey,"WORLD_52",INT2NUM(SDLK_WORLD_52));
|
159
|
+
rb_define_const(mKey,"WORLD_53",INT2NUM(SDLK_WORLD_53));
|
160
|
+
rb_define_const(mKey,"WORLD_54",INT2NUM(SDLK_WORLD_54));
|
161
|
+
rb_define_const(mKey,"WORLD_55",INT2NUM(SDLK_WORLD_55));
|
162
|
+
rb_define_const(mKey,"WORLD_56",INT2NUM(SDLK_WORLD_56));
|
163
|
+
rb_define_const(mKey,"WORLD_57",INT2NUM(SDLK_WORLD_57));
|
164
|
+
rb_define_const(mKey,"WORLD_58",INT2NUM(SDLK_WORLD_58));
|
165
|
+
rb_define_const(mKey,"WORLD_59",INT2NUM(SDLK_WORLD_59));
|
166
|
+
rb_define_const(mKey,"WORLD_60",INT2NUM(SDLK_WORLD_60));
|
167
|
+
rb_define_const(mKey,"WORLD_61",INT2NUM(SDLK_WORLD_61));
|
168
|
+
rb_define_const(mKey,"WORLD_62",INT2NUM(SDLK_WORLD_62));
|
169
|
+
rb_define_const(mKey,"WORLD_63",INT2NUM(SDLK_WORLD_63));
|
170
|
+
rb_define_const(mKey,"WORLD_64",INT2NUM(SDLK_WORLD_64));
|
171
|
+
rb_define_const(mKey,"WORLD_65",INT2NUM(SDLK_WORLD_65));
|
172
|
+
rb_define_const(mKey,"WORLD_66",INT2NUM(SDLK_WORLD_66));
|
173
|
+
rb_define_const(mKey,"WORLD_67",INT2NUM(SDLK_WORLD_67));
|
174
|
+
rb_define_const(mKey,"WORLD_68",INT2NUM(SDLK_WORLD_68));
|
175
|
+
rb_define_const(mKey,"WORLD_69",INT2NUM(SDLK_WORLD_69));
|
176
|
+
rb_define_const(mKey,"WORLD_70",INT2NUM(SDLK_WORLD_70));
|
177
|
+
rb_define_const(mKey,"WORLD_71",INT2NUM(SDLK_WORLD_71));
|
178
|
+
rb_define_const(mKey,"WORLD_72",INT2NUM(SDLK_WORLD_72));
|
179
|
+
rb_define_const(mKey,"WORLD_73",INT2NUM(SDLK_WORLD_73));
|
180
|
+
rb_define_const(mKey,"WORLD_74",INT2NUM(SDLK_WORLD_74));
|
181
|
+
rb_define_const(mKey,"WORLD_75",INT2NUM(SDLK_WORLD_75));
|
182
|
+
rb_define_const(mKey,"WORLD_76",INT2NUM(SDLK_WORLD_76));
|
183
|
+
rb_define_const(mKey,"WORLD_77",INT2NUM(SDLK_WORLD_77));
|
184
|
+
rb_define_const(mKey,"WORLD_78",INT2NUM(SDLK_WORLD_78));
|
185
|
+
rb_define_const(mKey,"WORLD_79",INT2NUM(SDLK_WORLD_79));
|
186
|
+
rb_define_const(mKey,"WORLD_80",INT2NUM(SDLK_WORLD_80));
|
187
|
+
rb_define_const(mKey,"WORLD_81",INT2NUM(SDLK_WORLD_81));
|
188
|
+
rb_define_const(mKey,"WORLD_82",INT2NUM(SDLK_WORLD_82));
|
189
|
+
rb_define_const(mKey,"WORLD_83",INT2NUM(SDLK_WORLD_83));
|
190
|
+
rb_define_const(mKey,"WORLD_84",INT2NUM(SDLK_WORLD_84));
|
191
|
+
rb_define_const(mKey,"WORLD_85",INT2NUM(SDLK_WORLD_85));
|
192
|
+
rb_define_const(mKey,"WORLD_86",INT2NUM(SDLK_WORLD_86));
|
193
|
+
rb_define_const(mKey,"WORLD_87",INT2NUM(SDLK_WORLD_87));
|
194
|
+
rb_define_const(mKey,"WORLD_88",INT2NUM(SDLK_WORLD_88));
|
195
|
+
rb_define_const(mKey,"WORLD_89",INT2NUM(SDLK_WORLD_89));
|
196
|
+
rb_define_const(mKey,"WORLD_90",INT2NUM(SDLK_WORLD_90));
|
197
|
+
rb_define_const(mKey,"WORLD_91",INT2NUM(SDLK_WORLD_91));
|
198
|
+
rb_define_const(mKey,"WORLD_92",INT2NUM(SDLK_WORLD_92));
|
199
|
+
rb_define_const(mKey,"WORLD_93",INT2NUM(SDLK_WORLD_93));
|
200
|
+
rb_define_const(mKey,"WORLD_94",INT2NUM(SDLK_WORLD_94));
|
201
|
+
rb_define_const(mKey,"WORLD_95",INT2NUM(SDLK_WORLD_95));
|
202
|
+
|
203
|
+
|
204
|
+
/* Numeric keypad */
|
205
|
+
rb_define_const(mKey,"KP0",INT2NUM(SDLK_KP0));
|
206
|
+
rb_define_const(mKey,"KP1",INT2NUM(SDLK_KP1));
|
207
|
+
rb_define_const(mKey,"KP2",INT2NUM(SDLK_KP2));
|
208
|
+
rb_define_const(mKey,"KP3",INT2NUM(SDLK_KP3));
|
209
|
+
rb_define_const(mKey,"KP4",INT2NUM(SDLK_KP4));
|
210
|
+
rb_define_const(mKey,"KP5",INT2NUM(SDLK_KP5));
|
211
|
+
rb_define_const(mKey,"KP6",INT2NUM(SDLK_KP6));
|
212
|
+
rb_define_const(mKey,"KP7",INT2NUM(SDLK_KP7));
|
213
|
+
rb_define_const(mKey,"KP8",INT2NUM(SDLK_KP8));
|
214
|
+
rb_define_const(mKey,"KP9",INT2NUM(SDLK_KP9));
|
215
|
+
rb_define_const(mKey,"KP_PERIOD",INT2NUM(SDLK_KP_PERIOD));
|
216
|
+
rb_define_const(mKey,"KP_DIVIDE",INT2NUM(SDLK_KP_DIVIDE));
|
217
|
+
rb_define_const(mKey,"KP_MULTIPLY",INT2NUM(SDLK_KP_MULTIPLY));
|
218
|
+
rb_define_const(mKey,"KP_MINUS",INT2NUM(SDLK_KP_MINUS));
|
219
|
+
rb_define_const(mKey,"KP_PLUS",INT2NUM(SDLK_KP_PLUS));
|
220
|
+
rb_define_const(mKey,"KP_ENTER",INT2NUM(SDLK_KP_ENTER));
|
221
|
+
rb_define_const(mKey,"KP_EQUALS",INT2NUM(SDLK_KP_EQUALS));
|
222
|
+
|
223
|
+
/* Arrows + Home/End pad */
|
224
|
+
rb_define_const(mKey,"UP",INT2NUM(SDLK_UP));
|
225
|
+
rb_define_const(mKey,"DOWN",INT2NUM(SDLK_DOWN));
|
226
|
+
rb_define_const(mKey,"RIGHT",INT2NUM(SDLK_RIGHT));
|
227
|
+
rb_define_const(mKey,"LEFT",INT2NUM(SDLK_LEFT));
|
228
|
+
rb_define_const(mKey,"INSERT",INT2NUM(SDLK_INSERT));
|
229
|
+
rb_define_const(mKey,"HOME",INT2NUM(SDLK_HOME));
|
230
|
+
rb_define_const(mKey,"END",INT2NUM(SDLK_END));
|
231
|
+
rb_define_const(mKey,"PAGEUP",INT2NUM(SDLK_PAGEUP));
|
232
|
+
rb_define_const(mKey,"PAGEDOWN",INT2NUM(SDLK_PAGEDOWN));
|
233
|
+
|
234
|
+
/* Function keys */
|
235
|
+
rb_define_const(mKey,"F1",INT2NUM(SDLK_F1));
|
236
|
+
rb_define_const(mKey,"F2",INT2NUM(SDLK_F2));
|
237
|
+
rb_define_const(mKey,"F3",INT2NUM(SDLK_F3));
|
238
|
+
rb_define_const(mKey,"F4",INT2NUM(SDLK_F4));
|
239
|
+
rb_define_const(mKey,"F5",INT2NUM(SDLK_F5));
|
240
|
+
rb_define_const(mKey,"F6",INT2NUM(SDLK_F6));
|
241
|
+
rb_define_const(mKey,"F7",INT2NUM(SDLK_F7));
|
242
|
+
rb_define_const(mKey,"F8",INT2NUM(SDLK_F8));
|
243
|
+
rb_define_const(mKey,"F9",INT2NUM(SDLK_F9));
|
244
|
+
rb_define_const(mKey,"F10",INT2NUM(SDLK_F10));
|
245
|
+
rb_define_const(mKey,"F11",INT2NUM(SDLK_F11));
|
246
|
+
rb_define_const(mKey,"F12",INT2NUM(SDLK_F12));
|
247
|
+
rb_define_const(mKey,"F13",INT2NUM(SDLK_F13));
|
248
|
+
rb_define_const(mKey,"F14",INT2NUM(SDLK_F14));
|
249
|
+
rb_define_const(mKey,"F15",INT2NUM(SDLK_F15));
|
250
|
+
|
251
|
+
/* Key state modifier keys */
|
252
|
+
rb_define_const(mKey,"NUMLOCK",INT2NUM(SDLK_NUMLOCK));
|
253
|
+
rb_define_const(mKey,"CAPSLOCK",INT2NUM(SDLK_CAPSLOCK));
|
254
|
+
rb_define_const(mKey,"SCROLLOCK",INT2NUM(SDLK_SCROLLOCK));
|
255
|
+
rb_define_const(mKey,"RSHIFT",INT2NUM(SDLK_RSHIFT));
|
256
|
+
rb_define_const(mKey,"LSHIFT",INT2NUM(SDLK_LSHIFT));
|
257
|
+
rb_define_const(mKey,"RCTRL",INT2NUM(SDLK_RCTRL));
|
258
|
+
rb_define_const(mKey,"LCTRL",INT2NUM(SDLK_LCTRL));
|
259
|
+
rb_define_const(mKey,"RALT",INT2NUM(SDLK_RALT));
|
260
|
+
rb_define_const(mKey,"LALT",INT2NUM(SDLK_LALT));
|
261
|
+
rb_define_const(mKey,"RMETA",INT2NUM(SDLK_RMETA));
|
262
|
+
rb_define_const(mKey,"LMETA",INT2NUM(SDLK_LMETA));
|
263
|
+
rb_define_const(mKey,"LSUPER",INT2NUM(SDLK_LSUPER));
|
264
|
+
rb_define_const(mKey,"RSUPER",INT2NUM(SDLK_RSUPER));
|
265
|
+
rb_define_const(mKey,"MODE",INT2NUM(SDLK_MODE));
|
266
|
+
|
267
|
+
/* Miscellaneous function keys */
|
268
|
+
rb_define_const(mKey,"HELP",INT2NUM(SDLK_HELP));
|
269
|
+
rb_define_const(mKey,"PRINT",INT2NUM(SDLK_PRINT));
|
270
|
+
rb_define_const(mKey,"SYSREQ",INT2NUM(SDLK_SYSREQ));
|
271
|
+
rb_define_const(mKey,"BREAK",INT2NUM(SDLK_BREAK));
|
272
|
+
rb_define_const(mKey,"MENU",INT2NUM(SDLK_MENU));
|
273
|
+
rb_define_const(mKey,"POWER",INT2NUM(SDLK_POWER));
|
274
|
+
rb_define_const(mKey,"EURO",INT2NUM(SDLK_EURO));
|
275
|
+
|
276
|
+
/* Add any other keys here */
|
277
|
+
|
278
|
+
rb_define_const(mKey,"LAST",INT2NUM(SDLK_LAST));
|
279
|
+
|
280
|
+
/* key mods */
|
281
|
+
rb_define_const(mKey,"MOD_NONE",UINT2NUM(KMOD_NONE));
|
282
|
+
rb_define_const(mKey,"MOD_LSHIFT",UINT2NUM(KMOD_LSHIFT));
|
283
|
+
rb_define_const(mKey,"MOD_RSHIFT",UINT2NUM(KMOD_RSHIFT));
|
284
|
+
rb_define_const(mKey,"MOD_LCTRL",UINT2NUM(KMOD_LCTRL));
|
285
|
+
rb_define_const(mKey,"MOD_RCTRL",UINT2NUM(KMOD_RCTRL));
|
286
|
+
rb_define_const(mKey,"MOD_LALT",UINT2NUM(KMOD_LALT));
|
287
|
+
rb_define_const(mKey,"MOD_RALT",UINT2NUM(KMOD_RALT));
|
288
|
+
rb_define_const(mKey,"MOD_LMETA",UINT2NUM(KMOD_LMETA));
|
289
|
+
rb_define_const(mKey,"MOD_RMETA",UINT2NUM(KMOD_RMETA));
|
290
|
+
rb_define_const(mKey,"MOD_NUM",UINT2NUM(KMOD_NUM));
|
291
|
+
rb_define_const(mKey,"MOD_CAPS",UINT2NUM(KMOD_CAPS));
|
292
|
+
rb_define_const(mKey,"MOD_MODE",UINT2NUM(KMOD_MODE));
|
293
|
+
rb_define_const(mKey,"MOD_RESERVED",UINT2NUM(KMOD_RESERVED));
|
294
|
+
|
295
|
+
rb_define_const(mKey,"MOD_CTRL",UINT2NUM(KMOD_CTRL));
|
296
|
+
rb_define_const(mKey,"MOD_SHIFT",UINT2NUM(KMOD_SHIFT));
|
297
|
+
rb_define_const(mKey,"MOD_ALT",UINT2NUM(KMOD_ALT));
|
298
|
+
rb_define_const(mKey,"MOD_META",UINT2NUM(KMOD_META));
|
299
|
+
|
300
|
+
/* key repeat constants*/
|
301
|
+
rb_define_const(mKey,"DEFAULT_REPEAT_DELAY", INT2NUM(SDL_DEFAULT_REPEAT_DELAY));
|
302
|
+
rb_define_const(mKey,"DEFAULT_REPEAT_INTERVAL", INT2NUM(SDL_DEFAULT_REPEAT_INTERVAL));
|
303
|
+
|
304
|
+
}
|
305
|
+
|
306
|
+
/* under 2 function is for testing */
|
307
|
+
static VALUE sdl_keyScan(VALUE mod)
|
308
|
+
{
|
309
|
+
keyState=SDL_GetKeyState(NULL);
|
310
|
+
modState=SDL_GetModState();
|
311
|
+
return Qnil;
|
312
|
+
}
|
313
|
+
static VALUE sdl_keyPressed(VALUE mod,VALUE keysym)
|
314
|
+
{
|
315
|
+
if(NUM2INT(keysym) <SDLK_FIRST || SDLK_LAST < NUM2INT(keysym))
|
316
|
+
rb_raise(eSDLError, "keysym number is out of range");
|
317
|
+
|
318
|
+
return (keyState[NUM2INT(keysym)]==SDL_PRESSED)?Qtrue:Qfalse;
|
319
|
+
}
|
320
|
+
static VALUE sdl_modState(VALUE mod)
|
321
|
+
{
|
322
|
+
return UINT2NUM(modState);
|
323
|
+
}
|
324
|
+
static VALUE sdl_enableKeyRepeat(VALUE mod,VALUE delay,VALUE interval)
|
325
|
+
{
|
326
|
+
if( SDL_EnableKeyRepeat( NUM2INT(delay),NUM2INT(interval) )==-1 ){
|
327
|
+
rb_raise(eSDLError,"enable key repeat fail: %s",SDL_GetError());
|
328
|
+
}
|
329
|
+
return Qnil;
|
330
|
+
}
|
331
|
+
static VALUE sdl_disableKeyRepeat(VALUE mod)
|
332
|
+
{
|
333
|
+
if( SDL_EnableKeyRepeat( 0,0 )==-1 ){
|
334
|
+
rb_raise(eSDLError,"disable key repeat fail: %s",SDL_GetError());
|
335
|
+
}
|
336
|
+
return Qnil;
|
337
|
+
}
|
338
|
+
static VALUE sdl_getKeyName(VALUE mod,VALUE key)
|
339
|
+
{
|
340
|
+
return rb_str_new2( SDL_GetKeyName( NUM2UINT(key) ) );
|
341
|
+
}
|
342
|
+
void init_keyEvent()
|
343
|
+
{
|
344
|
+
mKey = rb_define_module_under(mSDL,"Key");
|
345
|
+
rb_define_module_function(mKey,"scan",sdl_keyScan,0);
|
346
|
+
rb_define_module_function(mKey,"press?",sdl_keyPressed,1);
|
347
|
+
rb_define_module_function(mKey,"modState",sdl_modState,0);
|
348
|
+
rb_define_module_function(mKey,"enableKeyRepeat",sdl_enableKeyRepeat,2);
|
349
|
+
rb_define_module_function(mKey,"disableKeyRepeat",sdl_disableKeyRepeat,0);
|
350
|
+
rb_define_module_function(mKey,"getKeyName",sdl_getKeyName,1);
|
351
|
+
|
352
|
+
keyState = ALLOC_N(Uint8,SDLK_LAST);
|
353
|
+
memset(keyState, SDL_RELEASED, SDLK_LAST);
|
354
|
+
|
355
|
+
defineConstForKey();
|
356
|
+
}
|
data/rubysdl_image.c
ADDED
@@ -0,0 +1,53 @@
|
|
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
|
+
#ifdef HAVE_SDL_IMAGE
|
21
|
+
#include "rubysdl.h"
|
22
|
+
#include <SDL_image.h>
|
23
|
+
|
24
|
+
static VALUE sdl_load(VALUE class,VALUE filename)
|
25
|
+
{
|
26
|
+
SDL_Surface *surface;
|
27
|
+
surface = IMG_Load(GETCSTR(filename));
|
28
|
+
if(surface==NULL){
|
29
|
+
rb_raise(eSDLError,"Couldn't load %s: %s",GETCSTR(filename),
|
30
|
+
SDL_GetError());
|
31
|
+
}
|
32
|
+
return Data_Wrap_Struct(class,0,sdl_freeSurface,surface);
|
33
|
+
}
|
34
|
+
static VALUE sdl_loadFromIO(VALUE class,VALUE io)
|
35
|
+
{
|
36
|
+
volatile VALUE guard = io;
|
37
|
+
SDL_Surface *surface;
|
38
|
+
|
39
|
+
surface = IMG_Load_RW(rubysdl_RWops_from_ruby_obj(io), 1);
|
40
|
+
|
41
|
+
if(surface==NULL){
|
42
|
+
rb_raise(eSDLError,"Couldn't load image from IO: %s",
|
43
|
+
SDL_GetError());
|
44
|
+
}
|
45
|
+
return Data_Wrap_Struct(class,0,sdl_freeSurface,surface);
|
46
|
+
}
|
47
|
+
|
48
|
+
void init_sdl_image()
|
49
|
+
{
|
50
|
+
rb_define_singleton_method(cSurface,"load",sdl_load,1);
|
51
|
+
rb_define_singleton_method(cSurface,"loadFromIO",sdl_loadFromIO,1);
|
52
|
+
}
|
53
|
+
#endif /* HAVE_SDL_IMAGE */
|
data/rubysdl_joystick.c
ADDED
@@ -0,0 +1,156 @@
|
|
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
|
+
|
23
|
+
static VALUE sdl_getJoyPolling(VALUE class)
|
24
|
+
{
|
25
|
+
return BOOL(SDL_JoystickEventState(SDL_QUERY)==SDL_ENABLE);
|
26
|
+
}
|
27
|
+
static VALUE sdl_setJoyPolling(VALUE class,VALUE poll)
|
28
|
+
{
|
29
|
+
if(poll)
|
30
|
+
SDL_JoystickEventState(SDL_ENABLE);
|
31
|
+
else
|
32
|
+
SDL_JoystickEventState(SDL_IGNORE);
|
33
|
+
return poll;
|
34
|
+
}
|
35
|
+
|
36
|
+
static VALUE sdl_joystick_num(VALUE class)
|
37
|
+
{
|
38
|
+
return INT2FIX(SDL_NumJoysticks());
|
39
|
+
}
|
40
|
+
static VALUE sdl_joystick_name(VALUE class,VALUE index)
|
41
|
+
{
|
42
|
+
return rb_str_new2( SDL_JoystickName(NUM2INT(index)) );
|
43
|
+
}
|
44
|
+
static VALUE sdl_joystick_open(VALUE class,VALUE index)
|
45
|
+
{
|
46
|
+
SDL_Joystick *joystick;
|
47
|
+
joystick=SDL_JoystickOpen(NUM2INT(index));
|
48
|
+
if(joystick==NULL)
|
49
|
+
rb_raise(eSDLError,"Couldn't open joystick No.%d :%s",NUM2INT(index),
|
50
|
+
SDL_GetError());
|
51
|
+
return Data_Wrap_Struct(class,0,0,joystick);
|
52
|
+
}
|
53
|
+
static VALUE sdl_joystick_opened(VALUE class,VALUE index)
|
54
|
+
{
|
55
|
+
return (SDL_JoystickOpened(NUM2INT(index)))?Qtrue:Qfalse;
|
56
|
+
}
|
57
|
+
static VALUE sdl_joystick_update(VALUE class)
|
58
|
+
{
|
59
|
+
SDL_JoystickUpdate();
|
60
|
+
return Qnil;
|
61
|
+
}
|
62
|
+
static VALUE sdl_joystick_index(VALUE obj)
|
63
|
+
{
|
64
|
+
SDL_Joystick *joystick;
|
65
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
66
|
+
return INT2FIX(SDL_JoystickIndex(joystick));
|
67
|
+
}
|
68
|
+
static VALUE sdl_joystick_numAxes(VALUE obj)
|
69
|
+
{
|
70
|
+
SDL_Joystick *joystick;
|
71
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
72
|
+
return INT2FIX(SDL_JoystickNumAxes(joystick));
|
73
|
+
}
|
74
|
+
static VALUE sdl_joystick_numBalls(VALUE obj)
|
75
|
+
{
|
76
|
+
SDL_Joystick *joystick;
|
77
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
78
|
+
return INT2FIX(SDL_JoystickNumBalls(joystick));
|
79
|
+
}
|
80
|
+
static VALUE sdl_joystick_numHats(VALUE obj)
|
81
|
+
{
|
82
|
+
SDL_Joystick *joystick;
|
83
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
84
|
+
return INT2FIX(SDL_JoystickNumHats(joystick));
|
85
|
+
}
|
86
|
+
static VALUE sdl_joystick_numButtons(VALUE obj)
|
87
|
+
{
|
88
|
+
SDL_Joystick *joystick;
|
89
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
90
|
+
return INT2FIX(SDL_JoystickNumButtons(joystick));
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE sdl_joystick_getAxis(VALUE obj,VALUE axis)
|
94
|
+
{
|
95
|
+
SDL_Joystick *joystick;
|
96
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
97
|
+
return INT2NUM(SDL_JoystickGetAxis(joystick,NUM2INT(axis)));
|
98
|
+
}
|
99
|
+
static VALUE sdl_joystick_getHat(VALUE obj,VALUE hat)
|
100
|
+
{
|
101
|
+
SDL_Joystick *joystick;
|
102
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
103
|
+
return UINT2NUM(SDL_JoystickGetHat(joystick,NUM2INT(hat)));
|
104
|
+
}
|
105
|
+
static VALUE sdl_joystick_getButton(VALUE obj,VALUE button)
|
106
|
+
{
|
107
|
+
SDL_Joystick *joystick;
|
108
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
109
|
+
return (SDL_JoystickGetButton(joystick,NUM2INT(button)))?Qtrue:Qfalse;
|
110
|
+
}
|
111
|
+
static VALUE sdl_joystick_getBall(VALUE obj,VALUE ball)
|
112
|
+
{
|
113
|
+
SDL_Joystick *joystick;
|
114
|
+
int dx,dy;
|
115
|
+
Data_Get_Struct(obj,SDL_Joystick,joystick);
|
116
|
+
if( SDL_JoystickGetBall(joystick,NUM2INT(ball),&dx,&dy)== -1 )
|
117
|
+
rb_raise(eSDLError,"SDL_JoystickGetBall failed :%s",SDL_GetError());
|
118
|
+
return rb_ary_new3(2,INT2FIX(dx),INT2FIX(dy));
|
119
|
+
}
|
120
|
+
|
121
|
+
static void defineConstForJoystick()
|
122
|
+
{
|
123
|
+
rb_define_const(cJoystick,"HAT_CENTERED",UINT2NUM(SDL_HAT_CENTERED));
|
124
|
+
rb_define_const(cJoystick,"HAT_UP",UINT2NUM(SDL_HAT_UP));
|
125
|
+
rb_define_const(cJoystick,"HAT_RIGHT",UINT2NUM(SDL_HAT_RIGHT));
|
126
|
+
rb_define_const(cJoystick,"HAT_DOWN",UINT2NUM(SDL_HAT_DOWN));
|
127
|
+
rb_define_const(cJoystick,"HAT_LEFT",UINT2NUM(SDL_HAT_LEFT));
|
128
|
+
rb_define_const(cJoystick,"HAT_RIGHTUP",UINT2NUM(SDL_HAT_RIGHTUP));
|
129
|
+
rb_define_const(cJoystick,"HAT_RIGHTDOWN",UINT2NUM(SDL_HAT_RIGHTDOWN));
|
130
|
+
rb_define_const(cJoystick,"HAT_LEFTUP",UINT2NUM(SDL_HAT_LEFTUP));
|
131
|
+
rb_define_const(cJoystick,"HAT_LEFTDOWN",UINT2NUM(SDL_HAT_LEFTDOWN));
|
132
|
+
}
|
133
|
+
void init_joystick()
|
134
|
+
{
|
135
|
+
cJoystick = rb_define_class_under(mSDL,"Joystick",rb_cObject);
|
136
|
+
rb_define_singleton_method(cJoystick,"poll",sdl_getJoyPolling,0);
|
137
|
+
rb_define_singleton_method(cJoystick,"poll=",sdl_setJoyPolling,1);
|
138
|
+
rb_define_singleton_method(cJoystick,"num",sdl_joystick_num,0);
|
139
|
+
rb_define_singleton_method(cJoystick,"indexName",sdl_joystick_name,1);
|
140
|
+
rb_define_singleton_method(cJoystick,"open",sdl_joystick_open,1);
|
141
|
+
rb_define_singleton_method(cJoystick,"open?",sdl_joystick_opened,1);
|
142
|
+
rb_define_singleton_method(cJoystick,"updateAll",sdl_joystick_update,0);
|
143
|
+
|
144
|
+
rb_define_method(cJoystick,"index",sdl_joystick_index,0);
|
145
|
+
rb_define_method(cJoystick,"numAxes",sdl_joystick_numAxes,0);
|
146
|
+
rb_define_method(cJoystick,"numBalls",sdl_joystick_numBalls,0);
|
147
|
+
rb_define_method(cJoystick,"numHats",sdl_joystick_numHats,0);
|
148
|
+
rb_define_method(cJoystick,"numButtons",sdl_joystick_numButtons,0);
|
149
|
+
|
150
|
+
rb_define_method(cJoystick,"axis",sdl_joystick_getAxis,1);
|
151
|
+
rb_define_method(cJoystick,"hat",sdl_joystick_getHat,1);
|
152
|
+
rb_define_method(cJoystick,"button",sdl_joystick_getButton,1);
|
153
|
+
rb_define_method(cJoystick,"ball",sdl_joystick_getBall,1);
|
154
|
+
|
155
|
+
defineConstForJoystick();
|
156
|
+
}
|