summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/lufa
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/lufa
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/lufa')
-rw-r--r--tmk_core/protocol/lufa/lufa.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index bf005d519f..1084f67659 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -161,7 +161,10 @@ void raw_hid_send(uint8_t *data, uint8_t length) {
// Check to see if the host is ready to accept another packet
if (Endpoint_IsINReady()) {
// Write data
- Endpoint_Write_Stream_LE(data, RAW_EPSIZE, NULL);
+ if (Endpoint_Write_Stream_LE(data, RAW_EPSIZE, NULL)) {
+ rawhid_state.pairing = false;
+ rawhid_state.paired = false;
+ }
// Finalize the stream transfer to send the last packet
Endpoint_ClearIN();
}
@@ -279,9 +282,9 @@ void webusb_send(uint8_t *data, uint8_t length) {
Endpoint_SelectEndpoint(WEBUSB_IN_EPNUM);
- if(Endpoint_Write_Stream_LE(data, length, NULL)) {
+ if (Endpoint_Write_Stream_LE(data, length, NULL)) {
// Stream failed to complete, resetting WEBUSB's state
- webusb_state.paired = false;
+ webusb_state.paired = false;
webusb_state.pairing = false;
}
Endpoint_ClearIN();
@@ -292,7 +295,6 @@ static void webusb_task(void) {
uint8_t data[WEBUSB_EPSIZE];
bool data_read = false;
-
// Device must be connected and configured for the task to run
if (USB_DeviceState != DEVICE_STATE_Configured) return;
@@ -543,9 +545,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) {
#endif
#ifdef WEBUSB_ENABLE
- /* Setup Webusb Endpoints */
- ConfigSuccess &= Endpoint_ConfigureEndpoint(WEBUSB_IN_EPADDR, EP_TYPE_INTERRUPT, WEBUSB_EPSIZE, 1);
- ConfigSuccess &= Endpoint_ConfigureEndpoint(WEBUSB_OUT_EPADDR, EP_TYPE_INTERRUPT, WEBUSB_EPSIZE, 1);
+ /* Setup Webusb Endpoints */
+ ConfigSuccess &= Endpoint_ConfigureEndpoint(WEBUSB_IN_EPADDR, EP_TYPE_INTERRUPT, WEBUSB_EPSIZE, 1);
+ ConfigSuccess &= Endpoint_ConfigureEndpoint(WEBUSB_OUT_EPADDR, EP_TYPE_INTERRUPT, WEBUSB_EPSIZE, 1);
#endif
#ifdef MIDI_ENABLE
@@ -697,23 +699,23 @@ void EVENT_USB_Device_ControlRequest(void) {
case WEBUSB_VENDOR_CODE:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE)) {
switch (USB_ControlRequest.wIndex) {
- case WebUSB_RTYPE_GetURL:
- switch (USB_ControlRequest.wValue) {
- case WEBUSB_LANDING_PAGE_INDEX:
- Endpoint_ClearSETUP();
- /* Write the descriptor data to the control endpoint */
- Endpoint_Write_Control_PStream_LE(&WebUSB_LandingPage, WebUSB_LandingPage.Header.Size);
- /* Release the endpoint after transaction. */
- Endpoint_ClearStatusStage();
+ case WebUSB_RTYPE_GetURL:
+ switch (USB_ControlRequest.wValue) {
+ case WEBUSB_LANDING_PAGE_INDEX:
+ Endpoint_ClearSETUP();
+ /* Write the descriptor data to the control endpoint */
+ Endpoint_Write_Control_PStream_LE(&WebUSB_LandingPage, WebUSB_LandingPage.Header.Size);
+ /* Release the endpoint after transaction. */
+ Endpoint_ClearStatusStage();
+ break;
+ default: /* Stall transfer on invalid index. */
+ Endpoint_StallTransaction();
+ break;
+ }
break;
- default: /* Stall transfer on invalid index. */
+ default: /* Stall on unknown WebUSB request */
Endpoint_StallTransaction();
break;
- }
- break;
- default: /* Stall on unknown WebUSB request */
- Endpoint_StallTransaction();
- break;
}
}
@@ -721,16 +723,16 @@ void EVENT_USB_Device_ControlRequest(void) {
case MS_OS_20_VENDOR_CODE:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE)) {
switch (USB_ControlRequest.wIndex) {
- case MS_OS_20_DESCRIPTOR_INDEX:
- Endpoint_ClearSETUP();
- /* Write the descriptor data to the control endpoint */
- Endpoint_Write_Control_PStream_LE(&MS_OS_20_Descriptor, MS_OS_20_Descriptor.Header.TotalLength);
- /* Release the endpoint after transaction. */
- Endpoint_ClearStatusStage();
- break;
- default: /* Stall on unknown MS OS 2.0 request */
- Endpoint_StallTransaction();
- break;
+ case MS_OS_20_DESCRIPTOR_INDEX:
+ Endpoint_ClearSETUP();
+ /* Write the descriptor data to the control endpoint */
+ Endpoint_Write_Control_PStream_LE(&MS_OS_20_Descriptor, MS_OS_20_Descriptor.Header.TotalLength);
+ /* Release the endpoint after transaction. */
+ Endpoint_ClearStatusStage();
+ break;
+ default: /* Stall on unknown MS OS 2.0 request */
+ Endpoint_StallTransaction();
+ break;
}
}
break;
@@ -896,7 +898,6 @@ static void send_consumer(uint16_t data) {
#endif
}
-
static void send_programmable_button(uint32_t data) {
#ifdef PROGRAMMABLE_BUTTON_ENABLE
static report_programmable_button_t r;
@@ -1209,7 +1210,7 @@ void protocol_post_task(void) {
#endif
#ifdef WEBUSB_ENABLE
- webusb_task();
+ webusb_task();
#endif
#if !defined(INTERRUPT_CONTROL_ENDPOINT)