Module: Rubygame::Events::JoystickButtonEvent

Included in:
JoystickButtonPressed, JoystickButtonReleased
Defined in:
lib/rubygame/events/joystick_events.rb

Overview

JoystickButtonEvent is a mixin module included in the JoystickButtonPressed and JoystickButtonReleased classes. It defines the #joystick_id and #button attribute readers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#buttonObject (readonly)

Returns the value of attribute button.



94
95
96
# File 'lib/rubygame/events/joystick_events.rb', line 94

def button
  @button
end

#joystick_idObject (readonly)

Returns the value of attribute joystick_id.



94
95
96
# File 'lib/rubygame/events/joystick_events.rb', line 94

def joystick_id
  @joystick_id
end

Instance Method Details

#initialize(joystick_id, button) ⇒ Object

Initializes the JoystickButtonEvent.

joystick_id

an integer identifying which joystick changed. The first joystick is 0.

button

an integer identifying which button was pressed or released. The first button on each joystick is 0.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/rubygame/events/joystick_events.rb', line 105

def initialize( joystick_id, button )

  unless joystick_id.kind_of?(Fixnum) and joystick_id >= 0
    raise ArgumentError, "joystick_id must be an integer >= 0"
  end

  @joystick_id = joystick_id

  unless button.kind_of?(Fixnum) and button >= 0
    raise ArgumentError, "button must be an integer >= 0"
  end

  @button = button

end