Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/smart layers #387

Merged
merged 6 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions quantum/oryx.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ 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 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];
Expand All @@ -61,16 +75,31 @@ 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();

case ORYX_CMD_PAIRING_VALIDATE:
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;

Expand Down
6 changes: 5 additions & 1 deletion quantum/oryx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -47,6 +47,8 @@ enum Oryx_Event_Code {
ORYX_EVT_KEYDOWN,
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,
};
Expand All @@ -73,6 +75,8 @@ 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 trigger_smart_layer(void);

void oryx_layer_event(void);
bool process_record_oryx(uint16_t keycode, keyrecord_t* record);
Expand Down
7 changes: 4 additions & 3 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016-2017 Jack Humbert

Check failure on line 1 in quantum/quantum.c

View workflow job for this annotation

GitHub Actions / lint

Requires Formatting
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -251,6 +251,9 @@
/* 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) &&
Expand Down Expand Up @@ -284,6 +287,7 @@
}
#endif


#ifdef TAP_DANCE_ENABLE
if (preprocess_tap_dance(keycode, record)) {
// The tap dance might have updated the layer state, therefore the
Expand Down Expand Up @@ -322,9 +326,6 @@
#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
Expand Down
Loading