From 1cd69263a57367721ad5f769ab12f0c6fb23637c Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 20 Mar 2024 08:50:29 +0700 Subject: [PATCH 1/5] feat: allows to switch layers via hid --- quantum/oryx.c | 9 +++++++-- quantum/oryx.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/quantum/oryx.c b/quantum/oryx.c index e9b0e237d714..4dc37b4e06a6 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -68,9 +68,14 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { break; // Keeping this for backwards compatibility with older versions of Wally / Keymapp case ORYX_SET_LAYER: + // The first param's byte is on / off + // The second param's byte is the layer number if (rawhid_state.paired == true) { - layer_clear(); - layer_on(param[0]); + if (param[0] == 0) { + layer_off(param[1]); + } else { + layer_on(param[1]); + } } break; diff --git a/quantum/oryx.h b/quantum/oryx.h index 2a035a89fdde..f8164ca6eb40 100644 --- a/quantum/oryx.h +++ b/quantum/oryx.h @@ -21,7 +21,7 @@ Once the host has paired, it can freely use the commands define in the Oryx_Comm # define RAW_EPSIZE 32 #endif -#define ORYX_PROTOCOL_VERSION = 0x02 +#define ORYX_PROTOCOL_VERSION = 0x03 #define ORYX_STOP_BIT -2 enum Oryx_Command_Code { @@ -47,6 +47,7 @@ enum Oryx_Event_Code { ORYX_EVT_KEYDOWN, ORYX_EVT_KEYUP, ORYX_EVT_RGB_CONTROL, + ORYX_EVT_TOGGLE_SMART_LAYER, ORYX_EVT_GET_PROTOCOL_VERSION = 0XFE, ORYX_EVT_ERROR = 0xFF, }; From 991185d1b347b6d58e9d145920967ca91227d901 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 20 Mar 2024 08:58:42 +0700 Subject: [PATCH 2/5] feat: oryx protocol version hid command --- quantum/oryx.c | 10 ++++++++++ quantum/oryx.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/quantum/oryx.c b/quantum/oryx.c index 4dc37b4e06a6..da8c685db44b 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -61,6 +61,16 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { break; } + case ORYX_GET_PROTOCOL_VERSION: { + uint8_t event[RAW_EPSIZE]; + event[0] = ORYX_EVT_GET_PROTOCOL_VERSION; + event[1] = ORYX_PROTOCOL_VERSION; + event[2] = ORYX_STOP_BIT; + + raw_hid_send(event, RAW_EPSIZE); + break; + } + case ORYX_CMD_PAIRING_INIT: pairing_success_event(); diff --git a/quantum/oryx.h b/quantum/oryx.h index f8164ca6eb40..85d124fafa17 100644 --- a/quantum/oryx.h +++ b/quantum/oryx.h @@ -21,7 +21,7 @@ Once the host has paired, it can freely use the commands define in the Oryx_Comm # define RAW_EPSIZE 32 #endif -#define ORYX_PROTOCOL_VERSION = 0x03 +#define ORYX_PROTOCOL_VERSION 0x03 #define ORYX_STOP_BIT -2 enum Oryx_Command_Code { From 7547154a3073e53cfb8a317c7c6a8abd8fbc752e Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 20 Mar 2024 15:52:05 +0700 Subject: [PATCH 3/5] chore: refactor set layer over hid code --- quantum/oryx.c | 7 +++++++ quantum/oryx.h | 1 + 2 files changed, 8 insertions(+) diff --git a/quantum/oryx.c b/quantum/oryx.c index da8c685db44b..8e80bde6cbe0 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -41,6 +41,13 @@ void pairing_success_event(void) { raw_hid_send(event, sizeof(event)); } +void toggle_smart_layer(void) { + uint8_t event[RAW_EPSIZE]; + event[0] = ORYX_EVT_TOGGLE_SMART_LAYER; + event[1] = ORYX_STOP_BIT; + raw_hid_send(event, sizeof(event)); +} + void raw_hid_receive(uint8_t *data, uint8_t length) { uint8_t command = data[0]; uint8_t *param = &data[1]; diff --git a/quantum/oryx.h b/quantum/oryx.h index 85d124fafa17..454f09a550d1 100644 --- a/quantum/oryx.h +++ b/quantum/oryx.h @@ -74,6 +74,7 @@ extern rawhid_state_t rawhid_state; void oryx_error(uint8_t code); void pairing_failed_event(void); void pairing_succesful_event(void); +void toggle_smart_layer(void); void oryx_layer_event(void); bool process_record_oryx(uint16_t keycode, keyrecord_t* record); From 3165966c9ddc44946d2ff56c8c29d45258e7b26b Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 21 Mar 2024 11:08:05 +0700 Subject: [PATCH 4/5] feat: adds smart layer trigger key --- quantum/oryx.c | 7 +++++++ quantum/oryx.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/quantum/oryx.c b/quantum/oryx.c index 8e80bde6cbe0..c6fed402af08 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -48,6 +48,13 @@ void toggle_smart_layer(void) { raw_hid_send(event, sizeof(event)); } +void trigger_smart_layer(void) { + uint8_t event[RAW_EPSIZE]; + event[0] = ORYX_EVT_TRIGGER_SMART_LAYER; + event[1] = ORYX_STOP_BIT; + raw_hid_send(event, sizeof(event)); +} + void raw_hid_receive(uint8_t *data, uint8_t length) { uint8_t command = data[0]; uint8_t *param = &data[1]; diff --git a/quantum/oryx.h b/quantum/oryx.h index 454f09a550d1..314bbc35ecc2 100644 --- a/quantum/oryx.h +++ b/quantum/oryx.h @@ -48,6 +48,7 @@ enum Oryx_Event_Code { ORYX_EVT_KEYUP, ORYX_EVT_RGB_CONTROL, ORYX_EVT_TOGGLE_SMART_LAYER, + ORYX_EVT_TRIGGER_SMART_LAYER, ORYX_EVT_GET_PROTOCOL_VERSION = 0XFE, ORYX_EVT_ERROR = 0xFF, }; @@ -75,6 +76,7 @@ void oryx_error(uint8_t code); void pairing_failed_event(void); void pairing_succesful_event(void); void toggle_smart_layer(void); +void trigger_smart_layer(void); void oryx_layer_event(void); bool process_record_oryx(uint16_t keycode, keyrecord_t* record); From 50d38dce40609b032ed344d25dd5c63cc9d97481 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 27 Mar 2024 14:27:57 +0700 Subject: [PATCH 5/5] fix: send oryx keypress events before preprocessing keys --- quantum/quantum.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quantum/quantum.c b/quantum/quantum.c index 973fe57045d8..b5f1dfef0096 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -251,6 +251,9 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) { /* Get keycode, and then process pre tapping functionality */ bool pre_process_record_quantum(keyrecord_t *record) { uint16_t keycode = get_record_keycode(record, true); +#ifdef ORYX_ENABLE + process_record_oryx(keycode, record); +#endif return pre_process_record_kb(keycode, record) && #ifdef COMBO_ENABLE process_combo(keycode, record) && @@ -284,6 +287,7 @@ bool process_record_quantum(keyrecord_t *record) { } #endif + #ifdef TAP_DANCE_ENABLE if (preprocess_tap_dance(keycode, record)) { // The tap dance might have updated the layer state, therefore the @@ -322,9 +326,6 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef HAPTIC_ENABLE process_haptic(keycode, record) && #endif // HAPTIC_ENABLE -#ifdef ORYX_ENABLE - process_record_oryx(keycode, record) && -#endif #if defined(VIA_ENABLE) process_record_via(keycode, record) && #endif