Class: Artoo::Drivers::Ps3

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

Overview

The Ps3 controller driver behaviors

Constant Summary collapse

BUTTON_MAP =
{
  0 => 'square',
  1 => 'x',
  2 => 'circle',
  3 => 'triangle',
  4 => 'l1',
  5 => 'r1',
  6 => 'l2',
  7 => 'r2',
  8 => 'select',
  9 => 'start',
  10 => 'left_joystick',
  11 => 'right_joystick',
  12 => 'home'
}

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



38
39
40
# File 'lib/artoo/drivers/ps3.rb', line 38

def button_letter(b)
  BUTTON_MAP[b]
end

#handle_joystickObject



23
24
25
26
27
28
29
30
31
# File 'lib/artoo/drivers/ps3.rb', line 23

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

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

#publish_button(b) ⇒ Object



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

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