aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-10-02 11:10:08 +0100
committerfishsoupisgood <github@madingley.org>2020-10-02 11:10:08 +0100
commitee079a41f1450ef567e15699275596ebe058236a (patch)
tree225f59e41a436fc3b22cbfe04e214a6e371e82f2 /tmk_core
parent9cd522d3814baf2fd12839c5e5ff2a98b4d823b4 (diff)
downloadfirmware-master.tar.gz
firmware-master.tar.bz2
firmware-master.zip
async handing of colourHEADmaster
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/raw_hid.h1
-rw-r--r--tmk_core/protocol/vusb/vusb.c29
2 files changed, 13 insertions, 17 deletions
diff --git a/tmk_core/common/raw_hid.h b/tmk_core/common/raw_hid.h
index c579157f1..1e4be6a92 100644
--- a/tmk_core/common/raw_hid.h
+++ b/tmk_core/common/raw_hid.h
@@ -2,6 +2,7 @@
#define _RAW_HID_H_
void raw_hid_receive(uint8_t *data, uint8_t length);
+void raw_hid_dispatch(void);
void raw_hid_send(uint8_t *data, uint8_t length);
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 7d1a0a7a2..c32b595bc 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -107,10 +107,8 @@ void vusb_transfer_keyboard(void) {
* RAW HID
*------------------------------------------------------------------*/
#ifdef RAW_ENABLE
-# define RAW_BUFFER_SIZE 8
# define RAW_EPSIZE 8
-static uint8_t raw_output_buffer[RAW_BUFFER_SIZE];
static uint8_t raw_output_received_bytes = 0;
#if 0
@@ -140,11 +138,15 @@ __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) {
// so users can opt to not handle data coming in.
}
+__attribute__((weak)) void raw_hid_dispatch(void) {
+ // 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 raw_hid_task(void) {
- if (raw_output_received_bytes == RAW_BUFFER_SIZE) {
- raw_hid_receive(raw_output_buffer, RAW_BUFFER_SIZE);
- raw_output_received_bytes = 0;
- }
+ raw_hid_dispatch();
}
#endif
@@ -340,16 +342,9 @@ uchar usbFunctionWrite(uchar *data, uchar len) {
void usbFunctionWriteOut(uchar *data, uchar len) {
#ifdef RAW_ENABLE
// Data from host must be divided every 8bytes
- if (len != 8) {
- dprint("RAW: invalid length\n");
- raw_output_received_bytes = 0;
- return;
- }
+ raw_hid_receive(data, len);
- for (uint8_t i = 0; i < 8; i++) {
- raw_output_buffer[i] = data[i];
- }
- raw_output_received_bytes = len;
+ raw_output_received_bytes = 1;
#endif
}
@@ -491,14 +486,14 @@ const PROGMEM uchar raw_hid_report[] = {
0x09, 0x62, // Usage (Vendor Defined)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
- 0x95, RAW_BUFFER_SIZE, // Report Count
+ 0x95, RAW_EPSIZE, // Report Count
0x75, 0x08, // Report Size (8)
0x81, 0x02, // Input (Data, Variable, Absolute)
// Data from host
0x09, 0x63, // Usage (Vendor Defined)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
- 0x95, RAW_BUFFER_SIZE, // Report Count
+ 0x95, RAW_EPSIZE, // Report Count
0x75, 0x08, // Report Size (8)
0x91, 0x02, // Output (Data, Variable, Absolute)
0xC0 // End Collection