Class: RubyHid::Axis

Inherits:
Observer show all
Defined in:
lib/ruby_hid/axis.rb

Overview

An axis is a continuous control coming from a HID device. These are most often the output from joysticks.

The most common values for axes range from 0 to 255. In this case the central (resting) position is 128.

Axis includes d-pad axes, which have a distinctly different set of values.

  • -1 up or left

  • 0 centre

  • 1 down or right

Constant Summary collapse

EVENTS =

List of Axes, with names

Naming is mostly the stick name followed by x or y for the direction.

{
  0 => :left_x,
  1 => :left_y,
  2 => :right_x,
  5 => :right_y,
  6 => :throttle,
  16 => :dpad_x,
  17 => :dpad_y
}
DPAD_KEYS =
[:dpad_x, :dpad_y]

Instance Attribute Summary

Attributes inherited from Observer

#code, #events, #name

Instance Method Summary collapse

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_sObject

Quick summary of the button



40
41
42
# File 'lib/ruby_hid/axis.rb', line 40

def to_s
  "Axis: #{code} - #{name}"
end