Add Bluetooth HID remote control support
Integrate BLE keyboard host functionality for page-turner remotes. Adds device pairing, button mapping, preset configurations for Free2/Free3 remotes, and persistent storage of mappings. Migrates from open-x4-sdk to freeink-sdk submodule which includes the BleKeyboardHost library. Implements CPU frequency locking during BLE operations to prevent watchdog timeouts.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// CrossPoint <-> FreeInk BLE HID host glue.
|
||||
//
|
||||
// Thin, capability-safe helpers around freeink::BleKeyboardHost (the `BleHid`
|
||||
// singleton). When FREEINK_CAP_BLE_HID_HOST is compiled out the SDK links stubs,
|
||||
// so every call here is still valid and simply no-ops / returns false — callers
|
||||
// need no #ifdefs.
|
||||
//
|
||||
// The (kind, value) pair produced by encodeKey() is the stable identity stored in
|
||||
// CrossPointSettings::bleKeyMap. Page-turner remotes emit "special" keys
|
||||
// (PageUp/PageDown/arrows); plain keyboards emit usage codes. We deliberately
|
||||
// ignore modifiers and the printable char for matching (page turners don't use
|
||||
// modifiers), keeping the persisted entry a trivial two-byte comparison.
|
||||
|
||||
#include <BleKeyboardHost.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace bleinput {
|
||||
|
||||
// Advertised central name shown to peripherals during pairing.
|
||||
inline constexpr const char* kHostName = "CrossPoint";
|
||||
|
||||
// Start the BLE HID host (idempotent). Returns false if BLE is compiled out or
|
||||
// NimBLE init failed. Safe to call repeatedly.
|
||||
bool ensureStarted();
|
||||
|
||||
// Drop the active link (e.g. before deep sleep or when the user disables BT).
|
||||
void stop();
|
||||
|
||||
// Encode a decoded key event into the stable (kind, value) identity used by the
|
||||
// settings map. kind: 0 = SpecialKey, 1 = HID usage. Returns false when the event
|
||||
// carries no usable identity (no special key and no usage code).
|
||||
bool encodeKey(const freeink::KeyEvent& ev, uint8_t& kind, uint8_t& value);
|
||||
|
||||
// Human-readable name for a stored (kind, value) identity, for the mapping UI.
|
||||
// Writes a null-terminated string into out (e.g. "Page Down", "Key 0x4B").
|
||||
void describeKey(uint8_t kind, uint8_t value, char* out, size_t outLen);
|
||||
|
||||
} // namespace bleinput
|
||||
Reference in New Issue
Block a user