Implement some HID raw communication

Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
magic_rb 2024-11-03 11:26:28 +01:00
parent dd19ecbece
commit 540a7696b7
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -89,8 +89,29 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
enum HIDR_COMMANDS {
HIDR_RGB_SET = 0,
HIDR_OK
};
void raw_hid_receive(uint8_t* data, uint8_t length) {
raw_hid_send(data, length);
uint8_t response[length];
memset(response, 0, length);
if (data[0] == HIDR_RGB_SET) {
uint8_t r = data[1];
uint8_t g = data[2];
uint8_t b = data[3];
for (uint8_t i = 0 ; i < 8 ; i++) {
rgblight_setrgb_at(r, g, b, i);
}
response[0] = HIDR_OK;
raw_hid_send(response, length);
} else {
memcpy(response, data, length);
raw_hid_send(response, length);
}
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {