Add toggle for live training
This commit is contained in:
committed by
Florian Didron
parent
259cc07202
commit
5ed3ecdd73
@@ -336,11 +336,11 @@ void keyboard_post_init_kb(void) {
|
||||
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
#ifdef WEBUSB_ENABLE
|
||||
if(webusb_state.paired == true) {
|
||||
#ifdef ORYX_ENABLE
|
||||
if(is_oryx_live_training_enabled()) {
|
||||
uint8_t event[5];
|
||||
event[0] = WEBUSB_STATUS_OK;
|
||||
event[1] = record->event.pressed ? WEBUSB_EVT_KEYDOWN : WEBUSB_EVT_KEYUP;
|
||||
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;
|
||||
@@ -399,7 +399,7 @@ void eeconfig_init_kb(void) { // EEPROM is getting reset!
|
||||
eeconfig_init_user();
|
||||
}
|
||||
|
||||
#ifdef WEBUSB_ENABLE
|
||||
#ifdef ORYX_ENABLE
|
||||
static uint16_t loops = 0;
|
||||
static bool is_on = false;
|
||||
|
||||
@@ -436,10 +436,10 @@ void matrix_scan_kb(void) {
|
||||
uint32_t layer_state_set_kb(uint32_t state) {
|
||||
state = layer_state_set_user(state);
|
||||
uint8_t layer = biton32(state);
|
||||
if(webusb_state.paired == true) {
|
||||
if(is_oryx_live_training_enabled()) {
|
||||
uint8_t event[4];
|
||||
event[0] = WEBUSB_STATUS_OK;
|
||||
event[1] = WEBUSB_EVT_LAYER;
|
||||
event[1] = ORYX_EVT_LAYER;
|
||||
event[2] = layer;
|
||||
event[3] = WEBUSB_STOP_BIT;
|
||||
webusb_send(event, sizeof(event));
|
||||
|
||||
@@ -247,11 +247,11 @@ uint32_t layer_state_set_kb(uint32_t state) {
|
||||
planck_ez_right_led_off();
|
||||
state = layer_state_set_user(state);
|
||||
uint8_t layer = biton32(state);
|
||||
#ifdef WEBUSB_ENABLE
|
||||
if(webusb_state.paired == true) {
|
||||
#ifdef ORXY_ENABLE
|
||||
if(is_oryx_live_training_enabled()) {
|
||||
uint8_t event[4];
|
||||
event[0] = WEBUSB_STATUS_OK;
|
||||
event[1] = WEBUSB_EVT_LAYER;
|
||||
event[1] = ORYX_EVT_LAYER;
|
||||
event[2] = layer;
|
||||
event[3] = WEBUSB_STOP_BIT;
|
||||
webusb_send(event, sizeof(event));
|
||||
@@ -275,11 +275,11 @@ uint32_t layer_state_set_kb(uint32_t state) {
|
||||
}
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
#ifdef WEBUSB_ENABLE
|
||||
if(webusb_state.paired == true) {
|
||||
#ifdef ORYX_ENABLE
|
||||
if(is_oryx_live_training_enabled()) {
|
||||
uint8_t event[5];
|
||||
event[0] = WEBUSB_STATUS_OK;
|
||||
event[1] = record->event.pressed ? WEBUSB_EVT_KEYDOWN : WEBUSB_EVT_KEYUP;
|
||||
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;
|
||||
|
||||
@@ -1,18 +1,41 @@
|
||||
#include "oryx.h"
|
||||
|
||||
bool webusb_state_live_training_enabled;
|
||||
bool oryx_state_live_training_enabled;
|
||||
|
||||
bool webusb_receive_oryx(uint8_t *data, uint8_t length) {
|
||||
uint8_t command = data[0];
|
||||
uint8_t param = data[1];
|
||||
|
||||
switch (command) {
|
||||
case ORYX_GET_LAYER:
|
||||
oryx_layer_event();
|
||||
return true; break;
|
||||
case ORYX_CMD_LIVE_TRAINING: {
|
||||
uint8_t event[4];
|
||||
switch (param) { // 0 for state, 1 for off, 2 for on
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
oryx_state_live_training_enabled = false;
|
||||
break;
|
||||
case 2:
|
||||
oryx_state_live_training_enabled = true;
|
||||
break;
|
||||
default:
|
||||
webusb_error(WEBUSB_STATUS_UNKNOWN_COMMAND);
|
||||
return true;
|
||||
}
|
||||
event[0] = WEBUSB_STATUS_OK;
|
||||
event[1] = WEBUSB_EVT_PAIRED;
|
||||
event[2] = oryx_state_live_training_enabled;
|
||||
event[3] = WEBUSB_STOP_BIT;
|
||||
webusb_send(event, sizeof(event));
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return webusb_receive_kb(data, length);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,3 +51,7 @@ void oryx_layer_event(void) {
|
||||
webusb_send(event, sizeof(event));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is_oryx_live_training_enabled(void) {
|
||||
return oryx_state_live_training_enabled;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,16 @@
|
||||
#endif
|
||||
|
||||
#ifndef DYNAMIC_KEYMAP_ENABLE
|
||||
# error "Dynamic Keymaps are not enabled. It must be aenbled "
|
||||
# error "Dynamic Keymaps are not enabled. It must be enabled"
|
||||
#endif
|
||||
|
||||
// enum Oryx_Status_code {
|
||||
// PLACEHOLDER = WEBUSB_STATUS_SAFE_RANGE,
|
||||
// }
|
||||
|
||||
enum Oryx_Command_Code {
|
||||
ORYX_GET_LAYER = WEBUSB_CMD_SAFE_RANGE,
|
||||
ORYX_CMD_LIVE_TRAINING,
|
||||
|
||||
};
|
||||
|
||||
@@ -21,14 +25,15 @@ enum Oryx_Event_Code {
|
||||
ORYX_EVT_KEYDOWN = WEBUSB_EVT_SAFE_RANGE,
|
||||
ORYX_EVT_KEYUP,
|
||||
ORYX_EVT_LAYER,
|
||||
ORYX_EVT_LIVE_TRAINING
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern bool webusb_state_live_training_enabled;
|
||||
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);
|
||||
|
||||
void keyboard_pre_init_oryx(void);
|
||||
|
||||
@@ -28,6 +28,7 @@ enum Webusb_Status_Code {
|
||||
WEBUSB_STATUS_NOT_PAIRED = -1,
|
||||
WEBUSB_STATUS_OK,
|
||||
WEBUSB_STATUS_UNKNOWN_COMMAND,
|
||||
WEBUSB_STATUS_SAFE_RANGE,
|
||||
};
|
||||
|
||||
enum Webusb_Command_Code {
|
||||
@@ -35,7 +36,6 @@ enum Webusb_Command_Code {
|
||||
WEBUSB_CMD_GET_FW_VERSION,
|
||||
WEBUSB_CMD_SAFE_RANGE,
|
||||
|
||||
WEBUSB_GET_LAYER,
|
||||
};
|
||||
|
||||
enum Webusb_Event_Code {
|
||||
@@ -43,7 +43,4 @@ enum Webusb_Event_Code {
|
||||
WEBUSB_EVT_FW_VERSION,
|
||||
WEBUSB_EVT_SAFE_RANGE,
|
||||
|
||||
WEBUSB_EVT_KEYDOWN,
|
||||
WEBUSB_EVT_KEYUP,
|
||||
WEBUSB_EVT_LAYER,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user