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 RW
The input device filehandle
- event_format R
The
event_format
setting- neutral_offset R
The
neutral_offset
setting- thread R
The thread reading from the device file.
- timer R
Concurrent::TimerTask that periodically checks for device presence.
Public Class Methods
Create a new device adapter for a Rifle-Mounted Controller.
Public Instance Methods
If the device hasn’t been set up and is available, attempt to start it. If it has disappeared, stop what we’re doing, recover if it comes back.
Return a Hash that contains information describing this device for intra-device communication; overridden to set the correct vendor
.
Concurrent::Actor API — shut down cleanly.
Start listening for incoming input events and translating them to BDE messages.
Stop the device.
Protected Instance Methods
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.
Build a Concurrent::TimerTask that opens the RMC device if present, or ensures it is closed if not.
Create a Enumerator that yields raw events from the input device.
Map the event from axis+value to a single type.
Open the input device.
Start reading input events.
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.