summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/action.c1
-rw-r--r--tmk_core/common/action_layer.c7
-rw-r--r--tmk_core/common/arm_atsam/printf.c5
-rw-r--r--tmk_core/common/eeconfig.c7
-rw-r--r--tmk_core/common/webusb.c59
-rw-r--r--tmk_core/common/webusb.h46
6 files changed, 123 insertions, 2 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index bd41d28b66..5660c3fa1f 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -923,6 +923,7 @@ void unregister_mods(uint8_t mods) {
}
}
+
/** \brief Adds the given weak modifiers and sends a keyboard report immediately.
*
* \param mods A bitfield of modifiers to register.
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index af2d7d964b..9bd0948379 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
@@ -98,6 +100,9 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { re
*/
void layer_state_set(layer_state_t state) {
state = layer_state_set_kb(state);
+#ifdef ORYX_ENABLE
+ layer_state_set_oryx(state);
+#endif
dprint("layer_state: ");
layer_debug();
dprint(" to ");
diff --git a/tmk_core/common/arm_atsam/printf.c b/tmk_core/common/arm_atsam/printf.c
index 2cb59706a8..6f7e8d343f 100644
--- a/tmk_core/common/arm_atsam/printf.c
+++ b/tmk_core/common/arm_atsam/printf.c
@@ -68,5 +68,8 @@ void console_printf(char *fmt, ...) {
}
#endif // CONSOLE_ENABLE
+<<<<<<< HEAD
+=======
-void print_set_sendchar(sendchar_func_t send) {} \ No newline at end of file
+void print_set_sendchar(sendchar_func_t send) {}
+>>>>>>> 0.12.52~1
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index ffa56ab56d..57c468ed7a 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -3,6 +3,9 @@
#include "eeprom.h"
#include "eeconfig.h"
#include "action_layer.h"
+#ifdef ORYX_ENABLE
+# include "oryx.h"
+#endif
#ifdef STM32_EEPROM_ENABLE
# include <hal.h>
@@ -59,6 +62,10 @@ void eeconfig_init_quantum(void) {
eeprom_update_dword(EECONFIG_RGB_MATRIX, 0);
eeprom_update_word(EECONFIG_RGB_MATRIX_EXTENDED, 0);
+#ifdef ORYX_ENABLE
+ eeconfig_init_oryx();
+#endif
+
// TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
// within the emulated eeprom via dfu-util or another tool
#if defined INIT_EE_HANDS_LEFT
diff --git a/tmk_core/common/webusb.c b/tmk_core/common/webusb.c
new file mode 100644
index 0000000000..bc349e6afa
--- /dev/null
+++ b/tmk_core/common/webusb.c
@@ -0,0 +1,59 @@
+#include "quantum.h"
+#include <string.h>
+#include "webusb.h"
+#include "wait.h"
+
+webusb_state_t webusb_state = {
+ .paired = false,
+ .pairing = false,
+};
+
+__attribute__((weak)) bool webusb_receive_quantum(uint8_t *data, uint8_t length) { return false; }
+
+void webusb_receive(uint8_t *data, uint8_t length) {
+ uint8_t command = data[0];
+
+ if(command == WEBUSB_CMD_PAIR && webusb_state.pairing == true) {
+ uint8_t event[3];
+ webusb_state.pairing = false;
+ webusb_state.paired = true;
+ event[0] = WEBUSB_STATUS_OK;
+ event[1] = WEBUSB_EVT_PAIRED;
+ event[2] = WEBUSB_STOP_BIT;
+ webusb_send(event, sizeof(event));
+ return;
+ }
+
+ if(command == WEBUSB_CMD_GET_FW_VERSION) {
+ // Landing page + packet headers(2) + stop bit(1)
+ uint8_t lp_size = sizeof(FIRMWARE_VERSION) + 3;
+ uint8_t url[lp_size];
+
+ uint8_t event[2];
+ event[0] = WEBUSB_STATUS_OK;
+ event[1] = WEBUSB_EVT_FW_VERSION;
+
+ uint8_t stop[1];
+ stop[0] = WEBUSB_STOP_BIT;
+
+ memcpy(url, event, 2);
+ memcpy(url + 2, FIRMWARE_VERSION, sizeof(FIRMWARE_VERSION));
+ memcpy(url + 2 + sizeof(FIRMWARE_VERSION), stop, 1);
+ webusb_send(url, lp_size);
+ return;
+ }
+
+ if(webusb_state.paired == true) {
+ if (!webusb_receive_quantum(data, length)) {
+ webusb_error(WEBUSB_STATUS_UNKNOWN_COMMAND);
+ }
+ } else {
+ webusb_error(WEBUSB_STATUS_NOT_PAIRED);
+ }
+};
+
+void webusb_error(uint8_t code) {
+ uint8_t buffer[1];
+ buffer[0] = code;
+ webusb_send(buffer, 1);
+}
diff --git a/tmk_core/common/webusb.h b/tmk_core/common/webusb.h
new file mode 100644
index 0000000000..7bec7c50e1
--- /dev/null
+++ b/tmk_core/common/webusb.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifndef FIRMWARE_VERSION
+#define FIRMWARE_VERSION u8"default"
+#endif
+#define WEBUSB_STOP_BIT -2
+#define WEBUSB_BLINK_STEPS 512
+#define WEBUSB_BLINK_END WEBUSB_BLINK_STEPS * 60
+
+void webusb_receive(uint8_t *data, uint8_t length);
+void webusb_send(uint8_t *data, uint8_t length);
+void webusb_layer_event(void);
+void webusb_error(uint8_t code);
+void webusb_set_pairing_state(void);
+bool webusb_receive_quantum(uint8_t *data, uint8_t length);
+
+typedef struct{
+ bool paired;
+ bool pairing;
+} webusb_state_t;
+
+extern webusb_state_t webusb_state;
+
+enum Webusb_Status_Code {
+ WEBUSB_STATUS_NOT_PAIRED = -1,
+ WEBUSB_STATUS_OK,
+ WEBUSB_STATUS_UNKNOWN_COMMAND,
+ WEBUSB_STATUS_SAFE_RANGE,
+};
+
+enum Webusb_Command_Code {
+ WEBUSB_CMD_PAIR,
+ WEBUSB_CMD_GET_FW_VERSION,
+ WEBUSB_CMD_SAFE_RANGE,
+
+};
+
+enum Webusb_Event_Code {
+ WEBUSB_EVT_PAIRED,
+ WEBUSB_EVT_FW_VERSION,
+ WEBUSB_EVT_SAFE_RANGE,
+
+};