diff options
author | Florian Didron <fd@librem.one> | 2019-12-04 19:15:04 +0900 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2019-12-05 16:03:55 -0800 |
commit | 52f5c344c4ee483f7a10ec6eae69557388cadfb7 (patch) | |
tree | a51a6bd431d848279d8c03357ac05ecfb25312ce /tmk_core/common/webusb.c | |
parent | 0f319b48e62d53bcb0c0601a723893afd1c93505 (diff) |
feat: add get layer command
Diffstat (limited to 'tmk_core/common/webusb.c')
-rw-r--r-- | tmk_core/common/webusb.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tmk_core/common/webusb.c b/tmk_core/common/webusb.c index e11e63a9da..2488e75de7 100644 --- a/tmk_core/common/webusb.c +++ b/tmk_core/common/webusb.c @@ -1,3 +1,4 @@ +#include QMK_KEYBOARD_H #include <string.h> #include "webusb.h" #include "wait.h" @@ -41,13 +42,29 @@ void webusb_receive(uint8_t *data, uint8_t length) { if(webusb_state.paired == true) { switch(command) { - //Handle commands in here + //Handle commands in here + case WEBUSB_GET_LAYER: + webusb_layer_event(); + break; + default: + break; } } else { webusb_error(WEBUSB_STATUS_NOT_PAIRED); } }; +void webusb_layer_event() { + uint8_t layer; + uint8_t event[4]; + layer = biton32(layer_state); + event[0] = WEBUSB_STATUS_OK; + event[1] = WEBUSB_EVT_LAYER; + event[2] = layer; + event[3] = WEBUSB_STOP_BIT; + webusb_send(event, sizeof(event)); +} + void webusb_error(uint8_t code) { uint8_t buffer[1]; buffer[0] = code; |