diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/oryx.c | 30 | ||||
-rw-r--r-- | quantum/oryx.h | 34 | ||||
-rw-r--r-- | quantum/quantum.c | 13 | ||||
-rw-r--r-- | quantum/quantum.h | 7 |
4 files changed, 84 insertions, 0 deletions
diff --git a/quantum/oryx.c b/quantum/oryx.c new file mode 100644 index 0000000000..93ee50e935 --- /dev/null +++ b/quantum/oryx.c @@ -0,0 +1,30 @@ +#include "oryx.h" + +bool webusb_state_live_training_enabled; + +bool webusb_receive_oryx(uint8_t *data, uint8_t length) { + uint8_t command = data[0]; + + switch (command) { + case ORYX_GET_LAYER: + oryx_layer_event(); + return true; break; + + } + + return false; +} + + +void oryx_layer_event(void) { + uint8_t layer; + uint8_t event[4]; + layer = get_highest_layer(layer_state); +#ifdef WEBUSB_ENABLE + event[0] = WEBUSB_STATUS_OK; + event[1] = ORYX_EVT_LAYER; + event[2] = layer; + event[3] = WEBUSB_STOP_BIT; + webusb_send(event, sizeof(event)); +#endif +} diff --git a/quantum/oryx.h b/quantum/oryx.h new file mode 100644 index 0000000000..eaef5bd335 --- /dev/null +++ b/quantum/oryx.h @@ -0,0 +1,34 @@ +#pragma once + +#include "quantum.h" +#include "webusb.h" + +#ifndef WEBUSB_ENABLE +# error "WebUSB needs to be enabled, please enable it!" +#endif + +#ifndef DYNAMIC_KEYMAP_ENABLE +# error "Dynamic Keymaps are not enabled. It must be aenbled " +#endif + + +enum Oryx_Command_Code { + ORYX_GET_LAYER = WEBUSB_CMD_SAFE_RANGE, + +}; + +enum Oryx_Event_Code { + ORYX_EVT_KEYDOWN = WEBUSB_EVT_SAFE_RANGE, + ORYX_EVT_KEYUP, + ORYX_EVT_LAYER, +}; + + + +extern bool webusb_state_live_training_enabled; + +bool webusb_receive_oryx(uint8_t *data, uint8_t length); +void oryx_layer_event(void); + + +void keyboard_pre_init_oryx(void); diff --git a/quantum/quantum.c b/quantum/quantum.c index e182e62790..755686b341 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -774,3 +774,16 @@ __attribute__((weak)) void startup_user() {} __attribute__((weak)) void shutdown_user() {} //------------------------------------------------------------------------------ + +#ifdef WEBUSB_ENABLE +__attribute__((weak)) bool webusb_receive_user(uint8_t *data, uint8_t length) { return false; } +__attribute__((weak)) bool webusb_receive_kb(uint8_t *data, uint8_t length) { return webusb_receive_user(data, length); } + +bool webusb_receive_quantum(uint8_t *data, uint8_t length) { +#ifdef ORYX_ENABLE + return webusb_receive_oryx(data, length); +#else + return webusb_receive_kb(data, length); +#endif +} +#endif diff --git a/quantum/quantum.h b/quantum/quantum.h index 9a38b036ff..7548ed8b93 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -162,6 +162,10 @@ extern layer_state_t layer_state; # include "webusb.h" #endif +#ifdef ORYX_ENABLE +# include "oryx.h" +#endif + #ifdef DYNAMIC_MACRO_ENABLE #include "process_dynamic_macro.h" #endif @@ -283,3 +287,6 @@ bool led_update_user(led_t led_state); bool led_update_kb(led_t led_state); void api_send_unicode(uint32_t unicode); + +bool webusb_receive_kb(uint8_t *data, uint8_t length); +bool webusb_receive_user(uint8_t *data, uint8_t length); |