Initial physical button mapping implementation #4

This commit is contained in:
Nik Rozman
2026-03-03 11:44:38 +01:00
parent dcc50150b8
commit 5c36aa041e
8 changed files with 321 additions and 33 deletions
+12 -2
View File
@@ -10,6 +10,7 @@
#define FEATURE_AUTO_RECAL
#define FEATURE_BATTERY_MONITOR
#define FEATURE_BOOT_LOOP_DETECT
#define FEATURE_PHYSICAL_BUTTONS
// ─── Debug ────────────────────────────────────────────────────────────────────
// #define DEBUG
@@ -53,7 +54,10 @@
// ─── Persistence ──────────────────────────────────────────────────────────────
#define CONFIG_FILENAME "/imu_mouse_cfg.bin"
#define CONFIG_MAGIC 0xDEAD123CUL
#define CONFIG_MAGIC 0xDEAD123DUL
// ─── Physical button sentinel ─────────────────────────────────────────────────
#define BTN_PIN_NONE 0xFF // Stored in btn*Pin when that button is disabled
// ─── Runtime feature-override flags (cfg.featureFlags bitmask) ───────────────
// These mirror the compile-time FEATURE_* defines but can be toggled at runtime
@@ -94,6 +98,9 @@ struct Config {
float jerkThreshold; // jerk² threshold for tap-freeze detection
uint8_t tapFreezeEnabled; // 1 = enable jerk-based cursor freeze during taps
uint8_t featureFlags; // bitmask of FLAG_* — runtime feature overrides
uint8_t btnLeftPin; // BTN_PIN_NONE or Arduino pin number (0-10 = D0-D10)
uint8_t btnRightPin;
uint8_t btnMiddlePin;
};
extern Config cfg;
extern const Config CFG_DEFAULTS;
@@ -113,8 +120,11 @@ struct __attribute__((packed)) ConfigBlob {
uint8_t tapFreezeEnabled; // [19] 1 = enable jerk-based cursor freeze during taps
float jerkThreshold; // [20] jerk² tap-freeze threshold
uint8_t featureFlags; // [24] FLAG_* bitmask — runtime feature overrides
uint8_t btnLeftPin; // [25] BTN_PIN_NONE or Arduino pin (0-10 = D0-D10)
uint8_t btnRightPin; // [26]
uint8_t btnMiddlePin; // [27]
};
static_assert(sizeof(ConfigBlob) == 25, "ConfigBlob must be 25 bytes");
static_assert(sizeof(ConfigBlob) == 28, "ConfigBlob must be 28 bytes");
// ─── TelemetryPacket (24 bytes) ───────────────────────────────────────────────
#ifdef FEATURE_TELEMETRY