Papers3 improvements (#611)

- And Tab5 keyboard improvements
- Usb host keyboard improvements
- Symbols
- Requires the device.py change from CL-32 PR but that only affects visuals and not build breaking
This commit is contained in:
Shadowtrance
2026-08-08 23:02:49 +10:00
committed by GitHub
parent 564d8af64c
commit dc3f6104b8
14 changed files with 251 additions and 92 deletions
@@ -108,7 +108,16 @@ static uint32_t hid_keycode_to_key(uint8_t modifier, uint8_t key_code,
default: break;
}
if (ctrl || alt) return 0;
/*
* Ctrl and Alt no longer suppress the key.
*
* They used to return 0 here, which meant a chord like Ctrl+C produced nothing at all and a
* terminal application could never see it. The modifiers are now reported alongside the key in
* UsbHidEvent instead, so the plain character still comes through and a consumer that wants a
* control code derives it. Alt is passed through on the same basis.
*/
(void)ctrl;
(void)alt;
if (key_code < (sizeof(keycode2ascii) / sizeof(keycode2ascii[0]))) {
bool is_letter = (key_code >= 0x04 && key_code <= 0x1D);
@@ -157,6 +166,10 @@ static void hid_interface_callback(hid_host_device_handle_t handle,
if (params.proto == HID_PROTOCOL_KEYBOARD) {
if (data_len < sizeof(hid_keyboard_input_report_boot_t)) break;
auto* kb = reinterpret_cast<const hid_keyboard_input_report_boot_t*>(data);
const bool with_ctrl = (kb->modifier.val & HID_LEFT_CONTROL) ||
(kb->modifier.val & HID_RIGHT_CONTROL);
const bool with_alt = (kb->modifier.val & HID_LEFT_ALT) ||
(kb->modifier.val & HID_RIGHT_ALT);
for (int i = 0; i < HID_KEYBOARD_KEY_MAX; i++) {
uint8_t prev_hid = ctx->prev_keys[i];
@@ -169,7 +182,7 @@ static void hid_interface_callback(hid_host_device_handle_t handle,
uint32_t lv_key = ctx->pressed_lv_keys[prev_hid];
ctx->pressed_lv_keys[prev_hid] = 0;
if (lv_key) {
UsbHidEvent evt = { .type = USB_HID_EVENT_KEY, .key = { lv_key, false } };
UsbHidEvent evt = { .type = USB_HID_EVENT_KEY, .key = { lv_key, false, with_ctrl, with_alt } };
publish_event(ctx, &evt);
}
}
@@ -208,7 +221,10 @@ static void hid_interface_callback(hid_host_device_handle_t handle,
uint32_t lv_key = hid_keycode_to_key(kb->modifier.val, hid_code,
ctx->caps_lock_active, ctx->num_lock_active);
if (lv_key) {
UsbHidEvent evt = { .type = USB_HID_EVENT_KEY, .key = { lv_key, true } };
UsbHidEvent evt = {
.type = USB_HID_EVENT_KEY,
.key = { lv_key, true, with_ctrl, with_alt }
};
publish_event(ctx, &evt);
ctx->pressed_lv_keys[hid_code] = lv_key;
}