Class: SDL2::Joystick
- Defined in:
- lib/sdl2/joystick.rb,
lib/sdl2/joystick/axes.rb,
lib/sdl2/joystick/hats.rb,
lib/sdl2/joystick/balls.rb,
lib/sdl2/joystick/buttons.rb,
lib/sdl2/joystick/components.rb
Overview
A Joystick has all kinds of components, such as
Defined Under Namespace
Classes: Axes, Balls, Buttons, Components, Hats
Class Method Summary collapse
-
.name(idx) ⇒ Object
Returns the name of a joystick.
-
.num ⇒ Object
Returns the number of attached joysticks on success or a exception on failure.
-
.open(idx) ⇒ Object
Returns a joystick identifier or raises exception on error.
- .release(pointer) ⇒ Object
-
.update ⇒ Object
update the current state of open joysticks.
Instance Method Summary collapse
-
#axes ⇒ Object
Enumerator for Axes.
-
#balls ⇒ Object
Enumerator for balls.
-
#buttons ⇒ Object
Enumerator for buttons.
-
#event_state(state = SDL2::Event::STATE::QUERY) ⇒ Object
Event state.
-
#get_guid ⇒ Object
Get the GUID.
-
#hats ⇒ Object
Enumerator for hats.
-
#instance_id ⇒ Object
Get the device index of an opened joystick.
-
#name ⇒ Object
Returns the name of the joystick.
Methods inherited from Struct
#==, cast, create, #free, #initialize, #to_s, #update_members
Methods included from StructHelper
#member_readers, #member_writers
Constructor Details
This class inherits a constructor from SDL2::Struct
Class Method Details
.name(idx) ⇒ Object
Returns the name of a joystick
25 26 27 |
# File 'lib/sdl2/joystick.rb', line 25 def self.name(idx) SDL2.joystick_name_for_index!(idx) end |
.num ⇒ Object
Returns the number of attached joysticks on success or a exception on failure
15 16 17 |
# File 'lib/sdl2/joystick.rb', line 15 def self.num SDL2.num_joysticks! end |
.open(idx) ⇒ Object
Returns a joystick identifier or raises exception on error
20 21 22 |
# File 'lib/sdl2/joystick.rb', line 20 def self.open(idx) SDL2.joystick_open!(idx) end |
.release(pointer) ⇒ Object
9 10 11 |
# File 'lib/sdl2/joystick.rb', line 9 def self.release(pointer) SDL2.joystick_close(pointer) end |
.update ⇒ Object
update the current state of open joysticks
30 31 32 |
# File 'lib/sdl2/joystick.rb', line 30 def self.update() SDL2.joystick_update() end |
Instance Method Details
#axes ⇒ Object
Enumerator for Axes
40 41 42 |
# File 'lib/sdl2/joystick.rb', line 40 def axes @axes ||= Axes.new(self) end |
#balls ⇒ Object
Enumerator for balls
46 47 48 |
# File 'lib/sdl2/joystick.rb', line 46 def balls @balls ||= Balls.new(self) end |
#buttons ⇒ Object
Enumerator for buttons
52 53 54 |
# File 'lib/sdl2/joystick.rb', line 52 def @buttons ||= Buttons.new(self) end |
#event_state(state = SDL2::Event::STATE::QUERY) ⇒ Object
Event state
79 80 81 |
# File 'lib/sdl2/joystick.rb', line 79 def event_state(state = SDL2::Event::STATE::QUERY) SDL2.joystick_event_state(state) end |
#get_guid ⇒ Object
Get the GUID
69 70 71 |
# File 'lib/sdl2/joystick.rb', line 69 def get_guid() SDL2.joystick_get_guid!(self) end |
#hats ⇒ Object
Enumerator for hats
58 59 60 |
# File 'lib/sdl2/joystick.rb', line 58 def hats @hats ||= Hats.new(self) end |
#instance_id ⇒ Object
Get the device index of an opened joystick
64 65 66 |
# File 'lib/sdl2/joystick.rb', line 64 def instance_id() SDL2.joystick_instance_id!(self) end |
#name ⇒ Object
Returns the name of the joystick
35 36 37 |
# File 'lib/sdl2/joystick.rb', line 35 def name() SDL2.joystick_name(self) end |