diff options
-rw-r--r-- | common_features.mk | 1 | ||||
-rw-r--r-- | keyboards/ergodox_ez/ergodox_ez.c | 24 | ||||
-rw-r--r-- | keyboards/ergodox_ez/keymaps/oryx/keymap.c | 2 | ||||
-rw-r--r-- | keyboards/ergodox_ez/keymaps/webusb/keymap.c | 4 | ||||
-rw-r--r-- | keyboards/planck/ez/ez.c | 23 | ||||
-rw-r--r-- | keyboards/planck/keymaps/oryx/keymap.c | 2 | ||||
-rw-r--r-- | keyboards/planck/keymaps/webusb/keymap.c | 2 | ||||
-rw-r--r-- | quantum/oryx.c | 37 | ||||
-rw-r--r-- | quantum/oryx.h | 21 | ||||
-rw-r--r-- | quantum/quantum.c | 8 | ||||
-rw-r--r-- | tmk_core/common/action_layer.c | 7 |
11 files changed, 73 insertions, 58 deletions
diff --git a/common_features.mk b/common_features.mk index 1ccffc41bd..a1e2bc313d 100644 --- a/common_features.mk +++ b/common_features.mk @@ -354,6 +354,7 @@ ifeq ($(strip $(ORYX_ENABLE)), yes) WEBUSB_ENABLE := yes SRC += $(QUANTUM_DIR)/oryx.c OPT_DEFS += -DORYX_ENABLE + OPT_DEFS += -DLAYER_STATE_8BIT endif ifeq ($(strip $(VIA_ENABLE)), yes) diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index bd4a6fa78d..d003a19946 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c @@ -336,17 +336,6 @@ void keyboard_post_init_kb(void) { bool process_record_kb(uint16_t keycode, keyrecord_t *record) { -#ifdef ORYX_ENABLE - if(is_oryx_live_training_enabled()) { - uint8_t event[5]; - event[0] = WEBUSB_STATUS_OK; - event[1] = record->event.pressed ? ORYX_EVT_KEYDOWN : ORYX_EVT_KEYUP; - event[2] = record->event.key.col; - event[3] = record->event.key.row; - event[4] = WEBUSB_STOP_BIT; - webusb_send(event, sizeof(event)); - } -#endif switch (keycode) { case LED_LEVEL: if (record->event.pressed) { @@ -433,17 +422,4 @@ void matrix_scan_kb(void) { matrix_scan_user(); } -uint32_t layer_state_set_kb(uint32_t state) { - state = layer_state_set_user(state); - uint8_t layer = biton32(state); - if(is_oryx_live_training_enabled()) { - uint8_t event[4]; - event[0] = WEBUSB_STATUS_OK; - event[1] = ORYX_EVT_LAYER; - event[2] = layer; - event[3] = WEBUSB_STOP_BIT; - webusb_send(event, sizeof(event)); - } - return state; -} #endif diff --git a/keyboards/ergodox_ez/keymaps/oryx/keymap.c b/keyboards/ergodox_ez/keymaps/oryx/keymap.c index 58d281de6e..81c8b1b912 100644 --- a/keyboards/ergodox_ez/keymaps/oryx/keymap.c +++ b/keyboards/ergodox_ez/keymaps/oryx/keymap.c @@ -104,7 +104,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } -uint32_t layer_state_set_user(uint32_t state) { +layer_state_t layer_state_set_user(layer_state_t state) { uint8_t layer = biton32(state); diff --git a/keyboards/ergodox_ez/keymaps/webusb/keymap.c b/keyboards/ergodox_ez/keymaps/webusb/keymap.c index 58d281de6e..15eb76c15e 100644 --- a/keyboards/ergodox_ez/keymaps/webusb/keymap.c +++ b/keyboards/ergodox_ez/keymaps/webusb/keymap.c @@ -104,9 +104,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } -uint32_t layer_state_set_user(uint32_t state) { +layer_state_t layer_state_set_user(layer_state_t state) { - uint8_t layer = biton32(state); + uint8_t layer = get_highest_layer(state); ergodox_board_led_off(); ergodox_right_led_1_off(); diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c index aca2c4dd5d..2fd462548c 100644 --- a/keyboards/planck/ez/ez.c +++ b/keyboards/planck/ez/ez.c @@ -242,21 +242,11 @@ void eeconfig_init_kb(void) { // EEPROM is getting reset! } -uint32_t layer_state_set_kb(uint32_t state) { +layer_state_t layer_state_set_kb(layer_state_t state) { planck_ez_left_led_off(); planck_ez_right_led_off(); state = layer_state_set_user(state); uint8_t layer = biton32(state); -#ifdef ORXY_ENABLE - if(is_oryx_live_training_enabled()) { - uint8_t event[4]; - event[0] = WEBUSB_STATUS_OK; - event[1] = ORYX_EVT_LAYER; - event[2] = layer; - event[3] = WEBUSB_STOP_BIT; - webusb_send(event, sizeof(event)); - } -#endif switch (layer) { case 1: planck_ez_left_led_on(); @@ -275,17 +265,6 @@ uint32_t layer_state_set_kb(uint32_t state) { } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { -#ifdef ORYX_ENABLE - if(is_oryx_live_training_enabled()) { - uint8_t event[5]; - event[0] = WEBUSB_STATUS_OK; - event[1] = record->event.pressed ? ORYX_EVT_KEYDOWN : ORYX_EVT_KEYUP; - event[2] = record->event.key.col; - event[3] = record->event.key.row; - event[4] = WEBUSB_STOP_BIT; - webusb_send(event, sizeof(event)); - } -#endif switch (keycode) { case LED_LEVEL: if (record->event.pressed) { diff --git a/keyboards/planck/keymaps/oryx/keymap.c b/keyboards/planck/keymaps/oryx/keymap.c index a1e9ae4636..83b7b42767 100644 --- a/keyboards/planck/keymaps/oryx/keymap.c +++ b/keyboards/planck/keymaps/oryx/keymap.c @@ -129,6 +129,6 @@ bool music_mask_user(uint16_t keycode) { return true; } } -uint32_t layer_state_set_user(uint32_t state) { +layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); } diff --git a/keyboards/planck/keymaps/webusb/keymap.c b/keyboards/planck/keymaps/webusb/keymap.c index 9a7c2f4d85..f9d6998940 100644 --- a/keyboards/planck/keymaps/webusb/keymap.c +++ b/keyboards/planck/keymaps/webusb/keymap.c @@ -131,6 +131,6 @@ bool music_mask_user(uint16_t keycode) { } #endif -uint32_t layer_state_set_user(uint32_t state) { +layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); } diff --git a/quantum/oryx.c b/quantum/oryx.c index b99b0106dd..ea34481d84 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -191,3 +191,40 @@ void oryx_layer_event(void) { } bool is_oryx_live_training_enabled(void) { return oryx_state_live_training_enabled; } + +bool process_record_oryx(uint16_t keycode, keyrecord_t *record) { + if(is_oryx_live_training_enabled()) { + uint8_t event[5]; + event[0] = WEBUSB_STATUS_OK; + event[1] = record->event.pressed ? ORYX_EVT_KEYDOWN : ORYX_EVT_KEYUP; + event[2] = record->event.key.col; + event[3] = record->event.key.row; + event[4] = WEBUSB_STOP_BIT; + webusb_send(event, sizeof(event)); + } + + switch (keycode) { + case WEBUSB_PAIR: + if (record->event.pressed) { + webusb_state.pairing = true; + } + return false; + case MACRO00 ... MACRO15: + if (record->event.pressed) { + dynamic_keymap_macro_send(keycode - MACRO00); + } + return false; + } + return true; +} + +void layer_state_set_oryx(layer_state_t state) { + if(is_oryx_live_training_enabled()) { + uint8_t event[4]; + event[0] = WEBUSB_STATUS_OK; + event[1] = ORYX_EVT_LAYER; + event[2] = get_highest_layer(state); + event[3] = WEBUSB_STOP_BIT; + webusb_send(event, sizeof(event)); + } +} diff --git a/quantum/oryx.h b/quantum/oryx.h index 4c713f0a00..b7d341ea14 100644 --- a/quantum/oryx.h +++ b/quantum/oryx.h @@ -54,6 +54,24 @@ enum Oryx_Event_Code { ORYX_EVT_KEYUP, }; +enum dynamic_macros_keycodes { + MACRO00 = 0x5F12, + MACRO01, + MACRO02, + MACRO03, + MACRO04, + MACRO05, + MACRO06, + MACRO07, + MACRO08, + MACRO09, + MACRO10, + MACRO11, + MACRO12, + MACRO13, + MACRO14, + MACRO15, +}; extern bool oryx_state_live_training_enabled; @@ -61,5 +79,6 @@ extern bool oryx_state_live_training_enabled; bool webusb_receive_oryx(uint8_t *data, uint8_t length); void oryx_layer_event(void); bool is_oryx_live_training_enabled(void); - +bool process_record_oryx(uint16_t keycode, keyrecord_t *record); +void layer_state_set_oryx(layer_state_t state); void keyboard_pre_init_oryx(void); diff --git a/quantum/quantum.c b/quantum/quantum.c index c25877b8c6..a3c16f7f8f 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -210,6 +210,9 @@ bool process_record_quantum(keyrecord_t *record) { #if defined(RGB_MATRIX_ENABLE) process_rgb_matrix(keycode, record) && #endif +#ifdef ORYX_ENABLE + process_record_oryx(keycode, record) && +#endif #if defined(VIA_ENABLE) process_record_via(keycode, record) && #endif @@ -310,11 +313,6 @@ bool process_record_quantum(keyrecord_t *record) { backlight_toggle_breathing(); return false; #endif -#ifdef WEBUSB_ENABLE - case WEBUSB_PAIR: - webusb_state.pairing = true; - return false; -#endif } } diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index 4c7d15cd50..08523185bc 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c @@ -3,7 +3,9 @@ #include "action.h" #include "util.h" #include "action_layer.h" - +#ifdef ORYX_ENABLE +# include "oryx.h" +#endif #ifdef DEBUG_ACTION # include "debug.h" #else @@ -97,6 +99,9 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { re * Sets the layer to match the specifed state (a bitmask) */ void layer_state_set(layer_state_t state) { +#ifdef ORYX_ENABLE + layer_state_set_oryx(state); +#endif state = layer_state_set_kb(state); dprint("layer_state: "); layer_debug(); |