Class Joystick::Event
In: joystick.c
Parent: Object
Methods
initialize    number    time    type    value   
Public Class methods
initialize(VALUE self)

Constructor for Joystick::Event objects.

Note: you should never call this method directly.

Public Instance methods
time(VALUE self)

Return the timestamp (in milliseconds) of this Joystick::Event.

Example:

  stamp = ev.time
value(VALUE self)

Return the value of this Joystick::Event object.

The content of Joystick::Event#value varies depending on the type of event. For Joystick::Event::AXIS events, the value is the direction (and optionally magnitude) of the axis (eg, -32767 for maximum right/up, 19931 for partial left/down, etc). For Joystick::Event:BUTTON events, the value is usually 1 or 0, for button presses and button releases, respectively.

Aliases:

  Joystick::Event#val

Example:

  puts "The button was " <<
       ((ev.value != 0) ? 'pressed' : 'released') <<
       "." if ev.type == Joystick::Event::BUTTON
type(VALUE self)

Return the type of this Joystick::Event object.

Values:

  Joystick::Event::INIT
  Joystick::Event::BUTTON
  Joystick::Event::AXIS

Example:

  case ev.type
  when Joystick::Event::INIT
    puts 'init'
  when Joystick::Event::BUTTON
    puts "button: #{ev.num}, #{ev.val}"
  when Joystick::Event::AXIS
    puts "axis: #{ev.num}, #{ev.val}"
  end
number(VALUE self)

Return the number of this Joystick::Event object.

The value of Joystick::Event#number is the axis or button of the event.

Aliases:

  Joystick::Event#num

Example:

  puts "You're using joypad #{(ev.num / 2) + 1}." \
    if ev.type == Joystick::Event::AXIS