Class: Artoo::Drivers::Xbox360

Inherits:
Joystick
  • Object
show all
Defined in:
lib/artoo/drivers/xbox360.rb

Overview

The Xbox360 controller driver behaviors

Constant Summary collapse

BUTTON_MAP =
{
  0 => 'a',
  1 => 'b',
  2 => 'x',
  3 => 'y',
  4 => 'lb',
  5 => 'rb',
  6 => 'back',
  7 => 'start'
}

Instance Attribute Summary

Attributes inherited from Joystick

#button_values

Instance Method Summary collapse

Methods inherited from Joystick

#handle_buttons, #handle_message_events, #handle_trackball, #publish_joystick, #start_driver

Instance Method Details

#button_letter(b) ⇒ Object



33
34
35
# File 'lib/artoo/drivers/xbox360.rb', line 33

def button_letter(b)
  BUTTON_MAP[b]
end

#handle_joystickObject



18
19
20
21
22
23
24
25
26
# File 'lib/artoo/drivers/xbox360.rb', line 18

def handle_joystick
  x0 = connection.axis(0)
  y0 = connection.axis(1)
  publish_joystick(0, x0, y0)

  x1 = connection.axis(3)
  y1 = connection.axis(4)
  publish_joystick(1, x1, y1)        
end

#publish_button(b) ⇒ Object



28
29
30
31
# File 'lib/artoo/drivers/xbox360.rb', line 28

def publish_button(b)
  publish(event_topic_name("button_#{button_letter(b)}"))
  super
end