Updates and fixes.

- Implement fix for keyboards not switching to boot mode properly, until full report parsing gets done.
  This is expected to improve support for certain models that were reported problematic.
- Implement fix for mouse acceleration omitting absolute mode
- Provide pass_to_os = true to not capture shift+backspace from the OS, it's annoying when you hold shift
  and mistype something, then want to use backspace but couldn't.
This commit is contained in:
Hrvoje Cavrak 2024-03-31 23:42:13 +02:00
parent 1cf90ae31d
commit b44ef2dc6f
4 changed files with 29 additions and 2 deletions

View File

@ -55,6 +55,7 @@ hotkey_combo_t hotkeys[] = {
{.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT,
.keys = {HID_KEY_BACKSPACE},
.key_count = 1,
.pass_to_os = true,
.action_handler = &output_config_hotkey_handler},
/* Erase stored config */
@ -191,6 +192,12 @@ void process_keyboard_report(uint8_t *raw_report, int length, device_t *state) {
if (length < KBD_REPORT_LENGTH)
return;
/* If the report is longer by 1 byte, we can assume the first byte is the report ID
and that the keyboard didn't switch to boot mode properly. Use this workaround
until full HID report parsing is implemented */
if (length == KBD_REPORT_LENGTH + 1)
keyboard_report = (hid_keyboard_report_t *)(raw_report + 1);
/* Check if any hotkey was pressed */
hotkey = check_all_hotkeys(keyboard_report, state);

View File

@ -52,7 +52,7 @@ int32_t accelerate(int32_t offset) {
return offset;
for (int i = 0; i < 7; i++) {
if (offset < acceleration[i].value) {
if (abs(offset) < acceleration[i].value) {
return offset * acceleration[i].factor;
}
}

View File

@ -103,6 +103,9 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const *desc_re
switch (itf_protocol) {
case HID_ITF_PROTOCOL_KEYBOARD:
if (ENFORCE_PORTS && BOARD_ROLE == PICO_B)
return;
/* Keeping this is required for setting leds from device set_report callback */
global_state.kbd_dev_addr = dev_addr;
global_state.kbd_instance = instance;
@ -110,6 +113,9 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const *desc_re
break;
case HID_ITF_PROTOCOL_MOUSE:
if (ENFORCE_PORTS && BOARD_ROLE == PICO_A)
return;
/* Switch to using protocol report instead of boot report, it's more complicated but
at least we get all the information we need (looking at you, mouse wheel) */
if (tuh_hid_get_protocol(dev_addr, instance) == HID_PROTOCOL_BOOT) {
@ -128,7 +134,7 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const *desc_re
/* Also signal the other board to flash LED, to enable easy verification if serial works */
send_value(ENABLE, FLASH_LED_MSG);
/* Kick off the report querying */
/* Kick off the report querying */
tuh_hid_receive_report(dev_addr, instance);
}

View File

@ -158,3 +158,17 @@
#define OUTPUT_A_OS LINUX
#define OUTPUT_B_OS LINUX
/**================================================== *
* ================= Enforce Ports ================= *
* ==================================================
*
* If enabled, fixes some device incompatibilities by
* enforcing keyboard has to be in port A and mouse in port B.
*
* ENFORCE_PORTS: [0, 1] - 1 means keyboard has to plug in A and mouse in B
* 0 means no such layout is enforced
*
* */
#define ENFORCE_PORTS 0