Key selection via UI - #2
Open
ChrisVeigl wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
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
keycomboUI control that captures keydown events and sendsN:<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 +
keyboardReportcall 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 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 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 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 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); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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