summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/chibios
diff options
context:
space:
mode:
authorFlorian Didron <fdidron@users.noreply.github.com>2022-05-31 19:03:21 +0900
committerGitHub <noreply@github.com>2022-05-31 19:03:21 +0900
commitfc773ff0cf9c528773fa81be0fc8880ca5153d81 (patch)
treee917ed871290cc78cff818ee896b838d12ccc654 /tmk_core/protocol/chibios
parent1fbd91aa106a4beb6ab84614dde14165a43f009a (diff)
Reimplements Oryx's live training over raw hid (#345)
* feat: initial commit, random pairing sequence generation, host - board pairing handshakes * feat: reimplements ory's live training over raw hid * feat: adds planck / ergodox support * chore: some code styling fixes * fix: build smoke tests * fix: code lint * fix: disable console / command on moonlander, fixes build ci test * fix: code lint * fix: remove unused define(MATRIX_SIZE)
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r--tmk_core/protocol/chibios/usb_main.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 66cef7838a..04ae3d7f4d 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -49,6 +49,14 @@
extern keymap_config_t keymap_config;
#endif
+#ifdef RAW_ENABLE
+# include "raw_hid.h"
+#endif
+
+#ifdef ORYX_ENABLE
+# include "oryx.h"
+#endif
+
#ifdef WEBUSB_ENABLE
# include "webusb.h"
#endif
@@ -176,7 +184,6 @@ static const USBEndpointConfig shared_ep_config = {
};
#endif
-
#ifdef WEBUSB_ENABLE
/** Microsoft OS 2.0 Descriptor. This is used by Windows to select the USB driver for the device.
*
@@ -391,10 +398,10 @@ static usb_driver_configs_t drivers = {
#endif
#ifdef WEBUSB_ENABLE
-# define WEBUSB_IN_CAPACITY 4
-# define WEBUSB_OUT_CAPACITY 4
-# define WEBUSB_IN_MODE USB_EP_MODE_TYPE_INTR
-# define WEBUSB_OUT_MODE USB_EP_MODE_TYPE_INTR
+# define WEBUSB_IN_CAPACITY 4
+# define WEBUSB_OUT_CAPACITY 4
+# define WEBUSB_IN_MODE USB_EP_MODE_TYPE_INTR
+# define WEBUSB_OUT_MODE USB_EP_MODE_TYPE_INTR
.webusb_driver = QMK_USB_DRIVER_CONFIG(WEBUSB, 0, false),
#endif
#ifdef JOYSTICK_ENABLE
@@ -463,9 +470,9 @@ static inline void usb_event_wakeup_handler(void) {
suspend_wakeup_init();
usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
#ifdef SLEEP_LED_ENABLE
- sleep_led_disable();
- // NOTE: converters may not accept this
- led_set(host_keyboard_leds());
+ sleep_led_disable();
+ // NOTE: converters may not accept this
+ led_set(host_keyboard_leds());
#endif /* SLEEP_LED_ENABLE */
}
@@ -1145,7 +1152,15 @@ void raw_hid_send(uint8_t *data, uint8_t length) {
if (length != RAW_EPSIZE) {
return;
}
+
+# ifdef ORYX_ENABLE
+ if (chnWriteTimeout(&drivers.raw_driver.driver, data, length, TIME_IMMEDIATE) != length) {
+ rawhid_state.pairing = false;
+ rawhid_state.paired = false;
+ }
+# else
chnWrite(&drivers.raw_driver.driver, data, length);
+# endif
}
__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) {
@@ -1169,15 +1184,15 @@ void raw_hid_task(void) {
#ifdef WEBUSB_ENABLE
void webusb_send(uint8_t *data, uint8_t length) {
- if(chnWriteTimeout(&drivers.webusb_driver.driver, data, length, TIME_IMMEDIATE) != length){
- webusb_state.paired = false;
+ if (chnWriteTimeout(&drivers.webusb_driver.driver, data, length, TIME_IMMEDIATE) != length) {
+ webusb_state.paired = false;
webusb_state.pairing = false;
}
}
- // Users should #include "raw_hid.h" in their own code
- // and implement this function there. Leave this as weak linkage
- // so users can opt to not handle data coming in.
+// Users should #include "raw_hid.h" in their own code
+// and implement this function there. Leave this as weak linkage
+// so users can opt to not handle data coming in.
void webusb_task(void) {
uint8_t buffer[WEBUSB_EPSIZE];