Class: RubyHid::Button
Overview
Button objects are observers of buttons on a controller. Buttons which are currently available are listed, by name in the EVENTS constant.
Buttons can have 2 values passed to each event:
-
1 - button down event
-
0 - button up event
To set the actions for a button use add_event:
= Button.find_by_name(:btn_1)
.add_event(lambda{ |value| puts "Button 1: #{value}" })
Constant Summary collapse
- EVENTS =
List of button types, with names
{ # joy pads 288 => :btn_1, 289 => :btn_2, 290 => :btn_3, 291 => :btn_4, 292 => :l1, 293 => :r1, 294 => :l2, 295 => :r2, 296 => :select, 297 => :start, 298 => :l_stick, 299 => :r_stick }
Instance Attribute Summary
Attributes inherited from Observer
Instance Method Summary collapse
-
#to_s ⇒ Object
Quick summary of the button.
Methods inherited from Observer
#add_event, build, find, find_by_name, #initialize, make_from_code, make_from_name, trigger_event, #trigger_events, unmapped_event_message
Constructor Details
This class inherits a constructor from RubyHid::Observer
Instance Method Details
#to_s ⇒ Object
Quick summary of the button
43 44 45 |
# File 'lib/ruby_hid/button.rb', line 43 def to_s "Button: #{code} - #{name}" end |