Ravn::HAL::Device::
RMC class
Superclass | Ravn::HAL::Device |
Ravn
Rifle-Mounted Controller device adapter
Portions of this file were adapted from the ruby-hid library, used under the terms of the MIT license:
Copyright (c) 2015 Andrew Faraday Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Refs: - rubygems.org/gems/ruby_hid - www.kernel.org/doc/html/latest/input/joydev/joystick-api.html - docs.google.com/document/d/1MEKZb9hTe3MaBTIhZ6xWYGHynFVtUeU4RkjodvK41ZA
Constants
- AXIS_CODE_MAP
Map of axis event codes to device event types
- BUTTON_CODE_MAP
Map of button event codes to device event types.
- EVENT_TYPES
JS_EVENT_BUTTON 0x01 /* button pressed/released / JS_EVENT_AXIS 0x02 / joystick moved / JS_EVENT_INIT 0x80 / initial state of device */
- Event
Event
type for raw input dataEvent
= Struct.new( :tv_sec, :tv_usec, :type, :code, :value ) do- MESSAGE_TYPE_MAP
Map of device event types to BDE message types:
BLE Joystick | SOC | Odin
Event
| GPIO | Button —————-|——-|—————————- Button 1 = On | P0.31 | “Mode-Shift”Button 2 = On | P0.02 | “Clear Display”Button 3 = On | P0.17 | “Joystick Center Switch”Button 4 = On | P0.24 | “Menu”Button 5 = On | P0.29 | “Back”Y-axis = -127 | P0.22 | “Joystick Forward”Y-axis = 127 | P0.15 | “Joystick Back”X-axis = 127 | P0.20 | “Joystick Right”X-axis = -127 | P0.13 | “Joystick Left”
Attributes
- axis_offset R
The
axis_offset
setting- axis_states R
Recorded axis states for coalescing axis events
- block_size R
The
block_size
setting- device R
The input device filehandle
- event_format R
The
event_format
setting- neutral_offset R
The
neutral_offset
setting
Public Class Methods
Create a new device adapter for a Rifle-Mounted Controller.
Public Instance Methods
Do discovery of rifle-mounted controllers.
Iterate over events read from the input device. Returns an enumerator if called without a block, or yields raw events to the block if one is provided.
Create a Enumerator that yields raw events from the input device.
Map the event from axis+value to a single type.
Concurrent::Actor API — Handle lifecycle events.
Open the input device.
Start listening for incoming input events and translating them to BDE messages.
Start reading input events.
Stop the device. :TODO: Hook this up to on_event
Return the code of the given axis_event
into a BDE message type, returning nil
if a message shouldn’t be sent.
Translate the type and code of the given input_event
into a BDE message type.