Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/features/rawhid.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Add the following to your `rules.mk`:
RAW_ENABLE = yes
```

Keychron wireless keyboards can route raw HID reports received over the wireless
transport through the normal `raw_hid_receive()` handler by defining
`WIRELESS_RAW_ENABLE`. Keychron's command `KC_GET_BATTERY_LEVEL` (`0xA4`)
returns the cached battery percentage in byte 1 of the response.

## Basic Configuration {#basic-configuration}

By default, the HID Usage Page and Usage ID for the Raw HID interface are `0xFF60` and `0x61`. However, they can be changed if necessary by adding the following to your `config.h`:
Expand Down
7 changes: 7 additions & 0 deletions keyboards/keychron/common/keychron_raw_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# include "snap_click.h"
#endif
#if defined(LK_WIRELESS_ENABLE) || defined(KC_BLUETOOTH_ENABLE)
# include "battery.h"
# include "wireless.h"
# ifdef LK_WIRELESS_ENABLE
# include "lkbt51.h"
Expand Down Expand Up @@ -168,6 +169,12 @@ bool kc_raw_hid_rx(uint8_t src, uint8_t *data, uint8_t length) {
data[2] = get_highest_layer(layer_state);
break;

# if defined(LK_WIRELESS_ENABLE) || defined(KC_BLUETOOTH_ENABLE)
case KC_GET_BATTERY_LEVEL:
data[1] = battery_get_percentage();
break;
# endif

case KC_MISC_CMD_GROUP:
switch (data[1]) {
case MISC_GET_PROTOCOL_VER:
Expand Down
1 change: 1 addition & 0 deletions keyboards/keychron/common/keychron_raw_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum {
KC_GET_FIRMWARE_VERSION = 0xA1,
KC_GET_SUPPORT_FEATURE = 0xA2,
KC_GET_DEFAULT_LAYER = 0xA3,
KC_GET_BATTERY_LEVEL = 0xA4,
KC_MISC_CMD_GROUP = 0xA7,
KC_KEYCHRON_RGB = 0xA8,
KC_ANALOG_MATRIX = 0xA9,
Expand Down
8 changes: 2 additions & 6 deletions keyboards/keychron/common/wireless/wireless.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,9 @@ void wireless_event_task(void) {
case EVT_CONECTION_INTERVAL:
report_buffer_set_inverval(event.params.interval);
break;
#if defined(RAW_ENABLE) && defined(WILRESS_RAW_ENABLE)
#if defined(RAW_ENABLE) && defined(WIRELESS_RAW_ENABLE)
case EVT_RAW_HID:
# ifdef VIA_ENABLE
via_raw_hid_receive(RAW_HID_SRC_WIRELESS, event.params.raw_hid_data, 32);
# else
kc_raw_hid_rx(RAW_HID_SRC_WIRELESS, event.params.raw_hid_data, 32);
# endif
raw_hid_receive(RAW_HID_SRC_WIRELESS, event.params.raw_hid_data, 32);
lpm_timer_reset();
break;
#endif
Expand Down