rubysdl 1.3.1 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MANIFEST +22 -2
- data/NEWS.en +80 -0
- data/NEWS.ja +83 -0
- data/README.en +2 -1
- data/README.ja +2 -2
- data/doc-en/Makefile +18 -0
- data/doc-en/cdrom.rsd +417 -0
- data/doc-en/collision.rsd +174 -0
- data/doc-en/event.rsd +1476 -0
- data/doc-en/font.rsd +811 -0
- data/doc-en/general.rsd +43 -0
- data/doc-en/init.rsd +168 -0
- data/doc-en/joystick.rsd +401 -0
- data/doc-en/mixer.rsd +869 -0
- data/doc-en/mpeg.rsd +585 -0
- data/doc-en/opengl.rsd +155 -0
- data/doc-en/sdlskk.rsd +472 -0
- data/doc-en/time.rsd +46 -0
- data/doc-en/video.rsd +2806 -0
- data/doc-en/wm.rsd +112 -0
- data/doc/Makefile +1 -1
- data/doc/cdrom.rsd +3 -3
- data/doc/event.rsd +178 -179
- data/doc/general.rsd +10 -0
- data/doc/init.rsd +2 -2
- data/doc/joystick.rsd +29 -5
- data/doc/mixer.rsd +20 -0
- data/doc/rsd.rb +42 -9
- data/doc/sdlskk.rsd +7 -7
- data/doc/video.rsd +461 -168
- data/doc/wm.rsd +2 -2
- data/extconf.rb +1 -8
- data/lib/rubysdl_aliases.rb +52 -190
- data/lib/rubysdl_compatible_ver1.rb +243 -0
- data/lib/sdl.rb +58 -92
- data/rubysdl.h +59 -68
- data/rubysdl_cdrom.c +125 -102
- data/{rubysdl_doc.en.rd → rubysdl_doc_old.en.rd} +3 -2
- data/rubysdl_event.c +318 -255
- data/rubysdl_event_key.c +299 -287
- data/rubysdl_image.c +37 -13
- data/rubysdl_joystick.c +180 -67
- data/rubysdl_kanji.c +61 -75
- data/rubysdl_main.c +65 -138
- data/rubysdl_mixer.c +339 -214
- data/rubysdl_mouse.c +50 -43
- data/rubysdl_opengl.c +31 -28
- data/rubysdl_pixel.c +17 -28
- data/rubysdl_ref.en.html +5658 -0
- data/rubysdl_ref.en.rd +6337 -0
- data/rubysdl_ref.html +2253 -1964
- data/rubysdl_ref.rd +823 -469
- data/rubysdl_rwops.c +9 -6
- data/rubysdl_sdlskk.c +137 -165
- data/rubysdl_sge_video.c +355 -469
- data/rubysdl_smpeg.c +189 -190
- data/rubysdl_time.c +1 -1
- data/rubysdl_ttf.c +147 -215
- data/rubysdl_video.c +486 -405
- data/rubysdl_wm.c +30 -30
- data/sample/aadraw.rb +9 -9
- data/sample/alpha.rb +12 -13
- data/sample/alphadraw.rb +10 -10
- data/sample/bfont.rb +4 -4
- data/sample/cdrom.rb +11 -4
- data/sample/collision.rb +20 -20
- data/sample/cursor.rb +5 -5
- data/sample/ellipses.rb +20 -16
- data/sample/event2.rb +11 -9
- data/sample/font.rb +4 -4
- data/sample/fpstimer.rb +3 -3
- data/sample/icon.bmp.gz +0 -0
- data/sample/icon.png +0 -0
- data/sample/joy2.rb +14 -14
- data/sample/kanji.rb +7 -7
- data/sample/load_from_io.rb +44 -0
- data/sample/movesp.rb +13 -12
- data/sample/playmod.rb +2 -3
- data/sample/plaympeg.rb +8 -8
- data/sample/playwave.rb +5 -6
- data/sample/sdlskk.rb +11 -11
- data/sample/sgetest.rb +14 -12
- data/sample/stetris.rb +12 -13
- data/sample/testgl.rb +13 -14
- data/sample/testsprite.rb +12 -11
- data/sample/transformblit.rb +23 -22
- metadata +62 -35
- data/rubysdl_event2.c +0 -417
data/doc-en/general.rsd
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
= Contents
|
2
|
+
* ((<"Ruby/SDL Outline">))
|
3
|
+
* ((<Initialize>))
|
4
|
+
* ((<Video>))
|
5
|
+
* ((<OpenGL>))
|
6
|
+
* ((<Window Management>))
|
7
|
+
* ((<Event>))
|
8
|
+
* ((<Joystick>))
|
9
|
+
* ((<CD-ROM>))
|
10
|
+
* ((<Audio>))
|
11
|
+
* ((<Time>))
|
12
|
+
* ((<Font>))
|
13
|
+
* ((<Collision Detection>))
|
14
|
+
* ((<SDLSKK>))
|
15
|
+
* ((<MPEG playback>))
|
16
|
+
|
17
|
+
= Ruby/SDL Outline
|
18
|
+
Ruby/SDL is Ruby extension library for
|
19
|
+
((<SDL|URL:http://www.libsdl.org/>)).
|
20
|
+
This library enables you to create games, demo, or so on.
|
21
|
+
|
22
|
+
Ruby/SDL has following functions.
|
23
|
+
* ((<access to 2D video framebuffer|Video>))
|
24
|
+
* Access ((<Keyboard and mouse|Event>)), ((<Joystick>)) input
|
25
|
+
* ((<Audio Playback|Audio>)) with ((<SDL_mixer|URL:http://www.libsdl.org/projects/SDL_mixer/index.html>))
|
26
|
+
* ((<Control CD-ROM|CD-ROM>))
|
27
|
+
* ((<Font drawing |Font>)) with ((<SDL_ttf|URL:http://www.libsdl.org/projects/SDL_ttf/index.html>)),
|
28
|
+
((<SDL_kanji|URL:http://shinh.skr.jp/sdlkanji/>)) and
|
29
|
+
((<SGE|URL:http://www.etek.chalmers.se/~e8cal1/sge/index.html>))
|
30
|
+
* ((<Using OpenGL|OpenGL>)) via ((<OpenGL Interface|URL:http://www2.giganet.net/~yoshi/>))
|
31
|
+
* ((<Dealing with time|Time>))
|
32
|
+
* ((<SKK like Japanese input|SDLSKK>)) with ((<SDLSKK|URL:http://www.kmc.gr.jp/~ohai/sdlskk.html>))
|
33
|
+
* ((<MPEG playback>)) with ((<SMPGE|URL:http://www.icculus.org/smpeg/>))
|
34
|
+
* ((<Window Management>)) and ((<Collision Detection>))
|
35
|
+
|
36
|
+
== SDL::Error
|
37
|
+
A Exception class for SDL specific errors.
|
38
|
+
This class is subclass of StandardError.
|
39
|
+
|
40
|
+
== SDL::VERSION
|
41
|
+
Ruby/SDL version string.
|
42
|
+
|
43
|
+
|
data/doc-en/init.rsd
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
= Initialize
|
2
|
+
TOC
|
3
|
+
|
4
|
+
Before SDL can be used in a program it must be initialized
|
5
|
+
with @[init]. @[init] initializes all the subsystems that
|
6
|
+
the user requests (video, audio, joystick, timers and/or cdrom).
|
7
|
+
|
8
|
+
== Methods
|
9
|
+
%%%
|
10
|
+
NAME init
|
11
|
+
TYPE .
|
12
|
+
PURPOSE Initializes SDL
|
13
|
+
|
14
|
+
PROTO
|
15
|
+
init(flags)
|
16
|
+
|
17
|
+
DESC
|
18
|
+
Initializes SDL. This should be called before all other
|
19
|
+
Ruby/SDL methods. The $[flags] parameter specifies what
|
20
|
+
part(s) of SDL to initialize.
|
21
|
+
:SDL::INIT_AUDIO
|
22
|
+
Initialize autio subsystems.
|
23
|
+
:SDL::INIT_VIDEO
|
24
|
+
Initialize @[Video] subsystem.
|
25
|
+
:SDL::INIT_CDROM
|
26
|
+
Initialize @[CDROM] subsystem.
|
27
|
+
:SDL::INIT_JOYSTICK
|
28
|
+
Initialize @[Joystick] subsystem.
|
29
|
+
:SDL::INIT_EVERYTHING
|
30
|
+
Initialize all of the avobe.
|
31
|
+
|
32
|
+
EXCEPTION *
|
33
|
+
|
34
|
+
%%
|
35
|
+
NAME quit
|
36
|
+
TYPE .
|
37
|
+
PURPOSE Shut down SDL
|
38
|
+
|
39
|
+
PROTO
|
40
|
+
quit
|
41
|
+
|
42
|
+
DESC
|
43
|
+
This method shots down all SDL subsystem and frees the resources
|
44
|
+
allocated to them. Because this method is automatically called
|
45
|
+
when ruby stops, you don't have to call this function normally.
|
46
|
+
|
47
|
+
You should know SDL and Ruby/SDL very well when you use
|
48
|
+
this method.
|
49
|
+
|
50
|
+
%%
|
51
|
+
NAME inited_system
|
52
|
+
TYPE .
|
53
|
+
PURPOSE Check which subsystems are initialized
|
54
|
+
RVAL UINT
|
55
|
+
|
56
|
+
PROTO
|
57
|
+
inited_system(flags)
|
58
|
+
initedSystem(flags)
|
59
|
+
|
60
|
+
DESC
|
61
|
+
This method allows you to see which SDL subsytems have
|
62
|
+
been @[initialized|init]. $[flags] is a bitwise OR'd
|
63
|
+
combination of the subsystems you wish to check
|
64
|
+
(see @[init] for a list of subsystem flags).
|
65
|
+
|
66
|
+
RET
|
67
|
+
Returns a bitwised OR'd combination of the initialized subsystems.
|
68
|
+
|
69
|
+
EXAMPLE
|
70
|
+
# Here are several ways you can use SDL.inited_system
|
71
|
+
|
72
|
+
# Get init data on all the subsystem
|
73
|
+
subsystem_init = SDL.inited_system(SDL::INIT_EVERYTHING)
|
74
|
+
|
75
|
+
if subsystem_init & SDL::INIT_VIDEO
|
76
|
+
puts "video is initialized"
|
77
|
+
else
|
78
|
+
puts "video is not initialized"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Just check for one specfic subsystem
|
82
|
+
|
83
|
+
if SDL.inited_system(SDL::INIT_VIDEO) != 0
|
84
|
+
puts "Video is initialized"
|
85
|
+
else
|
86
|
+
puts "Video is not initialized "
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check for two subsystem
|
90
|
+
|
91
|
+
subsystem_mask = SDL::INIT_VIDEO|SDL::INIT_AUDIO;
|
92
|
+
|
93
|
+
if SDL.inited_system(subsystem_mask) == subsystem_mask
|
94
|
+
puts "Video and Audio initialized."
|
95
|
+
else
|
96
|
+
puts "Video and Audio not initialized"
|
97
|
+
end
|
98
|
+
|
99
|
+
SEEALSO
|
100
|
+
init
|
101
|
+
|
102
|
+
%%
|
103
|
+
NAME getenv
|
104
|
+
TYPE .
|
105
|
+
PURPOSE Get an environmental variable
|
106
|
+
RVAL String
|
107
|
+
|
108
|
+
PROTO
|
109
|
+
getenv(var)
|
110
|
+
|
111
|
+
DESC
|
112
|
+
Returns the environment variable string matched by $[var].
|
113
|
+
|
114
|
+
|
115
|
+
%%
|
116
|
+
NAME putenv
|
117
|
+
TYPE .
|
118
|
+
PURPOSE Change or add an environmental variable
|
119
|
+
|
120
|
+
PROTO
|
121
|
+
putenv(string)
|
122
|
+
|
123
|
+
DESC
|
124
|
+
Add or Change the value of environmental variables.
|
125
|
+
The argument $[string] is of the form "name=value"
|
126
|
+
|
127
|
+
If you want to change SDL_WINDOWID or SDL_VIDEODRIVER environmental variable
|
128
|
+
to modify the behavior of SDL in your program, you should use
|
129
|
+
this function instead of ENV.
|
130
|
+
|
131
|
+
EXCEPTION *
|
132
|
+
|
133
|
+
EXAMPLE
|
134
|
+
# from http://moriq.tdiary.net/20051006.html
|
135
|
+
# Apollo with Ruby/SDL
|
136
|
+
require 'phi'
|
137
|
+
require 'sdl'
|
138
|
+
|
139
|
+
# Create form
|
140
|
+
form = Phi::Form.new
|
141
|
+
$terminated = false
|
142
|
+
form.on_close{ $terminated = true }
|
143
|
+
form.caption = "Ruby/SDL on Phi::Form"
|
144
|
+
# Create a panel on new form
|
145
|
+
panel = Phi::Panel.new(form)
|
146
|
+
panel.align = Phi::AL_LEFT
|
147
|
+
|
148
|
+
# Put SDL window on panel with WINDOWID hack
|
149
|
+
SDL.putenv("SDL_VIDEODRIVER=windib")
|
150
|
+
SDL.putenv("SDL_WINDOWID=#{panel.handle}")
|
151
|
+
form.show
|
152
|
+
|
153
|
+
# initialize SDL
|
154
|
+
SDL.init(SDL::INIT_VIDEO)
|
155
|
+
screen = SDL.setVideoMode(640, 480, 16, SDL::SWSURFACE)
|
156
|
+
|
157
|
+
# main loop
|
158
|
+
unless $terminated
|
159
|
+
while event = SDL::Event2.poll
|
160
|
+
case event
|
161
|
+
when SDL::Event2::KeyDown, SDL::Event2::Quit
|
162
|
+
exit
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
sleep 0.05
|
167
|
+
end
|
168
|
+
|
data/doc-en/joystick.rsd
ADDED
@@ -0,0 +1,401 @@
|
|
1
|
+
= Joystick
|
2
|
+
* ((<Joystick Overview>))
|
3
|
+
* ((<SDL::Joystick>))
|
4
|
+
* Methods for Joystick
|
5
|
+
TOC
|
6
|
+
|
7
|
+
== Joystick Overview
|
8
|
+
Joysticks, and other similar input devices, have a very
|
9
|
+
strong role
|
10
|
+
in game playing and SDL provides comprehensive support for them.
|
11
|
+
Axes, Buttons, POV Hats and trackballs are all supported.
|
12
|
+
|
13
|
+
Joystick support is initialized
|
14
|
+
by passed the SDL::INIT_JOYSTICK flag
|
15
|
+
to @[init]. Once initilized joysticks must be opened
|
16
|
+
using @[Joystick.open].
|
17
|
+
|
18
|
+
While using the functions describe in this secton
|
19
|
+
may seem like the best way
|
20
|
+
to access and read from joysticks, in most cases they aren't.
|
21
|
+
Ideally joysticks should be read
|
22
|
+
using the @[Event] system.
|
23
|
+
To enable this, you must set the joystick event processing state
|
24
|
+
with @[Joystick.poll=].
|
25
|
+
Joysticks must be @[opened|Joystick.open]
|
26
|
+
before they can be used of course.
|
27
|
+
|
28
|
+
* NOTES
|
29
|
+
|
30
|
+
If you are ((*not*)) handling the joystick
|
31
|
+
via the event queue then you must explicitly
|
32
|
+
request a joystick update by calling @[Joystick.update_all].
|
33
|
+
|
34
|
+
Force Feedback is not yet support.
|
35
|
+
|
36
|
+
== SDL::Joystick
|
37
|
+
The class represents one joystick.
|
38
|
+
|
39
|
+
METHODS(Joystick)
|
40
|
+
|
41
|
+
== Methods
|
42
|
+
%%%
|
43
|
+
NAME num
|
44
|
+
MOD Joystick
|
45
|
+
TYPE .
|
46
|
+
PURPOSE Count available joysticks.
|
47
|
+
RVAL Integer
|
48
|
+
|
49
|
+
PROTO
|
50
|
+
num
|
51
|
+
|
52
|
+
DESC
|
53
|
+
Counts the number of joysticks attached to the system.
|
54
|
+
|
55
|
+
SEEALSO
|
56
|
+
Joystick.index_name
|
57
|
+
Joystick.open
|
58
|
+
|
59
|
+
%%
|
60
|
+
NAME index_name
|
61
|
+
MOD Joystick
|
62
|
+
TYPE .
|
63
|
+
PURPOSE Get joystick name.
|
64
|
+
RVAL String
|
65
|
+
|
66
|
+
PROTO
|
67
|
+
index_name(index)
|
68
|
+
indexName(index)
|
69
|
+
|
70
|
+
DESC
|
71
|
+
Get the implementation dependent name of joystick.
|
72
|
+
The $[index] parameter
|
73
|
+
refers to the N'th joystick on the system.
|
74
|
+
|
75
|
+
EXAMPLE
|
76
|
+
# Print the names of all attached joysticks
|
77
|
+
num_joy = SDL::Joystick.num
|
78
|
+
printf("%d joysticks found\n", num_joy)
|
79
|
+
num_joy.times do |i|
|
80
|
+
puts SDL::Joystick.index_name(i)
|
81
|
+
end
|
82
|
+
|
83
|
+
SEEALSO
|
84
|
+
Joystick.open
|
85
|
+
|
86
|
+
%%
|
87
|
+
NAME open
|
88
|
+
MOD Joystick
|
89
|
+
TYPE .
|
90
|
+
PURPOSE Opens a joystick for use.
|
91
|
+
RVAL SDL::Joystick
|
92
|
+
|
93
|
+
PROTO
|
94
|
+
open(index)
|
95
|
+
|
96
|
+
DESC
|
97
|
+
Opens a joystick for use within SDL. The $[index] refers to the N'th
|
98
|
+
joystick in the system. A joystick must be opened before it can be
|
99
|
+
used.
|
100
|
+
|
101
|
+
RET
|
102
|
+
Returns a @[Joystick] instance on success.
|
103
|
+
|
104
|
+
EXCEPTION *
|
105
|
+
|
106
|
+
EXAMPLE
|
107
|
+
# Check for joystick
|
108
|
+
if SDL::Joystick.num > 0
|
109
|
+
# Open joystick
|
110
|
+
joy = SDL::Joystick.open(0)
|
111
|
+
|
112
|
+
printf("Opened Joystick 0\n");
|
113
|
+
printf("Name: %s\n", SDL::Joystick.name(0))
|
114
|
+
printf("Number of Axes: %d\n", joy.num_axes)
|
115
|
+
printf("Number of Buttons: %d\n", joy.num_buttons)
|
116
|
+
printf("Number of Balls: %d\n", joy.num_balls)
|
117
|
+
end
|
118
|
+
|
119
|
+
%%
|
120
|
+
NAME open?
|
121
|
+
MOD Joystick
|
122
|
+
TYPE .
|
123
|
+
PURPOSE Determine if a joystick has been opened
|
124
|
+
RVAL true/false
|
125
|
+
|
126
|
+
PROTO
|
127
|
+
open?(index)
|
128
|
+
|
129
|
+
DESC
|
130
|
+
Determines whether a joystick has already been opened within the
|
131
|
+
application. $[index] refers to the N'th joystick on the system.
|
132
|
+
|
133
|
+
RET
|
134
|
+
Returns true if the joystick has been opened, or false if it has not.
|
135
|
+
|
136
|
+
SEEALSO
|
137
|
+
Joystick.open
|
138
|
+
|
139
|
+
%%
|
140
|
+
NAME index
|
141
|
+
MOD Joystick
|
142
|
+
TYPE #
|
143
|
+
PURPOSE Get the index of an joystick.
|
144
|
+
RVAL Integer
|
145
|
+
|
146
|
+
PROTO
|
147
|
+
index
|
148
|
+
|
149
|
+
DESC
|
150
|
+
Returns the index of $[self].
|
151
|
+
|
152
|
+
%%
|
153
|
+
NAME num_axes
|
154
|
+
MOD Joystick
|
155
|
+
TYPE #
|
156
|
+
PURPOSE Get the number of joystick axes
|
157
|
+
RVAL Integer
|
158
|
+
|
159
|
+
PROTO
|
160
|
+
num_axes
|
161
|
+
numAxes
|
162
|
+
|
163
|
+
DESC
|
164
|
+
Return the number of axes available.
|
165
|
+
|
166
|
+
NOTES
|
167
|
+
This method counts two dimensional axes as two axes.
|
168
|
+
|
169
|
+
SEEALSO
|
170
|
+
Joystick#axis
|
171
|
+
|
172
|
+
%%
|
173
|
+
NAME num_balls
|
174
|
+
MOD Joystick
|
175
|
+
TYPE #
|
176
|
+
PURPOSE Get the number of joystick trackballs
|
177
|
+
RVAL Integer
|
178
|
+
|
179
|
+
PROTO
|
180
|
+
num_balls
|
181
|
+
numBalls
|
182
|
+
|
183
|
+
DESC
|
184
|
+
Return the number of trackballs available.
|
185
|
+
|
186
|
+
SEEALSO
|
187
|
+
Joystick#ball
|
188
|
+
|
189
|
+
%%
|
190
|
+
NAME num_hats
|
191
|
+
MOD Joystick
|
192
|
+
TYPE #
|
193
|
+
PURPOSE Get the number of joystick hats
|
194
|
+
RVAL Integer
|
195
|
+
|
196
|
+
PROTO
|
197
|
+
num_hats
|
198
|
+
numHats
|
199
|
+
|
200
|
+
DESC
|
201
|
+
Return the number of hats available.
|
202
|
+
|
203
|
+
SEEALSO
|
204
|
+
Joystick#hat
|
205
|
+
|
206
|
+
%%
|
207
|
+
NAME num_buttons
|
208
|
+
MOD Joystick
|
209
|
+
TYPE #
|
210
|
+
PURPOSE Get the number of joystick buttons
|
211
|
+
RVAL Integer
|
212
|
+
|
213
|
+
PROTO
|
214
|
+
num_buttons
|
215
|
+
numButtons
|
216
|
+
|
217
|
+
DESC
|
218
|
+
Return the number of buttons available.
|
219
|
+
|
220
|
+
SEEALSO
|
221
|
+
Joystick#button
|
222
|
+
|
223
|
+
%%
|
224
|
+
NAME poll=
|
225
|
+
MOD Joystick
|
226
|
+
TYPE .
|
227
|
+
PURPOSE Enable/disable joystick event polling
|
228
|
+
|
229
|
+
PROTO
|
230
|
+
poll=(enable)
|
231
|
+
|
232
|
+
DESC
|
233
|
+
This function is used to enable or disable joystick event
|
234
|
+
processing. With joystick event processing disabled you will have
|
235
|
+
to update joystick states with @[Joystick.update_all] and read the
|
236
|
+
joystick information manually.
|
237
|
+
|
238
|
+
Joystick event polling is enabled by default.
|
239
|
+
|
240
|
+
NOTE
|
241
|
+
Joystick event handling is preferred.
|
242
|
+
|
243
|
+
Even if joystick event processing is enabled,
|
244
|
+
individual joysticks must be opened before they generate
|
245
|
+
events.
|
246
|
+
|
247
|
+
Calling this method may delete all events
|
248
|
+
currently in SDL's event queue.
|
249
|
+
|
250
|
+
SEEALSO
|
251
|
+
Joystick.update_all
|
252
|
+
Joystick.poll
|
253
|
+
Event2::JoyAxis
|
254
|
+
Event2::JoyBall
|
255
|
+
Event2::JoyButtonDown
|
256
|
+
Event2::JoyButtonUp
|
257
|
+
Event2::JoyHat
|
258
|
+
|
259
|
+
%%
|
260
|
+
NAME poll
|
261
|
+
MOD Joystick
|
262
|
+
TYPE .
|
263
|
+
PURPOSE Gets the current state of joysick event polling
|
264
|
+
RVAL true/false
|
265
|
+
|
266
|
+
PROTO
|
267
|
+
poll
|
268
|
+
|
269
|
+
DESC
|
270
|
+
Returns true if joysick event polling is enabled, otherwise
|
271
|
+
returns false. You will also read @[Joystick.poll=].
|
272
|
+
|
273
|
+
%%
|
274
|
+
NAME update_all
|
275
|
+
MOD Joystick
|
276
|
+
TYPE .
|
277
|
+
PURPOSE Updates the state of all joysticks
|
278
|
+
|
279
|
+
PROTO
|
280
|
+
update_all
|
281
|
+
updateAll
|
282
|
+
|
283
|
+
DESC
|
284
|
+
Updates the state(position, buttons, etc.) of all open joysticks.
|
285
|
+
If joystick events have been enabled with @[Joystick.poll=]
|
286
|
+
then this is called automatically in the event loop.
|
287
|
+
|
288
|
+
%%
|
289
|
+
NAME axis
|
290
|
+
MOD Joystick
|
291
|
+
TYPE #
|
292
|
+
PURPOSE Get the current state of an axis
|
293
|
+
RVAL Integer
|
294
|
+
|
295
|
+
PROTO
|
296
|
+
axis(axis_index)
|
297
|
+
|
298
|
+
DESC
|
299
|
+
Returns the current state of given $[axis_index] on $[self].
|
300
|
+
|
301
|
+
On most modern joysticks the X axis is usually represented by
|
302
|
+
axis 0 and the Y axis by axis 1. The value returned by
|
303
|
+
this method is a signed integer (-32768 to 32767)
|
304
|
+
representing the current position of the axis, it may be
|
305
|
+
necessary to impose certain tolerances on these values to account
|
306
|
+
for jitter.
|
307
|
+
|
308
|
+
EXAMPLE
|
309
|
+
joy = SDL::Joystick.open(0)
|
310
|
+
.
|
311
|
+
.
|
312
|
+
x_move = joy.axis(0)
|
313
|
+
y_move = joy.axis(1)
|
314
|
+
|
315
|
+
SEEALSO
|
316
|
+
Joystick#num_axes
|
317
|
+
|
318
|
+
%%
|
319
|
+
NAME hat
|
320
|
+
MOD Joystick
|
321
|
+
TYPE #
|
322
|
+
PURPOSE Get the current state of a joystick hat
|
323
|
+
RVAL UINT
|
324
|
+
|
325
|
+
PROTO
|
326
|
+
hat(hat_index)
|
327
|
+
|
328
|
+
DESC
|
329
|
+
Returns the current state of the given $[hat_index].
|
330
|
+
|
331
|
+
RET
|
332
|
+
The current state is returned as a unsinged integer
|
333
|
+
which is an OR'd combination of one or more of the following
|
334
|
+
|
335
|
+
* SDL::Joystick::HAT_CENTERED
|
336
|
+
* SDL::Joystick::HAT_UP
|
337
|
+
* SDL::Joystick::HAT_RIGHT
|
338
|
+
* SDL::Joystick::HAT_DOWN
|
339
|
+
* SDL::Joystick::HAT_LEFT
|
340
|
+
* SDL::Joystick::HAT_RIGHTUP
|
341
|
+
* SDL::Joystick::HAT_RIGHTDOWN
|
342
|
+
* SDL::Joystick::HAT_LEFTUP
|
343
|
+
* SDL::Joystick::HAT_LEFTDOWN
|
344
|
+
|
345
|
+
SEEALSO
|
346
|
+
Joystick#num_hats
|
347
|
+
|
348
|
+
%%
|
349
|
+
NAME button
|
350
|
+
MOD Joystick
|
351
|
+
TYPE #
|
352
|
+
PURPOSE Get the current state of a given button
|
353
|
+
RVAL true/false
|
354
|
+
|
355
|
+
PROTO
|
356
|
+
button(button_index)
|
357
|
+
|
358
|
+
DESC
|
359
|
+
returns the current state of the given $[button_index].
|
360
|
+
Returns true if the button is pressed, otherwise returns false.
|
361
|
+
|
362
|
+
SEEALSO
|
363
|
+
Joystick#num_buttons
|
364
|
+
|
365
|
+
%%
|
366
|
+
NAME ball
|
367
|
+
MOD Joystick
|
368
|
+
TYPE #
|
369
|
+
PURPOSE Get relative trackball motion
|
370
|
+
RVAL [Integer, Integer]
|
371
|
+
|
372
|
+
PROTO
|
373
|
+
ball(ball_index)
|
374
|
+
|
375
|
+
DESC
|
376
|
+
Get the ball axis change.
|
377
|
+
Trackballs can only return relative motion since the last call to
|
378
|
+
this method, these motion deltas are returned as
|
379
|
+
an array of two elements, [dx, dy].
|
380
|
+
|
381
|
+
EXCEPTION *
|
382
|
+
|
383
|
+
EXAMPLE
|
384
|
+
delta_x, delta_y = joy.ball(0)
|
385
|
+
printf("Trackball Delta- X:%d, Y:%d\n", delta_x, delta_y)
|
386
|
+
|
387
|
+
%%
|
388
|
+
NAME close
|
389
|
+
MOD Joystick
|
390
|
+
TYPE #
|
391
|
+
PURPOSE Closes a previously opened joystick
|
392
|
+
|
393
|
+
PROTO
|
394
|
+
close
|
395
|
+
|
396
|
+
DESC
|
397
|
+
Close a joystick that was previously opened with @[Joystick.open].
|
398
|
+
|
399
|
+
SEEALSO
|
400
|
+
Joystick.open
|
401
|
+
Joystick.open?
|