class Artoo::Adaptors::Joystick
Connect to a joystick device @see device documentation for more information
Attributes
joystick[R]
Public Instance Methods
axis(n)
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 55 def axis(n) ::SDL.JoystickGetAxis(joystick, n) end
ball(n)
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 63 def ball(n) ::SDL.JoystickGetBall(joystick, n) end
connect()
click to toggle source
Creates a connection with device @return [Boolean]
Calls superclass method
# File lib/artoo/adaptors/joystick.rb, line 12 def connect require 'ruby-sdl-ffi' unless defined?(::SDL) ::SDL.Init( ::SDL::INIT_JOYSTICK ) raise "No SDL joystick available" if num_joysticks == 0 @joystick = ::SDL.JoystickOpen(0) # TODO: allow user to choose which joystick super end
disconnect()
click to toggle source
Closes connection with device @return [Boolean]
Calls superclass method
# File lib/artoo/adaptors/joystick.rb, line 26 def disconnect ::SDL.JoystickClose(joystick) super end
firmware_name()
click to toggle source
Name of device @return [String]
# File lib/artoo/adaptors/joystick.rb, line 33 def firmware_name ::SDL.JoystickName(0) end
hat(n)
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 71 def hat(n) ::SDL.JoystickGetHat(joystick, n) end
num_axes()
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 51 def num_axes ::SDL.JoystickNumAxes(joystick) end
num_balls()
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 59 def num_balls ::SDL.JoystickNumBalls(joystick) end
num_hats()
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 67 def num_hats ::SDL.JoystickNumHats(joystick) end
num_joysticks()
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 47 def num_joysticks ::SDL.NumJoysticks end
poll()
click to toggle source
# File lib/artoo/adaptors/joystick.rb, line 43 def poll ::SDL.JoystickUpdate end
version()
click to toggle source
Version of device @return [String]
# File lib/artoo/adaptors/joystick.rb, line 39 def version Artoo::Joystick::VERSION end