diff options
| author | fauxpark <fauxpark@gmail.com> | 2020-02-03 07:17:05 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-02 12:17:05 -0800 |
| commit | b2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c (patch) | |
| tree | 58494d6dd519ac3b87b431188bd9b0e1b14befae /tmk_core/protocol/lufa | |
| parent | 5b91c3e0a0dc8152f69130cf047f3df0d0f94421 (diff) | |
| download | qmk_firmware-b2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c.tar.gz qmk_firmware-b2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c.zip | |
Dedupe extrakey report struct, and send functions in V-USB & LUFA (#7993)
* Dedupe extrakey report struct, and send functions in V-USB & LUFA
* Doc comment for consistency
* Wrap it in ifdef to prevent unused function error
* Do the same for ATSAM
Diffstat (limited to 'tmk_core/protocol/lufa')
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 27 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.h | 6 |
2 files changed, 14 insertions, 19 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index db66a0722..792db4340 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -662,17 +662,17 @@ static void send_mouse(report_mouse_t *report) { | |||
| 662 | #endif | 662 | #endif |
| 663 | } | 663 | } |
| 664 | 664 | ||
| 665 | /** \brief Send System | 665 | /** \brief Send Extra |
| 666 | * | 666 | * |
| 667 | * FIXME: Needs doc | 667 | * FIXME: Needs doc |
| 668 | */ | 668 | */ |
| 669 | static void send_system(uint16_t data) { | ||
| 670 | #ifdef EXTRAKEY_ENABLE | 669 | #ifdef EXTRAKEY_ENABLE |
| 670 | static void send_extra(uint8_t report_id, uint16_t data) { | ||
| 671 | uint8_t timeout = 255; | 671 | uint8_t timeout = 255; |
| 672 | 672 | ||
| 673 | if (USB_DeviceState != DEVICE_STATE_Configured) return; | 673 | if (USB_DeviceState != DEVICE_STATE_Configured) return; |
| 674 | 674 | ||
| 675 | report_extra_t r = {.report_id = REPORT_ID_SYSTEM, .usage = data - SYSTEM_POWER_DOWN + 1}; | 675 | report_extra_t r = {.report_id = report_id, .usage = data}; |
| 676 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); | 676 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); |
| 677 | 677 | ||
| 678 | /* Check if write ready for a polling interval around 10ms */ | 678 | /* Check if write ready for a polling interval around 10ms */ |
| @@ -681,6 +681,16 @@ static void send_system(uint16_t data) { | |||
| 681 | 681 | ||
| 682 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | 682 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); |
| 683 | Endpoint_ClearIN(); | 683 | Endpoint_ClearIN(); |
| 684 | } | ||
| 685 | #endif | ||
| 686 | |||
| 687 | /** \brief Send System | ||
| 688 | * | ||
| 689 | * FIXME: Needs doc | ||
| 690 | */ | ||
| 691 | static void send_system(uint16_t data) { | ||
| 692 | #ifdef EXTRAKEY_ENABLE | ||
| 693 | send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1); | ||
| 684 | #endif | 694 | #endif |
| 685 | } | 695 | } |
| 686 | 696 | ||
| @@ -690,7 +700,6 @@ static void send_system(uint16_t data) { | |||
| 690 | */ | 700 | */ |
| 691 | static void send_consumer(uint16_t data) { | 701 | static void send_consumer(uint16_t data) { |
| 692 | #ifdef EXTRAKEY_ENABLE | 702 | #ifdef EXTRAKEY_ENABLE |
| 693 | uint8_t timeout = 255; | ||
| 694 | uint8_t where = where_to_send(); | 703 | uint8_t where = where_to_send(); |
| 695 | 704 | ||
| 696 | # ifdef BLUETOOTH_ENABLE | 705 | # ifdef BLUETOOTH_ENABLE |
| @@ -729,15 +738,7 @@ static void send_consumer(uint16_t data) { | |||
| 729 | return; | 738 | return; |
| 730 | } | 739 | } |
| 731 | 740 | ||
| 732 | report_extra_t r = {.report_id = REPORT_ID_CONSUMER, .usage = data}; | 741 | send_extra(REPORT_ID_CONSUMER, data); |
| 733 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); | ||
| 734 | |||
| 735 | /* Check if write ready for a polling interval around 10ms */ | ||
| 736 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | ||
| 737 | if (!Endpoint_IsReadWriteAllowed()) return; | ||
| 738 | |||
| 739 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | ||
| 740 | Endpoint_ClearIN(); | ||
| 741 | #endif | 742 | #endif |
| 742 | } | 743 | } |
| 743 | 744 | ||
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index 652e4e79b..1b88060f1 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h | |||
| @@ -58,12 +58,6 @@ extern host_driver_t lufa_driver; | |||
| 58 | } | 58 | } |
| 59 | #endif | 59 | #endif |
| 60 | 60 | ||
| 61 | /* extra report structure */ | ||
| 62 | typedef struct { | ||
| 63 | uint8_t report_id; | ||
| 64 | uint16_t usage; | ||
| 65 | } __attribute__((packed)) report_extra_t; | ||
| 66 | |||
| 67 | #ifdef API_ENABLE | 61 | #ifdef API_ENABLE |
| 68 | # include "api.h" | 62 | # include "api.h" |
| 69 | #endif | 63 | #endif |
