Class OpenSkyhawk::HIDAxis
ClassList > OpenSkyhawk > HIDAxis
HID axis handler. Declared at sketch scope for each joystick axis. More...
#include <SimGateway.h>
Public Functions
| Type | Name |
|---|---|
| HIDAxis (uint16_t controlId, uint8_t axisIndex) Register a HID axis handler. |
|
| uint8_t | axisIndex () const Joystick axis index (0–7) this handler drives. |
| uint16_t | controlId () const controlId this handler is registered for. |
| void | dispatch (uint16_t value) Dispatch a value to the joystick axis. |
| HIDAxis * | next () const Next axis in list; nullptr at end. |
Public Static Functions
| Type | Name |
|---|---|
| HIDAxis * | head () First registered axis; nullptr if none. |
Detailed Description
Self-registers into a static linked list at construction. SimGateway::loop() walks the list and writes the calibrated value into the HID axis report when a frame with a matching controlId arrives. The 0–65535 unsigned value from PanelGroup is mapped to signed ±32767 internally (value − 32768).
Declare at file scope, not inside functions — C++ constructs file-scope objects before setup() runs, which is required for the linked list to be populated.
Calibration is never a constructor argument. Endpoints are per-unit — sensor spread, magnet geometry, print tolerance — so baking them in would mean a reflash per build, which is exactly the limitation this design removes. They live in flash, are loaded once by SimGateway::setup(), and are looked up by axisIndex. Sketch declarations are therefore identical calibrated or not.
Public Functions Documentation
function HIDAxis
Register a HID axis handler.
OpenSkyhawk::HIDAxis::HIDAxis (
uint16_t controlId,
uint8_t axisIndex
)
Parameters:
controlIdCTRL_* constant from HIDControls.h (0x0010–0x001F range).axisIndexHID report axis index (0–7).
function axisIndex
Joystick axis index (0–7) this handler drives.
uint8_t OpenSkyhawk::HIDAxis::axisIndex () const
function controlId
controlId this handler is registered for.
uint16_t OpenSkyhawk::HIDAxis::controlId () const
function dispatch
Dispatch a value to the joystick axis.
void OpenSkyhawk::HIDAxis::dispatch (
uint16_t value
)
Parameters:
valueUnsigned 0–65535 as emitted by the node, pre-calibration.
Applies the stored calibration first, then the fixed unsigned→signed offset. Order matters: the pipeline stays unsigned until the final step, so the map never divides on signed values.
Note:
The −32768 offset is invariant, not calibration-dependent. Two different centres are in play: AxisCal::centre is the axis's physical rest point, which the map absorbs; −32768 is the re-centring of a 16-bit range, a property of the representation. axisCalApply() always returns 0–65535, so making the offset variable would apply the centring twice.
function next
Next axis in list; nullptr at end.
HIDAxis * OpenSkyhawk::HIDAxis::next () const
Public Static Functions Documentation
function head
First registered axis; nullptr if none.
static HIDAxis * OpenSkyhawk::HIDAxis::head ()
The documentation for this class was generated from the following file Firmware/Libraries/SimGateway/SimGateway.h