class SDL2::Joystick

TODO: == Joystick Overview ==

A joystick may have many Axes

A Joystick may have many balls.

A Joystick may have many buttons.

A Joystick has all kinds of components, such as

A Joystick may have many hats.

Public Class Methods

name(idx) click to toggle source

Returns the name of a joystick

# File lib/sdl2/joystick.rb, line 25
def self.name(idx)
  SDL2.joystick_name_for_index!(idx)
end
num() click to toggle source

Returns the number of attached joysticks on success or a exception on failure

# File lib/sdl2/joystick.rb, line 15
def self.num
  SDL2.num_joysticks!
end
open(idx) click to toggle source

Returns a joystick identifier or raises exception on error

# File lib/sdl2/joystick.rb, line 20
def self.open(idx)      
  SDL2.joystick_open!(idx)
end
release(pointer) click to toggle source
# File lib/sdl2/joystick.rb, line 9
def self.release(pointer)
  SDL2.joystick_close(pointer)
end
update() click to toggle source

update the current state of open joysticks

# File lib/sdl2/joystick.rb, line 30
def self.update()
  SDL2.joystick_update()
end

Public Instance Methods

axes() click to toggle source

Enumerator for Axes

# File lib/sdl2/joystick.rb, line 40
def axes
  @axes ||= Axes.new(self)
end
balls() click to toggle source

Enumerator for balls

# File lib/sdl2/joystick.rb, line 46
def balls
  @balls ||= Balls.new(self)
end
buttons() click to toggle source

Enumerator for buttons

# File lib/sdl2/joystick.rb, line 52
def buttons
  @buttons ||= Buttons.new(self)
end
event_state(state = SDL2::Event::STATE::QUERY) click to toggle source

Event state @param - state

== SDL2::Event::STATE::QUERY [default]: Returns current state
== SDL2::Event::STATE::IGNORE : Disables event dispatching
== SDL2::Event::STATE::ENABLE : Enables event dispatching

@returns - true if events enabled

# File lib/sdl2/joystick.rb, line 79
def event_state(state = SDL2::Event::STATE::QUERY)
  SDL2.joystick_event_state(state)
end
get_guid() click to toggle source

Get the GUID

# File lib/sdl2/joystick.rb, line 69
def get_guid()
  SDL2.joystick_get_guid!(self)
end
hats() click to toggle source

Enumerator for hats

# File lib/sdl2/joystick.rb, line 58
def hats
  @hats ||= Hats.new(self)
end
instance_id() click to toggle source

Get the device index of an opened joystick

# File lib/sdl2/joystick.rb, line 64
def instance_id()
  SDL2.joystick_instance_id!(self)
end
name() click to toggle source

Returns the name of the joystick

# File lib/sdl2/joystick.rb, line 35
def name()
  SDL2.joystick_name(self)
end