Class Joystick::Device |
|
Methods |
Public Class methods |
new(VALUE klass, VALUE path) |
Open and allocate a new Joystick::Device object.
This method also accepts a block.
Aliases:
Joystick::Device::open
Examples:
joy = Joystick::Device.new '/dev/input/js0' # read a joystick device in block mode Joystick::Device::open('/dev/input/js0') { |joy| # ... do stuff ... }
open(VALUE klass, VALUE path) |
Open and allocate a new Joystick::Device object.
This method also accepts a block.
Aliases:
Joystick::Device::open
Examples:
joy = Joystick::Device.new '/dev/input/js0' # read a joystick device in block mode Joystick::Device::open('/dev/input/js0') { |joy| # ... do stuff ... }
initialize(VALUE self) |
Constructor for Joystick::Device.
Note: this method should never be called directly.
Public Instance methods |
pending?() |
next_event(VALUE self) |
Return the next Joystick::Event from a Joystick::Device object.
Note: For performance reasons, only one joystick event is allocated per device. Calling this method will silently overwrite old events for this device.
This method will block if no data is waiting to be read, so you should probably test the Joystick::Device object with Joystick::Device#pending? before calling this method.
Aliases:
Joystick::Device::ev Joystick::Device::event Joystick::Device::next_ev
Example:
ev = joy.next_event
axes(VALUE self) |
Return the number of axes for this joystick.
Note: Don't forget that each joypad has two axes.
Aliases:
Joystick::Device#num_axes
Example:
puts "This joystick has #{joy.axes / 2} pads."
buttons(VALUE self) |
Return the number of buttons for this Joystick::Device object.
Aliases:
Joystick::Device#num_buttons
Example:
puts "This joystick has #{joy.buttons / 2} buttons."
name(VALUE self) |
Return the name of this Joystick::Device object.
Note: not all joysticks have descriptive names.
Example:
puts "Joystick Name: #{joy.name}"
fd(VALUE self) |
close(VALUE self) |
Close a Joystick::Device object.
Note: You cannot read or write to a closed joystick device.
Example:
joy.close