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)
This commit is contained in:
Florian Didron
2022-05-31 19:03:21 +09:00
committed by GitHub
parent 1fbd91aa10
commit fc773ff0cf
14 changed files with 306 additions and 390 deletions
+28 -13
View File
@@ -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];