Skip to content

Key selection via UI - #2

Open
ChrisVeigl wants to merge 6 commits into
mainfrom
key-selection-via-ui
Open

Key selection via UI#2
ChrisVeigl wants to merge 6 commits into
mainfrom
key-selection-via-ui

Conversation

@ChrisVeigl

Copy link
Copy Markdown
Contributor

a few changes that enable use of desired keys (including combinations with modifier key, such as Ctrl+C or Alt+F5).
the key selection is done in the web ui by detecting the key combinations entered in the input fields for Key1 and Key2

Copilot AI lite review requested due to automatic review settings August 18, 2026 16:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables selecting arbitrary USB HID key codes and modifier combinations (e.g., Ctrl+C / Alt+F5) from the web UI, and updates the firmware protocol/storage to support sending those combinations over BLE HID.

Changes:

  • Added a new keycombo UI control that captures keydown events and sends N:<keycode>:<modifier> to the device.
  • Updated firmware to store per-button HID keycode + modifier, and to compute modifiers from currently pressed buttons when sending HID reports.
  • Updated documentation for the new keycombo behavior and added “Mode 4 - disabled” for relay output.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
ui/config.html Adds key-combo input handling and HID key mapping/formatting helpers for the web UI.
src/main.cpp Switches from enum-based key selection to raw HID keycode/modifier storage + reporting; adds output mode 4.
README.md Documents key combo assignment format and new output mode.
Suppressed comments (1)

src/main.cpp:298

  • Same readability issue as the press path: the modifier aggregation + keyboardReport call is hard to follow when written as a single line.
      removeActiveKey(button_keycodes[i]);
      { uint8_t mods = 0; for (uint8_t j = 0; j < NUM_BUTTONS; j++) if (buttonStates & (1 << j)) mods |= button_modifiers[j]; blehid.keyboardReport(mods, active_keys); }
      //if (ENABLE_ACTIVITY_LED ) dToggle(LED_R);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ui/config.html Outdated
Comment on lines +264 to +269
el.addEventListener("keydown", (e) => {
e.preventDefault();
if (["Control","Alt","Shift","Meta"].includes(e.key)) return;
const hid = browserCodeToHID(e.code);
if (hid === undefined) { el.value = "(unsupported: " + e.code + ")"; return; }
let mod = 0;
Comment thread ui/config.html
Comment on lines +378 to +386
function formatKeyCombo(keycode, modifier) {
if (!keycode) return "(none)";
const mods = [];
if (modifier & 0x11) mods.push('Ctrl');
if (modifier & 0x22) mods.push('Shift');
if (modifier & 0x44) mods.push('Alt');
if (modifier & 0x88) mods.push('Win');
return [...mods, hidKeycodeToName(keycode)].join('+');
}
Comment thread src/main.cpp
Comment on lines +438 to +444
uint8_t btnIdx = buf[0] - '1';
char *sep = strchr(buf+2, ':');
uint8_t newKeycode = (uint8_t)String(buf+2).toInt();
uint8_t newModifier = sep ? (uint8_t)String(sep+1).toInt() : 0;
Serial.print("Prev: "); Serial.print(button_keycodes[btnIdx]); Serial.print(":"); Serial.println(button_modifiers[btnIdx]);
button_keycodes[btnIdx] = newKeycode;
button_modifiers[btnIdx] = newModifier;
Comment thread src/main.cpp Outdated
Comment on lines +285 to +286
addActiveKey(button_keycodes[i]);
{ uint8_t mods = 0; for (uint8_t j = 0; j < NUM_BUTTONS; j++) if (buttonStates & (1 << j)) mods |= button_modifiers[j]; blehid.keyboardReport(mods, active_keys); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants