rubysdl 1.3.1 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/MANIFEST +22 -2
  2. data/NEWS.en +80 -0
  3. data/NEWS.ja +83 -0
  4. data/README.en +2 -1
  5. data/README.ja +2 -2
  6. data/doc-en/Makefile +18 -0
  7. data/doc-en/cdrom.rsd +417 -0
  8. data/doc-en/collision.rsd +174 -0
  9. data/doc-en/event.rsd +1476 -0
  10. data/doc-en/font.rsd +811 -0
  11. data/doc-en/general.rsd +43 -0
  12. data/doc-en/init.rsd +168 -0
  13. data/doc-en/joystick.rsd +401 -0
  14. data/doc-en/mixer.rsd +869 -0
  15. data/doc-en/mpeg.rsd +585 -0
  16. data/doc-en/opengl.rsd +155 -0
  17. data/doc-en/sdlskk.rsd +472 -0
  18. data/doc-en/time.rsd +46 -0
  19. data/doc-en/video.rsd +2806 -0
  20. data/doc-en/wm.rsd +112 -0
  21. data/doc/Makefile +1 -1
  22. data/doc/cdrom.rsd +3 -3
  23. data/doc/event.rsd +178 -179
  24. data/doc/general.rsd +10 -0
  25. data/doc/init.rsd +2 -2
  26. data/doc/joystick.rsd +29 -5
  27. data/doc/mixer.rsd +20 -0
  28. data/doc/rsd.rb +42 -9
  29. data/doc/sdlskk.rsd +7 -7
  30. data/doc/video.rsd +461 -168
  31. data/doc/wm.rsd +2 -2
  32. data/extconf.rb +1 -8
  33. data/lib/rubysdl_aliases.rb +52 -190
  34. data/lib/rubysdl_compatible_ver1.rb +243 -0
  35. data/lib/sdl.rb +58 -92
  36. data/rubysdl.h +59 -68
  37. data/rubysdl_cdrom.c +125 -102
  38. data/{rubysdl_doc.en.rd → rubysdl_doc_old.en.rd} +3 -2
  39. data/rubysdl_event.c +318 -255
  40. data/rubysdl_event_key.c +299 -287
  41. data/rubysdl_image.c +37 -13
  42. data/rubysdl_joystick.c +180 -67
  43. data/rubysdl_kanji.c +61 -75
  44. data/rubysdl_main.c +65 -138
  45. data/rubysdl_mixer.c +339 -214
  46. data/rubysdl_mouse.c +50 -43
  47. data/rubysdl_opengl.c +31 -28
  48. data/rubysdl_pixel.c +17 -28
  49. data/rubysdl_ref.en.html +5658 -0
  50. data/rubysdl_ref.en.rd +6337 -0
  51. data/rubysdl_ref.html +2253 -1964
  52. data/rubysdl_ref.rd +823 -469
  53. data/rubysdl_rwops.c +9 -6
  54. data/rubysdl_sdlskk.c +137 -165
  55. data/rubysdl_sge_video.c +355 -469
  56. data/rubysdl_smpeg.c +189 -190
  57. data/rubysdl_time.c +1 -1
  58. data/rubysdl_ttf.c +147 -215
  59. data/rubysdl_video.c +486 -405
  60. data/rubysdl_wm.c +30 -30
  61. data/sample/aadraw.rb +9 -9
  62. data/sample/alpha.rb +12 -13
  63. data/sample/alphadraw.rb +10 -10
  64. data/sample/bfont.rb +4 -4
  65. data/sample/cdrom.rb +11 -4
  66. data/sample/collision.rb +20 -20
  67. data/sample/cursor.rb +5 -5
  68. data/sample/ellipses.rb +20 -16
  69. data/sample/event2.rb +11 -9
  70. data/sample/font.rb +4 -4
  71. data/sample/fpstimer.rb +3 -3
  72. data/sample/icon.bmp.gz +0 -0
  73. data/sample/icon.png +0 -0
  74. data/sample/joy2.rb +14 -14
  75. data/sample/kanji.rb +7 -7
  76. data/sample/load_from_io.rb +44 -0
  77. data/sample/movesp.rb +13 -12
  78. data/sample/playmod.rb +2 -3
  79. data/sample/plaympeg.rb +8 -8
  80. data/sample/playwave.rb +5 -6
  81. data/sample/sdlskk.rb +11 -11
  82. data/sample/sgetest.rb +14 -12
  83. data/sample/stetris.rb +12 -13
  84. data/sample/testgl.rb +13 -14
  85. data/sample/testsprite.rb +12 -11
  86. data/sample/transformblit.rb +23 -22
  87. metadata +62 -35
  88. data/rubysdl_event2.c +0 -417
@@ -0,0 +1,174 @@
1
+ = Collision Detection
2
+ * ((<Collision Detection outline>))
3
+ * ((<SDL::CollisionMap>))
4
+
5
+ * ((<Collision Detection Methods>))
6
+ TOC
7
+
8
+ == Collision Detection outline
9
+ Ruby/SDL has collision detection system
10
+ derived from
11
+ ((<SGE|URL:http://www.etek.chalmers.se/~e8cal1/sge/index.html>)).
12
+ This enables you to pixel-pixel checking after
13
+ creating binary image by @[Surface#make_collision_map].
14
+
15
+ Please see sample/collision.rb too.
16
+
17
+ == SDL::CollisionMap
18
+ This class represents binary image used by collision
19
+ detections.
20
+ You can create this instance only by
21
+ @[Surface#make_collision_map].
22
+
23
+ METHODS(CollisionMap)
24
+
25
+ == Collision Detection Methods
26
+ %%%
27
+ NAME make_collision_map
28
+ MOD Surface
29
+ TYPE #
30
+ DEP SGE
31
+ PURPOSE Creates a new collision map
32
+ RVAL SDL::CollisionMap
33
+
34
+ PROTO
35
+ make_collision_map
36
+ makeCollisionMap
37
+
38
+ DESC
39
+ Creates a new collision map from @[Surface] object.
40
+ Use @[Surface#set_color_key] before calling this method.
41
+ Every non-transparent pixel is set to
42
+ solid in the collision map.
43
+
44
+ Returns a new @[CollisionMap] object.
45
+
46
+ EXCEPTION *
47
+
48
+ SEEALSO
49
+ Surface#set_color_key
50
+ CollisionMap#collision_check
51
+ CollisionMap#clear
52
+ CollisionMap#set
53
+
54
+ %%
55
+ NAME collision_check
56
+ MOD CollisionMap
57
+ TYPE #
58
+ DEP SGE
59
+ PURPOSE Does pixel collision detection.
60
+ RVAL true/false
61
+
62
+ PROTO
63
+ collision_check(x1, y1, cmap, x2, y2)
64
+
65
+ DESC
66
+ Does pixel perfect collision detection with
67
+ $[self] and $[cmap].
68
+ The ($[x1],$[y1]) and ($[x2],$[y2])
69
+ coords are the positions of the upper left corners of the
70
+ images. Returns true if any solid
71
+ pixels of the two images overlap or else false.
72
+
73
+ This method calls @[CollisionMap#bounding_box_check]
74
+ internally.
75
+
76
+ SEEALSO
77
+ CollisionMap#bounding_box_check
78
+
79
+ %%
80
+ NAME bounding_box_check
81
+ MOD CollisionMap
82
+ TYPE #
83
+ DEP SGE
84
+ PURPOSE Checks if two shapes overlap.
85
+ RVAL true/false
86
+
87
+ PROTO
88
+ bounding_box_check(x1, y1, cmap, x2, y2)
89
+ boundingBoxCheck(x1, y1, cmap, x2, y2)
90
+
91
+ DESC
92
+
93
+ Checks if two rectangles
94
+ (the bounding boxes, $[self] and $[cmap]) overlap.
95
+ The ($[x1],$[y1]) and ($[x2],$[y2])
96
+ coords are the positions of the upper left corners of the
97
+ images.
98
+
99
+ RET
100
+ Returns true if two rectangles overlap, otherwise
101
+ returns false.
102
+
103
+ SEEALSO
104
+ CollisionMap#collision_check
105
+ CollisionMap#w
106
+ CollisionMap#h
107
+
108
+ %%
109
+ NAME clear
110
+ MOD CollisionMap
111
+ TYPE #
112
+ DEP SGE
113
+ PURPOSE Clears an area in the collision map
114
+
115
+ PROTO
116
+ clear(x, y, w, h)
117
+
118
+ DESC
119
+ Clears an area in the collision map from anything solid.
120
+
121
+ SEEALSO
122
+ CollisionMap#set
123
+
124
+ %%
125
+ NAME set
126
+ MOD CollisionMap
127
+ TYPE #
128
+ DEP SGE
129
+ PURPOSE Makes an area in the collision map solid
130
+
131
+ PROTO
132
+ set(x, y, w, h)
133
+
134
+ DESC
135
+ Makes an area in the collision map solid.
136
+
137
+ SEEALSO
138
+ CollisionMap#set
139
+
140
+ %%
141
+ NAME w
142
+ MOD CollisionMap
143
+ TYPE #
144
+ DEP SGE
145
+ PURPOSE Gets width of collision map
146
+ RVAL Integer
147
+
148
+ PROTO
149
+ w
150
+
151
+ DESC
152
+ Returns width of collision map.
153
+
154
+ SEEALSO
155
+ CollisionMap#h
156
+
157
+ %%
158
+ NAME h
159
+ MOD CollisionMap
160
+ TYPE #
161
+ DEP SGE
162
+ PURPOSE Get height of collision map
163
+ RVAL Integer
164
+
165
+ PROTO
166
+ h
167
+
168
+ DESC
169
+ Returns height of collision map.
170
+
171
+
172
+ SEEALSO
173
+ CollisionMap#w
174
+
data/doc-en/event.rsd ADDED
@@ -0,0 +1,1476 @@
1
+ = Event
2
+ * ((<Event system Overview>))
3
+ * ((<SDL::Event>))
4
+ * ((<SDL::Event::Active>))
5
+ * ((<SDL::Event::KeyDown>))
6
+ * ((<SDL::Event::KeyUp>))
7
+ * ((<SDL::Event::MouseMotion>))
8
+ * ((<SDL::Event::MouseButtonDown>))
9
+ * ((<SDL::Event::MouseButtonUp>))
10
+ * ((<SDL::Event::JoyAxis>))
11
+ * ((<SDL::Event::JoyBall>))
12
+ * ((<SDL::Event::JoyHat>))
13
+ * ((<SDL::Event::JoyButtonDown>))
14
+ * ((<SDL::Event::JoyButtonUp>))
15
+ * ((<SDL::Event::Quit>))
16
+ * ((<SDL::Event::SysWM>))
17
+ * ((<SDL::Event::VideoResize>))
18
+ * ((<SDL::Event::VideoExpose>))
19
+ * ((<SDL::Key>))
20
+ * ((<SDL::Mouse>))
21
+ * Methdos for Event
22
+ TOC
23
+
24
+ == Event system Overview
25
+ Event handling allows your application to receive input from the user.
26
+ Event handling is initalised (along with video) with a call to:
27
+ SDL_Init(SDL_INIT_VIDEO);
28
+ Internally, SDL stores all the events waiting to be handled in an event queue.
29
+ Using functions like @[Event.poll] and @[Event.wait]
30
+ you can observe and handle waiting input events.
31
+
32
+ The key to event handling in SDL is the subclasses of @[Event].
33
+ The event queue itself is composed of a series of
34
+ instance of (subclasses of) @[Event], one for each waiting event.
35
+ Those objects are read from queue with the @[Event.poll] and it is
36
+ then up to the application to process the information stored with them.
37
+
38
+ Subclasses of @[Event] is following:
39
+ * @[Event::Active]
40
+ * @[Event::KeyDown]
41
+ * @[Event::KeyUp]
42
+ * @[Event::MouseMotion]
43
+ * @[Event::MouseButtonDown]
44
+ * @[Event::MouseButtonUp]
45
+ * @[Event::JoyAxis]
46
+ * @[Event::JoyBall]
47
+ * @[Event::JoyHat]
48
+ * @[Event::JoyButtonDown]
49
+ * @[Event::JoyButtonUp]
50
+ * @[Event::Quit]
51
+ * @[Event::SysWM]
52
+ * @[Event::VideoResize]
53
+ * @[Event::VideoExpose]
54
+
55
+ Those classes have two uses.
56
+ * Reading events on the event queue.
57
+ * Placing events on the event queue.
58
+
59
+ Reading events from the event queue is done with @[Event.poll].
60
+ We'll use @[Event.poll] and step through an example.
61
+ @[Event.poll] removes the next event from the event queue,
62
+ if there are no events on the queue it returns nil
63
+ otherwise it returns event object.
64
+ We use a while loop to process each event in turn.
65
+
66
+ while event = SDL::Event.poll
67
+
68
+ We know that if @[Event.poll] removes an event from the queue then the event information will
69
+ be placed in returned object, but we also know that the class of that object will represent
70
+ the type of event. So we handle each event type seperately we use a switch statement.
71
+
72
+ case event
73
+
74
+ We need to know what kind of events we're looking for ((*and*)) the event type's of those events.
75
+ So lets assume we want to detect where the user is moving the mouse pointer within our application.
76
+ We look through our event types and notice that @[Event::MouseMotion] is, more than likely,
77
+ the event we're looking for. A little more research tells use that
78
+ mouse motion events are handled within the @[Event::MouseMotion].
79
+ We can check for the mouse motion event type within our switch statement like so:
80
+
81
+ when SDL::Event::MouseMotion
82
+
83
+ All we need do now is read the information out of this object as instance
84
+ of @[Event::MouseMotion].
85
+
86
+ puts "We got a motion event"
87
+ puts "Current mouse position is: (#{event.x}, #{event.y})"
88
+ else
89
+ puts "Unhandled Event!"
90
+ end
91
+ end
92
+ puts "Event queue is empty."
93
+
94
+ It is also possible to push events onto the event queue.
95
+ [Event.push] allows you to place events onto the event queue.
96
+ You can use it to post fake input events if you wished.
97
+
98
+ == SDL::Event
99
+ This class handle events. All objects returned by @[Event.poll] are
100
+ instances of subclasses of SDL::Event.
101
+
102
+ == Compatiblity
103
+ The class that used to be known as SDL::Event is remove.
104
+ The class now called SDL::Event was called SDL::Event2 before.
105
+ A constant SDL::Event2 remains as alias of SDL::Event because of compatiblity with older version.
106
+
107
+ == SDL::Event::Active
108
+ Class for Application visibility event.
109
+
110
+ This event raises when the mouse leaves or enters the window area,
111
+ the application loses or gains keyboard focus,
112
+ or the application is either minimised/iconified or restored.
113
+
114
+ @[Event::Active#state] returns which event occurs.
115
+
116
+ * NOTES
117
+
118
+ This event does not occur when an application window is first created.
119
+
120
+ METHODS(Event::Active)
121
+
122
+ == SDL::Event::KeyDown
123
+
124
+ Class for keyboard down event.
125
+
126
+ METHODS(Event::KeyDown)
127
+
128
+ == SDL::Event::KeyUp
129
+
130
+ Class for key up event.
131
+
132
+ METHODS(Event::KeyUp)
133
+
134
+ == SDL::Event::MouseMotion
135
+
136
+ Class for mouse motion event.
137
+
138
+ Simply put, a event of this type occurs
139
+ when a user moves the mouse within the application window or when [Mouse.warp] is called.
140
+ Both the absolute coordinate (@[Event::MouseMotion#x] and @[Event::MouseMotion#y]) and
141
+ relative coordinate (@[Event::MouseMotion#xrel] and @[Event::MouseMotion#yrel])
142
+ are reported along with the current button states (@[Event::MouseMotion#state]).
143
+
144
+ METHODS(Event::MouseMotion)
145
+
146
+ == SDL::Event::MouseButtonDown
147
+ Class for mouse button press event.
148
+
149
+ This type of event occurs when a mouse button press is detected.
150
+
151
+ METHODS(Event::MouseButtonDown)
152
+
153
+ == SDL::Event::MouseButtonUp
154
+ Class for mouse button release event.
155
+
156
+ This type of event occurs when a mouse button release is detected.
157
+
158
+ METHODS(Event::MouseButtonUp)
159
+
160
+ == SDL::Event::JoyAxis
161
+ Class for joystick axis motion event.
162
+
163
+ This event occurs when ever a user moves an axis on the joystick.
164
+
165
+ METHODS(Event::JoyAxis)
166
+
167
+ * SEEALSO
168
+ @[Joystick#num_axes], @[Joystick#axis]
169
+
170
+ == SDL::Event::JoyBall
171
+ Class for joystick ball motion event.
172
+
173
+ This type of event occurs when a user moves a trackball on the joystick.
174
+
175
+ METHODS(Event::JoyBall)
176
+
177
+ * SEEALSO
178
+
179
+ @[Joystick#num_balls], @[Joystick#ball]
180
+
181
+ == SDL::Event::JoyHat
182
+ Class for joystick hat position change event.
183
+
184
+ METHODS(Event::JoyHat)
185
+
186
+ * SEEALSO
187
+
188
+ @[Joystick#num_hats], @[Joystick#hat]
189
+
190
+ == SDL::Event::JoyButtonDown
191
+ Class for joystick button press event.
192
+
193
+ This event occurs when a user presses a button on a joystick.
194
+
195
+ METHODS(Event::JoyButtonDown)
196
+
197
+ * SEEALSO
198
+
199
+ @[Joystick#num_buttons], @[Joystick#button]
200
+
201
+ == SDL::Event::JoyButtonUp
202
+ Class for joystick button release event.
203
+
204
+ This event occurs when a user releases a button on a joystick.
205
+
206
+ METHODS(Event::JoyButtonUp)
207
+
208
+ * SEEALSO
209
+
210
+ @[Joystick#num_buttons], @[Joystick#button]
211
+
212
+ == SDL::Event::Quit
213
+ Class for quit reqested event.
214
+
215
+ This event is very important.
216
+ If you filter out or ignore a quit event then it is impossible for the user to
217
+ close the window. On the other hand, if you do accept a quit event then the application window will be
218
+ closed, and screen updates will still report success event though the application will no longer be
219
+ visible.
220
+
221
+ == SDL::Event::SysWM
222
+ Class for platform-dependent window manager event.
223
+
224
+ Event of this type occurs when unknown window manager event happens.
225
+ You can never know the detail of this event.
226
+ Only you can to do is to ignore this event.
227
+
228
+ == SDL::Event::VideoResize
229
+ Class for window resize event.
230
+
231
+ When SDL::RESIZABLE is passed as a $[flag] to
232
+ @[Screen.open] the user is allowed to resize the applications
233
+ window. When the window is resized an event of this type is report,
234
+ with the new window width and height values stored in @[Event::VideoResize#w] and
235
+ @[Event::VideoResize#h] respectively.
236
+
237
+ When this event is recieved the window should be resized
238
+ to the new dimensions using @[Screen.open].
239
+
240
+ == SDL::Event::VideoExpose
241
+ Class for video expose event.
242
+
243
+ This event is triggered when the screen has been modified outside of the application, usually by
244
+ the window manager and needs to be redrawn.
245
+
246
+ == SDL::Key
247
+ Module for keyboard input.
248
+
249
+ This module defines some keyboard-related constants and
250
+ module functions.
251
+
252
+ METHODS(Key)
253
+
254
+ === Key symbol
255
+ Key symbol constants definitions.
256
+ * SDL::Key::BACKSPACE '\b' backspace
257
+ * SDL::Key::TAB '\t' tab
258
+ * SDL::Key::CLEAR clear
259
+ * SDL::Key::RETURN '\r' return
260
+ * SDL::Key::PAUSE pause
261
+ * SDL::Key::ESCAPE '^[' escape
262
+ * SDL::Key::SPACE ' ' space
263
+ * SDL::Key::EXCLAIM '!' exclaim
264
+ * SDL::Key::QUOTEDBL '"' quotedbl
265
+ * SDL::Key::HASH '#' hash
266
+ * SDL::Key::DOLLAR '$' dollar
267
+ * SDL::Key::AMPERSAND '&' ampersand
268
+ * SDL::Key::QUOTE ''' quote
269
+ * SDL::Key::LEFTPAREN '(' left parenthesis
270
+ * SDL::Key::RIGHTPAREN ')' right parenthesis
271
+ * SDL::Key::ASTERISK '*' asterisk
272
+ * SDL::Key::PLUS '+' plus sign
273
+ * SDL::Key::COMMA ',' comma
274
+ * SDL::Key::MINUS '-' minus sign
275
+ * SDL::Key::PERIOD '.' period
276
+ * SDL::Key::SLASH '/' forward slash
277
+ * SDL::Key::K0 '0' 0
278
+ * SDL::Key::K1 '1' 1
279
+ * SDL::Key::K2 '2' 2
280
+ * SDL::Key::K3 '3' 3
281
+ * SDL::Key::K4 '4' 4
282
+ * SDL::Key::K5 '5' 5
283
+ * SDL::Key::K6 '6' 6
284
+ * SDL::Key::K7 '7' 7
285
+ * SDL::Key::K8 '8' 8
286
+ * SDL::Key::K9 '9' 9
287
+ * SDL::Key::COLON ':' colon
288
+ * SDL::Key::SEMICOLON ';' semicolon
289
+ * SDL::Key::LESS '&lt;' less-than sign
290
+ * SDL::Key::EQUALS '=' equals sign
291
+ * SDL::Key::GREATER '&gt;' greater-than sign
292
+ * SDL::Key::QUESTION '?' question mark
293
+ * SDL::Key::AT '@' at
294
+ * SDL::Key::LEFTBRACKET '[' left bracket
295
+ * SDL::Key::BACKSLASH '\' backslash
296
+ * SDL::Key::RIGHTBRACKET ']' right bracket
297
+ * SDL::Key::CARET '^' caret
298
+ * SDL::Key::UNDERSCORE '_' underscore
299
+ * SDL::Key::BACKQUOTE '`' grave
300
+ * SDL::Key::A 'a' a
301
+ * SDL::Key::B 'b' b
302
+ * SDL::Key::C 'c' c
303
+ * SDL::Key::D 'd' d
304
+ * SDL::Key::E 'e' e
305
+ * SDL::Key::F 'f' f
306
+ * SDL::Key::G 'g' g
307
+ * SDL::Key::H 'h' h
308
+ * SDL::Key::I 'i' i
309
+ * SDL::Key::J 'j' j
310
+ * SDL::Key::K 'k' k
311
+ * SDL::Key::L 'l' l
312
+ * SDL::Key::M 'm' m
313
+ * SDL::Key::N 'n' n
314
+ * SDL::Key::O 'o' o
315
+ * SDL::Key::P 'p' p
316
+ * SDL::Key::Q 'q' q
317
+ * SDL::Key::R 'r' r
318
+ * SDL::Key::S 's' s
319
+ * SDL::Key::T 't' t
320
+ * SDL::Key::U 'u' u
321
+ * SDL::Key::V 'v' v
322
+ * SDL::Key::W 'w' w
323
+ * SDL::Key::X 'x' x
324
+ * SDL::Key::Y 'y' y
325
+ * SDL::Key::Z 'z' z
326
+ * SDL::Key::DELETE '^?' delete
327
+ * SDL::Key::KP0 keypad 0
328
+ * SDL::Key::KP1 keypad 1
329
+ * SDL::Key::KP2 keypad 2
330
+ * SDL::Key::KP3 keypad 3
331
+ * SDL::Key::KP4 keypad 4
332
+ * SDL::Key::KP5 keypad 5
333
+ * SDL::Key::KP6 keypad 6
334
+ * SDL::Key::KP7 keypad 7
335
+ * SDL::Key::KP8 keypad 8
336
+ * SDL::Key::KP9 keypad 9
337
+ * SDL::Key::KP_PERIOD '.' keypad period
338
+ * SDL::Key::KP_DIVIDE '/' keypad divide
339
+ * SDL::Key::KP_MULTIPLY '*' keypad multiply
340
+ * SDL::Key::KP_MINUS '-' keypad minus
341
+ * SDL::Key::KP_PLUS '+' keypad plus
342
+ * SDL::Key::KP_ENTER '\r' keypad enter
343
+ * SDL::Key::KP_EQUALS '=' keypad equals
344
+ * SDL::Key::UP up arrow
345
+ * SDL::Key::DOWN down arrow
346
+ * SDL::Key::RIGHT right arrow
347
+ * SDL::Key::LEFT left arrow
348
+ * SDL::Key::INSERT insert
349
+ * SDL::Key::HOME home
350
+ * SDL::Key::END end
351
+ * SDL::Key::PAGEUP page up
352
+ * SDL::Key::PAGEDOWN page down
353
+ * SDL::Key::F1 F1
354
+ * SDL::Key::F2 F2
355
+ * SDL::Key::F3 F3
356
+ * SDL::Key::F4 F4
357
+ * SDL::Key::F5 F5
358
+ * SDL::Key::F6 F6
359
+ * SDL::Key::F7 F7
360
+ * SDL::Key::F8 F8
361
+ * SDL::Key::F9 F9
362
+ * SDL::Key::F10 F10
363
+ * SDL::Key::F11 F11
364
+ * SDL::Key::F12 F12
365
+ * SDL::Key::F13 F13
366
+ * SDL::Key::F14 F14
367
+ * SDL::Key::F15 F15
368
+ * SDL::Key::NUMLOCK numlock
369
+ * SDL::Key::CAPSLOCK capslock
370
+ * SDL::Key::SCROLLOCK scrollock
371
+ * SDL::Key::RSHIFT right shift
372
+ * SDL::Key::LSHIFT left shift
373
+ * SDL::Key::RCTRL right ctrl
374
+ * SDL::Key::LCTRL left ctrl
375
+ * SDL::Key::RALT right alt
376
+ * SDL::Key::LALT left alt
377
+ * SDL::Key::RMETA right meta
378
+ * SDL::Key::LMETA left meta
379
+ * SDL::Key::LSUPER left windows key
380
+ * SDL::Key::RSUPER right windows key
381
+ * SDL::Key::MODE mode shift
382
+ * SDL::Key::HELP help
383
+ * SDL::Key::PRINT print-screen
384
+ * SDL::Key::SYSREQ SysRq
385
+ * SDL::Key::BREAK break
386
+ * SDL::Key::MENU menu
387
+ * SDL::Key::POWER power
388
+ * SDL::Key::EURO euro
389
+
390
+ == SDL::Mouse
391
+ Module for mouse input.
392
+
393
+ This module defines some mouse constants and module functions.
394
+
395
+ METHODS(Mouse)
396
+ == Methods
397
+ %%%
398
+ NAME poll
399
+ MOD Event
400
+ TYPE .
401
+ PURPOSE Polls for currently pending events.
402
+ RVAL Event/nil
403
+
404
+ PROTO
405
+ poll
406
+
407
+ DESC
408
+ Polls for currently pending events, and returns event object if there
409
+ are any pending events, or nil if there are none
410
+ available.
411
+
412
+ If event object is returned, the next event is removed from
413
+ the queue and stored in that area.
414
+
415
+ EXAMPLE
416
+ while event = SDL::Event.poll # Loop until there are no events left on the queue
417
+ case event # Process the appropiate event type
418
+ when SDL::Event::KeyDown # Handle a KEYDOWN event
419
+ puts "Oh! Key press"
420
+ when SDL::Event::MouseMotion
421
+ .
422
+ .
423
+ .
424
+ else # Report an unhandled event
425
+ puts "I don't know what this event is!"
426
+ end
427
+ end
428
+
429
+ SEEALSO
430
+ Event
431
+ Event.wait
432
+
433
+ %%
434
+ NAME wait
435
+ MOD Event
436
+ TYPE .
437
+ PURPOSE Waits indefinitely for the next available event.
438
+ RVAL Event/nil
439
+
440
+ PROTO
441
+ wait
442
+
443
+ DESC
444
+ Waits indefinitely for the next available event and return that event.
445
+
446
+ If event object is returned, the next event is removed
447
+ from the queue and stored in that area.
448
+
449
+ EXCEPTION
450
+ Raise @[Error] if there was an error while waiting
451
+ for events.
452
+
453
+ NOTES
454
+ All Ruby's threads stop while waiting next event because Ruby's thread
455
+ is not native thread.
456
+
457
+ SEEALSO
458
+ Event.poll
459
+
460
+ %%
461
+ NAME push
462
+ MOD Event
463
+ TYPE .
464
+ PURPOSE Pushes an event onto the event queue.
465
+
466
+ PROTO
467
+ push(event)
468
+
469
+ DESC
470
+ Push $[event] onto event queue.
471
+
472
+ NOTES
473
+ Pushing device input events onto the queue doesn't modify the
474
+ state of the device within SDL.
475
+
476
+ EXCEPTION *
477
+
478
+ SEEALSO
479
+ Event.poll
480
+
481
+ %%
482
+ NAME app_state
483
+ MOD Event
484
+ TYPE .
485
+ PURPOSE Get the state of the application.
486
+ RVAL UINT
487
+
488
+ PROTO
489
+ app_state
490
+ appState
491
+
492
+ DESC
493
+ This method returns the current state of the application.
494
+ The value returned is a bitwise combination of:
495
+ :SDL::Event::APPMOUSEFOCUS
496
+ The application has mouse focus.
497
+ :SDL::Event::APPINPUTFOCUS
498
+ The application has keyboard focus.
499
+ :SDL::Event::APPACTIVE
500
+ The application is visible.
501
+
502
+ SEEALSO
503
+ Event::Active
504
+
505
+ %%
506
+ NAME enable_unicode
507
+ MOD Event
508
+ TYPE .
509
+ PURPOSE Enable UNICODE translation
510
+
511
+ PROTO
512
+ enable_unicode
513
+ enableUNICODE
514
+
515
+ DESC
516
+ To obtain the character codes corresponding to received keyboard events, Unicode translation must first
517
+ be turned on using this function. The translation incurs a slight overhead for each keyboard event and is
518
+ therefore disabled by default. For each subsequently received key down event,
519
+ @[Event::KeyDown#unicode] will then contain the corresponding character code,
520
+ or zero for keysyms that do not correspond to any character code.
521
+
522
+ NOTES
523
+ Note that only key press events will be translated, not release events.
524
+
525
+ SEEALSO
526
+ Event.disable_unicode
527
+ Event.enable_unicode?
528
+
529
+ %%
530
+ NAME disable_unicode
531
+ MOD Event
532
+ TYPE .
533
+ PURPOSE Disable UNICODE translation
534
+
535
+ PROTO
536
+ disable_unicode
537
+ disableUNICODE
538
+
539
+ DESC
540
+ Disables Unicode keyboard translation. Please see @[Event.enable_unicode]
541
+ in detail.
542
+
543
+ %%
544
+ NAME enable_unicode?
545
+ MOD Event
546
+ TYPE .
547
+ PURPOSE Get whether UNICODE translation is enabled.
548
+ RVAL true/false
549
+
550
+ PROTO
551
+ enable_unicode?
552
+ enableUNICODE?
553
+
554
+ DESC
555
+ Returns true if Unicode keyboard translation is enabled, otherwise
556
+ returns false. Please see @[Event.enable_unicode] in detail.
557
+
558
+ %%
559
+ NAME gain
560
+ TYPE #
561
+ MOD Event::Active
562
+ PURPOSE Returns whether gaining visibility or not
563
+ RVAL true/false
564
+
565
+ PROTO
566
+ gain
567
+
568
+ DESC
569
+ Returns true if the mouse enters the window, the application gains keyboard focus, or
570
+ minimized/iconcified window is restored.
571
+ Otherwise returns false.
572
+
573
+ SEEALSO
574
+ Event::Active
575
+ Event::Active#state
576
+
577
+ %%
578
+ NAME state
579
+ MOD Event::Active
580
+ TYPE #
581
+ PURPOSE Gets the type of visibility event.
582
+ RVAL SDL::Event::APPMOUSEFOCUS/SDL::Event::APPINPUTFOCUS/SDL::Event::APPACTIVE
583
+
584
+ PROTO
585
+ state
586
+
587
+ DESC
588
+ Returns one of following three constants:
589
+ * SDL::Event::APPMOUSEFOCUS
590
+
591
+ This event occurs when the mouse leaves or enters the window area.
592
+
593
+ * SDL::Event::APPINPUTFOCUS
594
+
595
+ THis event occurs when the application loses or gains input focus.
596
+
597
+ * SDL::Event::APPACTIVE
598
+
599
+ This event occurs when the application is either minimized/iconcified or restored.
600
+
601
+ SEEALSO
602
+ Event::Active
603
+ Event::Active#gain
604
+
605
+ %%
606
+ NAME press
607
+ MOD Event::KeyDown
608
+ TYPE #
609
+ PURPOSE Returns true.
610
+ RVAL true
611
+
612
+ PROTO
613
+ press
614
+
615
+ DESC
616
+ Always returns true.
617
+
618
+ SEEALSO
619
+ Event::KeyUp#press
620
+
621
+ %%
622
+ NAME sym
623
+ MOD Event::KeyDown
624
+ TYPE #
625
+ PURPOSE Get the key symbol of pressed key
626
+ RVAL Integer
627
+
628
+ PROTO
629
+ sym
630
+
631
+ DESC
632
+ Returns pressed ((<Key symbol>)).
633
+
634
+ SEEALSO
635
+ Event::KeyDown#unicode
636
+
637
+ %%
638
+ NAME mod
639
+ MOD Event::KeyDown
640
+ TYPE #
641
+ PURPOSE Current key modifier
642
+ RVAL UINT
643
+
644
+ PROTO
645
+ mod
646
+
647
+ DESC
648
+ Returns the current state of keyboard modifiers as explained in @[Key.mod_state].
649
+
650
+ SEEALSO
651
+ Key.mod_state
652
+
653
+ %%
654
+ NAME unicode
655
+ MOD Event::KeyDown
656
+ TYPE #
657
+ PURPOSE Translated character
658
+ RVAL UINT
659
+
660
+ PROTO
661
+ unicode
662
+
663
+ DESC
664
+ Returns the UNICODE character corresponding to the keypress if Unicode translation
665
+ is enabled with @[Event.enable_unicode].
666
+ If the high 9 bits of the character are 0, then this
667
+ maps to the equivalent ASCII character:
668
+
669
+ Returns zero if unicode translation is disabled.
670
+
671
+ %%
672
+ NAME press
673
+ MOD Event::KeyUp
674
+ TYPE #
675
+ PURPOSE Whether key is pressed
676
+ RVAL false
677
+
678
+ PROTO
679
+ press
680
+
681
+ DESC
682
+ Always returns false.
683
+
684
+ SEEALSO
685
+ Event::KeyDown#press
686
+
687
+ %%
688
+ NAME sym
689
+ MOD Event::KeyUp
690
+ TYPE #
691
+ PURPOSE Get the key symbol of released key
692
+ RVAL Integer
693
+
694
+ PROTO
695
+ sym
696
+
697
+ DESC
698
+ Returns the released ((<Key symbol>))
699
+
700
+ %%
701
+ NAME mod
702
+ MOD Event::KeyUp
703
+ TYPE #
704
+ PURPOSE Current key modifier
705
+ RVAL UINT
706
+
707
+ PROTO
708
+ mod
709
+
710
+ DESC
711
+ Returns the current state of keyboard modifiers as explained in @[Key.mod_state].
712
+
713
+ SEEALSO
714
+ Key.mod_state
715
+
716
+ %%
717
+ NAME state
718
+ MOD Event::MouseMotion
719
+ TYPE #
720
+ PURPOSE The current button state
721
+ RVAL UINT
722
+
723
+ PROTO
724
+ state
725
+
726
+ DESC
727
+ Returns the current button state.
728
+ The value returned is a bitwise combination of:
729
+
730
+ :SDL::Mouse::BUTTON_LMASK
731
+ Left button
732
+ :SDL::Mouse::BUTTON_MMASK
733
+ Middle button
734
+ :SDL::Mouse::BUTTON_RMASK
735
+ Right button
736
+
737
+ SEEALSO
738
+ Mouse.state
739
+
740
+ %%
741
+ NAME x
742
+ MOD Event::MouseMotion
743
+ TYPE #
744
+ PURPOSE The X coordinate of the mouse
745
+ RVAL UINT
746
+
747
+ PROTO
748
+ x
749
+
750
+ DESC
751
+ Returns the X coordinate of the mouse.
752
+
753
+ SEEALSO
754
+ Mouse.state
755
+
756
+ %%
757
+ NAME y
758
+ MOD Event::MouseMotion
759
+ TYPE #
760
+ PURPOSE the X coordinate of the mouse.
761
+ RVAL UINT
762
+
763
+ PROTO
764
+ y
765
+
766
+ DESC
767
+ Returns the Y coordinate of the mouse.
768
+
769
+ SEEALSO
770
+ Mouse.state
771
+
772
+ %%
773
+ NAME xrel
774
+ MOD Event::MouseMotion
775
+ TYPE #
776
+ PURPOSE Relative motion in the X direction
777
+ RVAL Integer
778
+
779
+ PROTO
780
+ xrel
781
+
782
+ DESC
783
+ Returns relative motion in the X direction.
784
+
785
+ %%
786
+ NAME yrel
787
+ MOD Event::MouseMotion
788
+ TYPE #
789
+ PURPOSE Relative motion in the Y direction
790
+ RVAL Integer
791
+
792
+ PROTO
793
+ yrel
794
+
795
+ DESC
796
+ Returns relative motion in the Y direction.
797
+
798
+ %%
799
+ NAME button
800
+ MOD Event::MouseButtonDown
801
+ TYPE #
802
+ PURPOSE The mouse button index
803
+
804
+ PROTO
805
+ button
806
+
807
+ DESC
808
+ Returns number of the button pressed:
809
+ * SDL::Mouse::BUTTON_LEFT
810
+ * SDL::Mouse::BUTTON_MIDDLE
811
+ * SDL::Mouse::BUTTON_RIGHT
812
+
813
+ %%
814
+ NAME press
815
+ MOD Event::MouseButtonDown
816
+ TYPE #
817
+ PURPOSE Whether mouse button is pressed or not
818
+ RVAL true
819
+
820
+ PROTO
821
+ press
822
+
823
+ DESC
824
+ Always returns true.
825
+
826
+ SEEALSO
827
+ Event::MouseButtonUp#press
828
+
829
+ %%
830
+ NAME x
831
+ MOD Event::MouseButtonDown
832
+ TYPE #
833
+ PURPOSE The X coordinate of the mouse at press time.
834
+ RVAL UINT
835
+
836
+ PROTO
837
+ x
838
+
839
+ DESC
840
+ Returns the X coordinate of the mouse.
841
+
842
+ SEEALSO
843
+ Mouse.state
844
+
845
+ %%
846
+ NAME y
847
+ MOD Event::MouseButtonDown
848
+ TYPE #
849
+ PURPOSE The Y coordinate of the mouse at press time
850
+ RVAL UINT
851
+
852
+ PROTO
853
+ y
854
+
855
+ DESC
856
+ Returns the Y coordinate of the mouse at press time.
857
+
858
+ SEEALSO
859
+ Mouse.state
860
+
861
+ %%
862
+ NAME button
863
+ MOD Event::MouseButtonUp
864
+ TYPE #
865
+ PURPOSE The mouse button index
866
+
867
+ PROTO
868
+ button
869
+
870
+ DESC
871
+ Returns number of the button released:
872
+ * SDL::Mouse::BUTTON_LEFT
873
+ * SDL::Mouse::BUTTON_MIDDLE
874
+ * SDL::Mouse::BUTTON_RIGHT
875
+
876
+ %%
877
+ NAME press
878
+ MOD Event::MouseButtonUp
879
+ TYPE #
880
+ PURPOSE Whether mouse button is pressed or not
881
+ RVAL false
882
+
883
+ PROTO
884
+ press
885
+
886
+ DESC
887
+ Always returns false.
888
+
889
+ SEEALSO
890
+ Event::MouseButtonDown#press
891
+
892
+ %%
893
+ NAME x
894
+ MOD Event::MouseButtonUp
895
+ TYPE #
896
+ PURPOSE The X coordinate of the mouse at release time
897
+ RVAL UINT
898
+
899
+ PROTO
900
+ x
901
+
902
+ DESC
903
+ Returns the X coordinate of the mouse at release time.
904
+
905
+ SEEALSO
906
+ Mouse.state
907
+
908
+ %%
909
+ NAME y
910
+ MOD Event::MouseButtonUp
911
+ TYPE #
912
+ PURPOSE The Y coordinate of the mouse at release time.
913
+ RVAL UINT
914
+
915
+ PROTO
916
+ y
917
+
918
+ DESC
919
+ Returns the Y coordinate of the mouse at release time.
920
+
921
+ SEEALSO
922
+ Mouse.state
923
+
924
+ %%
925
+ NAME which
926
+ MOD Event::JoyAxis
927
+ TYPE #
928
+ PURPOSE Joystick device index
929
+ RVAL Integer
930
+
931
+ PROTO
932
+ which
933
+
934
+ DESC
935
+ Returns the index of the joystick that reported the event.
936
+
937
+ SEEALSO
938
+ Joystick
939
+ Joystick#num_axes
940
+
941
+ %%
942
+ NAME axis
943
+ MOD Event::JoyAxis
944
+ TYPE #
945
+ PURPOSE JoyAxis axis index
946
+ RVAL Integer
947
+
948
+ PROTO
949
+ axis
950
+
951
+ DESC
952
+ Returns the index of the axis that reported the event.
953
+
954
+ SEEALSO
955
+ Joystick
956
+
957
+ %%
958
+ NAME value
959
+ MOD Event::JoyAxis
960
+ TYPE #
961
+ PURPOSE Axis value
962
+ RVAL -32767 - 32767
963
+
964
+ PROTO
965
+ value
966
+
967
+ DESC
968
+ Returns the position of the axis in -32767 .. 32767.
969
+
970
+ SEEALSO
971
+ Joystick
972
+ Joystick#axis
973
+
974
+ %%
975
+ NAME which
976
+ MOD Event::JoyBall
977
+ TYPE #
978
+ PURPOSE Joystick device index
979
+ RVAL Integer
980
+
981
+ PROTO
982
+ which
983
+
984
+ DESC
985
+ Returns the index of the joystick that reported the event.
986
+
987
+ SEEALSO
988
+ Joystick
989
+
990
+ %%
991
+ NAME ball
992
+ MOD Event::JoyBall
993
+ TYPE #
994
+ PURPOSE Joystick trackball index
995
+ RVAL Integer
996
+
997
+ PROTO
998
+ ball
999
+
1000
+ DESC
1001
+ Returns the index of the trackball that reported the event.
1002
+
1003
+ SEEALSO
1004
+ Joystick
1005
+ Joystick#num_balls
1006
+
1007
+ %%
1008
+ NAME xrel
1009
+ MOD Event::JoyBall
1010
+ TYPE #
1011
+ PURPOSE The relative motion in the X direction
1012
+ RVAL Integer
1013
+
1014
+ PROTO
1015
+ xrel
1016
+
1017
+ DESC
1018
+ Returns the relative motion in the X direction as Integer.
1019
+ This value is the change in position on the ball since it was last polled.
1020
+
1021
+ SEEALSO
1022
+ Joystick
1023
+ Joystick#ball
1024
+
1025
+ %%
1026
+ NAME yrel
1027
+ MOD Event::JoyBall
1028
+ TYPE #
1029
+ PURPOSE The relative motion in the Y direction.
1030
+
1031
+ RVAL Integer
1032
+
1033
+ PROTO
1034
+ yrel
1035
+
1036
+ DESC
1037
+ Returns the relative motion in the Y direction as Integer.
1038
+ This value is the change in position on the ball since it was last polled.
1039
+
1040
+ SEEALSO
1041
+ Joystick
1042
+ Joystick#ball
1043
+
1044
+ %%
1045
+ NAME which
1046
+ MOD Event::JoyHat
1047
+ TYPE #
1048
+ PURPOSE Joystick device index
1049
+ RVAL Integer
1050
+
1051
+ PROTO
1052
+ which
1053
+
1054
+ DESC
1055
+ Returns the index of the joystick that reported the event.
1056
+
1057
+ SEEALSO
1058
+ Joystick
1059
+
1060
+ %%
1061
+ NAME hat
1062
+ MOD Event::JoyHat
1063
+ TYPE #
1064
+ PURPOSE Joystick hat index
1065
+ RVAL Integer
1066
+
1067
+ PROTO
1068
+ hat
1069
+
1070
+ DESC
1071
+ Returns the index of the hat that reported the event.
1072
+
1073
+ SEEALSO
1074
+ Joystick
1075
+ Joystick#num_hats
1076
+
1077
+ %%
1078
+ NAME value
1079
+ MOD Event::JoyHat
1080
+ TYPE #
1081
+ PURPOSE Hat position
1082
+ RVAL UINT
1083
+
1084
+ PROTO
1085
+ value
1086
+
1087
+ DESC
1088
+ Returns the current position of the hat. It is a logically OR'd
1089
+ combination of the following values (whose meanings should be pretty obvious:) :
1090
+
1091
+ * SDL::Joystick::HAT_CENTERED
1092
+ * SDL::Joystick::HAT_UP
1093
+ * SDL::Joystick::HAT_RIGHT
1094
+ * SDL::Joystick::HAT_DOWN
1095
+ * SDL::Joystick::HAT_LEFT
1096
+
1097
+ The following defines are also provided:
1098
+ * SDL::Joystick::HAT_RIGHTUP
1099
+ * SDL::Joystick::HAT_RIGHTDOWN
1100
+ * SDL::Joystick::HAT_LEFTUP
1101
+ * SDL::Joystick::HAT_LEFTDOWN
1102
+
1103
+ %%
1104
+ NAME which
1105
+ MOD Event::JoyButtonDown
1106
+ TYPE #
1107
+ PURPOSE Joystick device index
1108
+ RVAL Integer
1109
+
1110
+ PROTO
1111
+ which
1112
+
1113
+ DESC
1114
+ Returns the index of the joystick that reported the event.
1115
+
1116
+ SEEALSO
1117
+ Joystick
1118
+
1119
+ %%
1120
+ NAME button
1121
+ MOD Event::JoyButtonDown
1122
+ TYPE #
1123
+ PURPOSE Joystick button index
1124
+ RVAL Integer
1125
+
1126
+ PROTO
1127
+ button
1128
+
1129
+ DESC
1130
+ Returns the index of the button that reported the event.
1131
+
1132
+ SEEALSO
1133
+ Joystick
1134
+ Joystick#num_buttons
1135
+
1136
+ %%
1137
+ NAME press
1138
+ MOD Event::JoyButtonDown
1139
+ TYPE #
1140
+ PURPOSE Joystick button is pressed or released
1141
+ RVAL true
1142
+
1143
+ PROTO
1144
+ press
1145
+
1146
+ DESC
1147
+ Returns whether this event is button press event.
1148
+ Always returns true.
1149
+
1150
+ SEEALSO
1151
+ Event::JoyButtonUp#press
1152
+ Joystick#button
1153
+
1154
+ %%
1155
+ NAME which
1156
+ MOD Event::JoyButtonUp
1157
+ TYPE
1158
+ PURPOSE Joystick device index
1159
+ RVAL Integer
1160
+
1161
+ PROTO
1162
+ which
1163
+
1164
+ DESC
1165
+ Returns the index of the joystick that reported the event.
1166
+
1167
+ SEEALSO
1168
+ Joystick
1169
+
1170
+ %%
1171
+ NAME button
1172
+ MOD Event::JoyButtonUp
1173
+ TYPE #
1174
+ PURPOSE Joystick button index
1175
+ RVAL Integer
1176
+
1177
+ PROTO
1178
+ button
1179
+
1180
+ DESC
1181
+ Returns the index of the button that reported the event.
1182
+
1183
+ SEEALSO
1184
+ Joystick
1185
+ Joystick#num_buttons
1186
+
1187
+ %%
1188
+ NAME press
1189
+ MOD Event::JoyButtonUp
1190
+ TYPE #
1191
+ PURPOSE Joystick button is pressed or released
1192
+ RVAL false
1193
+
1194
+ PROTO
1195
+ press
1196
+
1197
+ DESC
1198
+ Returns whether this event is button press event.
1199
+ Always returns false.
1200
+
1201
+ SEEALSO
1202
+ Event::JoyButtonDown#press
1203
+ Joystick#button
1204
+
1205
+ %%
1206
+ NAME w
1207
+ MOD Event::VideoResize
1208
+ TYPE #
1209
+ PURPOSE New width of the window.
1210
+ RVAL Integer
1211
+
1212
+ PROTO
1213
+ w
1214
+
1215
+ DESC
1216
+ Returns the new width of the window when window is resized.
1217
+
1218
+ %%
1219
+ NAME h
1220
+ MOD Event::VideoResize
1221
+ TYPE #
1222
+ PURPOSE New height of the window
1223
+ RVAL Integer
1224
+
1225
+ PROTO
1226
+ h
1227
+
1228
+ DESC
1229
+ Returns the new width of the window when window is resized.
1230
+
1231
+ %%
1232
+ NAME scan
1233
+ MOD Key
1234
+ TYPE .
1235
+ PURPOSE Get a snapshot of the current keyboard state
1236
+
1237
+ PROTO
1238
+ scan
1239
+
1240
+ DESC
1241
+ Gets a snapshot of the current keyboard state.
1242
+ You can check this state with @[Key.press?].
1243
+
1244
+ NOTE
1245
+ Call @[Event.poll] or @[Event.wait] to update the state.
1246
+
1247
+ SEEALSO
1248
+ Key.press?
1249
+ Event::KeyDown
1250
+ Event::KeyUp
1251
+ Event.poll
1252
+
1253
+ %%
1254
+ NAME press?
1255
+ MOD Key
1256
+ TYPE .
1257
+ PURPOSE Get the current keyboard state.
1258
+ RVAL true/false
1259
+
1260
+ PROTO
1261
+ press?(key)
1262
+
1263
+ DESC
1264
+ Returns true if $[key] is pressed, otherwise returns false.
1265
+ Please use ((<Key symbol>)) as parameter.
1266
+
1267
+ SEEALSO
1268
+ Key.scan
1269
+ Event::KeyDown
1270
+ Event::KeyUp
1271
+
1272
+ %%
1273
+ NAME mod_state
1274
+ MOD Key
1275
+ TYPE .
1276
+ PURPOSE Get the state of modifier keys.
1277
+ RVAL UINT
1278
+
1279
+ PROTO
1280
+ mod_state
1281
+ modState
1282
+
1283
+ DESC
1284
+ Returns the current state of the modifier keys (CTRL, ALT, etc.).
1285
+ The return value can be an OR'd combination of:
1286
+ :SDL::Key::MOD_NONE
1287
+ :SDL::Key::MOD_LSHIFT
1288
+ :SDL::Key::MOD_RSHIFT
1289
+ :SDL::Key::MOD_LCTRL
1290
+ :SDL::Key::MOD_RCTRL
1291
+ :SDL::Key::MOD_LALT
1292
+ :SDL::Key::MOD_RALT
1293
+ :SDL::Key::MOD_LMETA
1294
+ :SDL::Key::MOD_RMETA
1295
+ :SDL::Key::MOD_NUM
1296
+ :SDL::Key::MOD_CAPS
1297
+ :SDL::Key::MOD_MODE
1298
+
1299
+ SDL also defines the following symbols for convenience:
1300
+ * SDL::Key::MOD_CTRL = SDL::Key::MOD_LCTRL|SDL::Key::MOD_RCTRL
1301
+ * SDL::Key::MOD_SHIFT = SDL::Key::MOD_LSHIFT|SDL::Key::MOD_RSHIFT
1302
+ * SDL::Key::MOD_ALT = SDL::Key::MOD_LALT|SDL::Key::MOD_RALT
1303
+ * SDL::Key::MOD_META = SDL::Key::MOD_LMETA|SDL::Key::MOD_RMETA
1304
+
1305
+ SEEALSO
1306
+ Key.scan
1307
+
1308
+ %%
1309
+ NAME get_key_name
1310
+ MOD Key
1311
+ TYPE .
1312
+ PURPOSE Get the name of an SDL virtual keysym
1313
+ RVAL String
1314
+
1315
+ PROTO
1316
+ get_key_name(key)
1317
+ getKeyName(key)
1318
+
1319
+ DESC
1320
+ Returns the SDL-defined name of the $[key] ((<key symbol|Key symbol>)).
1321
+
1322
+ %%
1323
+ NAME enable_key_repeat
1324
+ MOD Key
1325
+ TYPE .
1326
+ PURPOSE Set keyboard repeat rate.
1327
+
1328
+ PROTO
1329
+ enable_key_repeat(delay,interval)
1330
+ enableKeyRepeat(delay,interval)
1331
+
1332
+ DESC
1333
+ Enables the keyboard repeat rate. $[delay] specifies how long the key must be pressed before it
1334
+ begins repeating, it then repeats at the speed specified by $[interval]. Both delay and interval are
1335
+ expressed in milliseconds.
1336
+
1337
+ Good default values are SDL::Key::DEFAULT_REPEAT_DELAY and
1338
+ SDL::Key::DEFAULT_REPEAT_INTERVAL.
1339
+
1340
+ EXCEPTION *
1341
+
1342
+ SEEALSO
1343
+ Key.disable_key_repeat
1344
+
1345
+ %%
1346
+ NAME disable_key_repeat
1347
+ MOD Key
1348
+ TYPE .
1349
+ PURPOSE Disable key repeat.
1350
+
1351
+ PROTO
1352
+ disable_key_repeat
1353
+ disableKeyRepeat
1354
+
1355
+ DESC
1356
+ Disables key repeat.
1357
+
1358
+ EXCEPTION *
1359
+
1360
+ SEEALSO
1361
+ Key.enable_key_repeat
1362
+
1363
+ %%
1364
+ NAME state
1365
+ MOD Mouse
1366
+ TYPE .
1367
+ PURPOSE Retrieve the current state of the mouse
1368
+ RVAL [Integer, Integer, true/false, true/false, true/false]
1369
+ PROTO
1370
+ state
1371
+
1372
+ DESC
1373
+ Returns an array of five element:
1374
+ [ X coordinate, Y coordinate, left button is pressed?, middle button is pressed?, right button is pressed?]
1375
+
1376
+ EXAMPLE
1377
+ x, y, lbutton, * = SDL::Mouse.state
1378
+ if lbutton
1379
+ print "Left Mouse Button is pressed \n"
1380
+ end
1381
+
1382
+ SEEALSO
1383
+ Event::MouseMotion
1384
+ Event::MouseButtonDown
1385
+ Event::MouseButtonUp
1386
+
1387
+ %%
1388
+ NAME warp
1389
+ MOD Mouse
1390
+ TYPE .
1391
+ PURPOSE Set the position of the mouse cursor.
1392
+
1393
+ PROTO
1394
+ warp(x,y)
1395
+
1396
+ DESC
1397
+ Set the position of the mouse cursor (generates a mouse motion event).
1398
+
1399
+ SEEALSO
1400
+ Event::MouseMotion
1401
+
1402
+ %%
1403
+ NAME show
1404
+ MOD Mouse
1405
+ TYPE .
1406
+ PURPOSE Toggle the cursor is shown on the screen.
1407
+
1408
+ PROTO
1409
+ show
1410
+
1411
+ DESC
1412
+ Shows cursor.
1413
+
1414
+ The cursor starts off displayed, but can be turned off.
1415
+
1416
+ SEEALSO
1417
+ Mouse.hide
1418
+ Mouse.show?
1419
+
1420
+ %%
1421
+ NAME hide
1422
+ MOD Mouse
1423
+ TYPE .
1424
+ PURPOSE Hide cursor.
1425
+
1426
+ PROTO
1427
+ hide
1428
+
1429
+ DESC
1430
+ Hide cursor.
1431
+
1432
+ SEEALSO
1433
+ Mouse.show
1434
+ Mouse.show?
1435
+
1436
+ %%
1437
+ NAME show?
1438
+ MOD Mouse
1439
+ TYPE .
1440
+ PURPOSE Get the state of mouse cursor.
1441
+ RVAL true/false
1442
+
1443
+ PROTO
1444
+ show?
1445
+
1446
+ DESC
1447
+ Returns true if mouse cursor is shown, otherwise returns false.
1448
+
1449
+ SEEALSO
1450
+ Mouse.show
1451
+ Mouse.hide
1452
+
1453
+ %%
1454
+ NAME set_cursor
1455
+ MOD Mouse
1456
+ TYPE .
1457
+ PURPOSE Set the currently active mouse cursor.
1458
+
1459
+ PROTO
1460
+ set_cursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0)
1461
+ setCursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0)
1462
+
1463
+ DESC
1464
+ Sets the currently active cursor to the specified one. If the cursor is currently visible, the change
1465
+ will be immediately represented on the display.
1466
+
1467
+ $[bitmap] is shape of cursor, given by the instance of @[Surface].
1468
+ $[white] is white color pixel value in $[bitmap],
1469
+ $[black] is black color pixel value in $[bitmap],
1470
+ $[transparent] is transparent pixel value in $[bitmap],
1471
+ $[inverted] is inverted pixel value in $[bitmap].
1472
+ The cursor width must be a multiple of 8 bits.
1473
+
1474
+ SEEALSO
1475
+ Surface
1476
+