Remove button mapping
This commit is contained in:
@@ -77,9 +77,6 @@ void pushConfigBlob() {
|
||||
b.tapFreezeEnabled = cfg.tapFreezeEnabled;
|
||||
b.jerkThreshold = cfg.jerkThreshold;
|
||||
b.featureFlags = cfg.featureFlags;
|
||||
b.btnLeftPin = cfg.btnLeftPin;
|
||||
b.btnRightPin = cfg.btnRightPin;
|
||||
b.btnMiddlePin = cfg.btnMiddlePin;
|
||||
cfgBlob.write((uint8_t*)&b, sizeof(b));
|
||||
}
|
||||
#endif
|
||||
@@ -125,13 +122,6 @@ void onConfigBlobWrite(uint16_t h, BLECharacteristic* c, uint8_t* d, uint16_t l)
|
||||
cfg.tapFreezeEnabled = b->tapFreezeEnabled ? 1 : 0;
|
||||
if (b->jerkThreshold >= 100.0f && b->jerkThreshold <= 50000.0f) cfg.jerkThreshold = b->jerkThreshold;
|
||||
cfg.featureFlags = b->featureFlags & (FLAG_TAP_ENABLED | FLAG_TEMP_COMP_ENABLED | FLAG_AUTO_RECAL_ENABLED);
|
||||
// btnXPin: accept BTN_PIN_NONE (0xFF) or a valid Arduino pin number (0-10 = D0-D10)
|
||||
cfg.btnLeftPin = (b->btnLeftPin <= 10 || b->btnLeftPin == BTN_PIN_NONE) ? b->btnLeftPin : BTN_PIN_NONE;
|
||||
cfg.btnRightPin = (b->btnRightPin <= 10 || b->btnRightPin == BTN_PIN_NONE) ? b->btnRightPin : BTN_PIN_NONE;
|
||||
cfg.btnMiddlePin = (b->btnMiddlePin <= 10 || b->btnMiddlePin == BTN_PIN_NONE) ? b->btnMiddlePin : BTN_PIN_NONE;
|
||||
#ifdef FEATURE_PHYSICAL_BUTTONS
|
||||
setupPhysicalButtons(); // reconfigure pins immediately (no restart needed)
|
||||
#endif
|
||||
saveConfig();
|
||||
Serial.print("[CFG] Written - sens="); Serial.print(cfg.sensitivity,0);
|
||||
Serial.print(" dz="); Serial.print(cfg.deadZone,3);
|
||||
|
||||
@@ -13,19 +13,19 @@ void setupPhysicalButtons() {
|
||||
if (physBtnMask && Bluefruit.connected()) { blehid.mouseButtonRelease(); }
|
||||
physBtnMask = 0;
|
||||
|
||||
if (cfg.btnLeftPin != BTN_PIN_NONE) pinMode(cfg.btnLeftPin, INPUT_PULLUP);
|
||||
if (cfg.btnRightPin != BTN_PIN_NONE) pinMode(cfg.btnRightPin, INPUT_PULLUP);
|
||||
if (cfg.btnMiddlePin != BTN_PIN_NONE) pinMode(cfg.btnMiddlePin, INPUT_PULLUP);
|
||||
if (BTN_LEFT_PIN != BTN_PIN_NONE) pinMode(BTN_LEFT_PIN, INPUT_PULLUP);
|
||||
if (BTN_RIGHT_PIN != BTN_PIN_NONE) pinMode(BTN_RIGHT_PIN, INPUT_PULLUP);
|
||||
if (BTN_MIDDLE_PIN != BTN_PIN_NONE) pinMode(BTN_MIDDLE_PIN, INPUT_PULLUP);
|
||||
|
||||
bool any = (cfg.btnLeftPin != BTN_PIN_NONE) || (cfg.btnRightPin != BTN_PIN_NONE)
|
||||
|| (cfg.btnMiddlePin != BTN_PIN_NONE);
|
||||
bool any = (BTN_LEFT_PIN != BTN_PIN_NONE) || (BTN_RIGHT_PIN != BTN_PIN_NONE)
|
||||
|| (BTN_MIDDLE_PIN != BTN_PIN_NONE);
|
||||
if (any) {
|
||||
Serial.print("[BTN] L=");
|
||||
cfg.btnLeftPin == BTN_PIN_NONE ? Serial.print("--") : Serial.print(cfg.btnLeftPin);
|
||||
BTN_LEFT_PIN == BTN_PIN_NONE ? Serial.print("--") : Serial.print(BTN_LEFT_PIN);
|
||||
Serial.print(" R=");
|
||||
cfg.btnRightPin == BTN_PIN_NONE ? Serial.print("--") : Serial.print(cfg.btnRightPin);
|
||||
BTN_RIGHT_PIN == BTN_PIN_NONE ? Serial.print("--") : Serial.print(BTN_RIGHT_PIN);
|
||||
Serial.print(" M=");
|
||||
cfg.btnMiddlePin == BTN_PIN_NONE ? Serial.print("--") : Serial.print(cfg.btnMiddlePin);
|
||||
BTN_MIDDLE_PIN == BTN_PIN_NONE ? Serial.print("--") : Serial.print(BTN_MIDDLE_PIN);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,9 @@ void processPhysicalButtons() {
|
||||
if (!Bluefruit.connected()) return;
|
||||
|
||||
uint8_t newMask = 0;
|
||||
if (cfg.btnLeftPin != BTN_PIN_NONE && digitalRead(cfg.btnLeftPin) == LOW) newMask |= MOUSE_BUTTON_LEFT;
|
||||
if (cfg.btnRightPin != BTN_PIN_NONE && digitalRead(cfg.btnRightPin) == LOW) newMask |= MOUSE_BUTTON_RIGHT;
|
||||
if (cfg.btnMiddlePin != BTN_PIN_NONE && digitalRead(cfg.btnMiddlePin) == LOW) newMask |= MOUSE_BUTTON_MIDDLE;
|
||||
if (BTN_LEFT_PIN != BTN_PIN_NONE && digitalRead(BTN_LEFT_PIN) == LOW) newMask |= MOUSE_BUTTON_LEFT;
|
||||
if (BTN_RIGHT_PIN != BTN_PIN_NONE && digitalRead(BTN_RIGHT_PIN) == LOW) newMask |= MOUSE_BUTTON_RIGHT;
|
||||
if (BTN_MIDDLE_PIN != BTN_PIN_NONE && digitalRead(BTN_MIDDLE_PIN) == LOW) newMask |= MOUSE_BUTTON_MIDDLE;
|
||||
|
||||
if (newMask != physBtnMask) {
|
||||
physBtnMask = newMask;
|
||||
|
||||
@@ -56,8 +56,12 @@
|
||||
#define CONFIG_FILENAME "/imu_mouse_cfg.bin"
|
||||
#define CONFIG_MAGIC 0xDEAD123EUL
|
||||
|
||||
// Physical button sentinel
|
||||
#define BTN_PIN_NONE 0xFF // Stored in btn*Pin when that button is disabled
|
||||
// Physical button pin assignments (hardcoded - set to 0xFF to disable a button)
|
||||
// Valid pin numbers: 0-10 (Arduino D0-D10 on XIAO nRF52840 Sense)
|
||||
#define BTN_PIN_NONE 0xFF
|
||||
#define BTN_LEFT_PIN BTN_PIN_NONE // e.g. 0 for D0
|
||||
#define BTN_RIGHT_PIN BTN_PIN_NONE // e.g. 1 for D1
|
||||
#define BTN_MIDDLE_PIN BTN_PIN_NONE // e.g. 2 for D2
|
||||
|
||||
// Runtime feature-override flags (cfg.featureFlags bitmask)
|
||||
// These mirror the compile-time FEATURE_* defines but can be toggled at runtime
|
||||
@@ -98,9 +102,6 @@ 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;
|
||||
@@ -120,11 +121,8 @@ 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) == 28, "ConfigBlob must be 28 bytes");
|
||||
static_assert(sizeof(ConfigBlob) == 25, "ConfigBlob must be 25 bytes");
|
||||
|
||||
// TelemetryPacket (24 bytes)
|
||||
#ifdef FEATURE_TELEMETRY
|
||||
|
||||
@@ -47,8 +47,7 @@ Config cfg;
|
||||
const Config CFG_DEFAULTS = {
|
||||
CONFIG_MAGIC, 600.0f, 0.060f, 0.08f, CURVE_LINEAR, 0x00, CHARGE_SLOW,
|
||||
/*tapThreshold=*/12, /*tapAction=*/TAP_ACTION_LEFT, /*tapKey=*/0, /*tapMod=*/0,
|
||||
/*jerkThreshold=*/2000.0f, /*tapFreezeEnabled=*/1, /*featureFlags=*/FLAG_ALL_DEFAULT,
|
||||
/*btnLeftPin=*/BTN_PIN_NONE, /*btnRightPin=*/BTN_PIN_NONE, /*btnMiddlePin=*/BTN_PIN_NONE
|
||||
/*jerkThreshold=*/2000.0f, /*tapFreezeEnabled=*/1, /*featureFlags=*/FLAG_ALL_DEFAULT
|
||||
};
|
||||
|
||||
// Telemetry definition
|
||||
|
||||
Reference in New Issue
Block a user