summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/vusb/vusb.c
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-12 10:29:31 -0800
committerGitHub <noreply@github.com>2022-02-12 18:29:31 +0000
commit63646e8906e062d1c1de3925cba70c4e3426a855 (patch)
tree4e91648b77b838e1125cf86331d7e84bde6d07a9 /tmk_core/protocol/vusb/vusb.c
parentafcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff)
Format code according to conventions (#16322)
Diffstat (limited to 'tmk_core/protocol/vusb/vusb.c')
-rw-r--r--tmk_core/protocol/vusb/vusb.c358
1 files changed, 181 insertions, 177 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 8bdcccc9c9..ebde955d3b 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -230,9 +230,13 @@ static void send_programmable_button(uint32_t data);
static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
-host_driver_t *vusb_driver(void) { return &driver; }
+host_driver_t *vusb_driver(void) {
+ return &driver;
+}
-static uint8_t keyboard_leds(void) { return keyboard_led_state; }
+static uint8_t keyboard_leds(void) {
+ return keyboard_led_state;
+}
static void send_keyboard(report_keyboard_t *report) {
uint8_t next = (kbuf_head + 1) % KBUF_SIZE;
@@ -348,7 +352,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
last_req.kind = SET_LED;
last_req.len = rq->wLength.word;
}
- return USB_NO_MSG; // to get data in usbFunctionWrite
+ return USB_NO_MSG; // to get data in usbFunctionWrite
} else {
dprint("UNKNOWN:");
}
@@ -410,47 +414,47 @@ const PROGMEM uchar shared_hid_report[] = {
#else
const PROGMEM uchar keyboard_hid_report[] = {
#endif
- 0x05, 0x01, // Usage Page (Generic Desktop)
- 0x09, 0x06, // Usage (Keyboard)
- 0xA1, 0x01, // Collection (Application)
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x06, // Usage (Keyboard)
+ 0xA1, 0x01, // Collection (Application)
#ifdef KEYBOARD_SHARED_EP
- 0x85, REPORT_ID_KEYBOARD, // Report ID
+ 0x85, REPORT_ID_KEYBOARD, // Report ID
#endif
// Modifiers (8 bits)
- 0x05, 0x07, // Usage Page (Keyboard/Keypad)
- 0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
- 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0x01, // Logical Maximum (1)
- 0x95, 0x08, // Report Count (8)
- 0x75, 0x01, // Report Size (1)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x05, 0x07, // Usage Page (Keyboard/Keypad)
+ 0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
+ 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x95, 0x08, // Report Count (8)
+ 0x75, 0x01, // Report Size (1)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
// Reserved (1 byte)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x03, // Input (Constant)
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x03, // Input (Constant)
// Keycodes (6 bytes)
- 0x05, 0x07, // Usage Page (Keyboard/Keypad)
- 0x19, 0x00, // Usage Minimum (0)
- 0x29, 0xFF, // Usage Maximum (255)
- 0x15, 0x00, // Logical Minimum (0)
- 0x26, 0xFF, 0x00, // Logical Maximum (255)
- 0x95, 0x06, // Report Count (6)
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0x05, 0x07, // Usage Page (Keyboard/Keypad)
+ 0x19, 0x00, // Usage Minimum (0)
+ 0x29, 0xFF, // Usage Maximum (255)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x95, 0x06, // Report Count (6)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
// Status LEDs (5 bits)
- 0x05, 0x08, // Usage Page (LED)
- 0x19, 0x01, // Usage Minimum (Num Lock)
- 0x29, 0x05, // Usage Maximum (Kana)
- 0x95, 0x05, // Report Count (5)
- 0x75, 0x01, // Report Size (1)
- 0x91, 0x02, // Output (Data, Variable, Absolute)
+ 0x05, 0x08, // Usage Page (LED)
+ 0x19, 0x01, // Usage Minimum (Num Lock)
+ 0x29, 0x05, // Usage Maximum (Kana)
+ 0x95, 0x05, // Report Count (5)
+ 0x75, 0x01, // Report Size (1)
+ 0x91, 0x02, // Output (Data, Variable, Absolute)
// LED padding (3 bits)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x03, // Report Size (3)
- 0x91, 0x03, // Output (Constant)
- 0xC0, // End Collection
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x03, // Report Size (3)
+ 0x91, 0x03, // Output (Constant)
+ 0xC0, // End Collection
#ifndef KEYBOARD_SHARED_EP
};
#endif
@@ -462,135 +466,135 @@ const PROGMEM uchar shared_hid_report[] = {
#ifdef MOUSE_ENABLE
// Mouse report descriptor
- 0x05, 0x01, // Usage Page (Generic Desktop)
- 0x09, 0x02, // Usage (Mouse)
- 0xA1, 0x01, // Collection (Application)
- 0x85, REPORT_ID_MOUSE, // Report ID
- 0x09, 0x01, // Usage (Pointer)
- 0xA1, 0x00, // Collection (Physical)
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x02, // Usage (Mouse)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_MOUSE, // Report ID
+ 0x09, 0x01, // Usage (Pointer)
+ 0xA1, 0x00, // Collection (Physical)
// Buttons (8 bits)
- 0x05, 0x09, // Usage Page (Button)
- 0x19, 0x01, // Usage Minimum (Button 1)
- 0x29, 0x08, // Usage Maximum (Button 8)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0x01, // Logical Maximum (1)
- 0x95, 0x08, // Report Count (8)
- 0x75, 0x01, // Report Size (1)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x05, 0x09, // Usage Page (Button)
+ 0x19, 0x01, // Usage Minimum (Button 1)
+ 0x29, 0x08, // Usage Maximum (Button 8)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x95, 0x08, // Report Count (8)
+ 0x75, 0x01, // Report Size (1)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
// X/Y position (2 bytes)
- 0x05, 0x01, // Usage Page (Generic Desktop)
- 0x09, 0x30, // Usage (X)
- 0x09, 0x31, // Usage (Y)
- 0x15, 0x81, // Logical Minimum (-127)
- 0x25, 0x7F, // Logical Maximum (127)
- 0x95, 0x02, // Report Count (2)
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x06, // Input (Data, Variable, Relative)
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x30, // Usage (X)
+ 0x09, 0x31, // Usage (Y)
+ 0x15, 0x81, // Logical Minimum (-127)
+ 0x25, 0x7F, // Logical Maximum (127)
+ 0x95, 0x02, // Report Count (2)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x06, // Input (Data, Variable, Relative)
// Vertical wheel (1 byte)
- 0x09, 0x38, // Usage (Wheel)
- 0x15, 0x81, // Logical Minimum (-127)
- 0x25, 0x7F, // Logical Maximum (127)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x06, // Input (Data, Variable, Relative)
+ 0x09, 0x38, // Usage (Wheel)
+ 0x15, 0x81, // Logical Minimum (-127)
+ 0x25, 0x7F, // Logical Maximum (127)
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x06, // Input (Data, Variable, Relative)
// Horizontal wheel (1 byte)
- 0x05, 0x0C, // Usage Page (Consumer)
- 0x0A, 0x38, 0x02, // Usage (AC Pan)
- 0x15, 0x81, // Logical Minimum (-127)
- 0x25, 0x7F, // Logical Maximum (127)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x06, // Input (Data, Variable, Relative)
- 0xC0, // End Collection
- 0xC0, // End Collection
+ 0x05, 0x0C, // Usage Page (Consumer)
+ 0x0A, 0x38, 0x02, // Usage (AC Pan)
+ 0x15, 0x81, // Logical Minimum (-127)
+ 0x25, 0x7F, // Logical Maximum (127)
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x06, // Input (Data, Variable, Relative)
+ 0xC0, // End Collection
+ 0xC0, // End Collection
#endif
#ifdef EXTRAKEY_ENABLE
// Extrakeys report descriptor
- 0x05, 0x01, // Usage Page (Generic Desktop)
- 0x09, 0x80, // Usage (System Control)
- 0xA1, 0x01, // Collection (Application)
- 0x85, REPORT_ID_SYSTEM, // Report ID
- 0x19, 0x01, // Usage Minimum (Pointer)
- 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale)
- 0x15, 0x01, // Logical Minimum
- 0x26, 0xB7, 0x00, // Logical Maximum
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x10, // Report Size (16)
- 0x81, 0x00, // Input (Data, Array, Absolute)
- 0xC0, // End Collection
-
- 0x05, 0x0C, // Usage Page (Consumer)
- 0x09, 0x01, // Usage (Consumer Control)
- 0xA1, 0x01, // Collection (Application)
- 0x85, REPORT_ID_CONSUMER, // Report ID
- 0x19, 0x01, // Usage Minimum (Consumer Control)
- 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications)
- 0x15, 0x01, // Logical Minimum
- 0x26, 0xA0, 0x02, // Logical Maximum
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x10, // Report Size (16)
- 0x81, 0x00, // Input (Data, Array, Absolute)
- 0xC0, // End Collection
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x80, // Usage (System Control)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_SYSTEM, // Report ID
+ 0x19, 0x01, // Usage Minimum (Pointer)
+ 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xB7, 0x00, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0xC0, // End Collection
+
+ 0x05, 0x0C, // Usage Page (Consumer)
+ 0x09, 0x01, // Usage (Consumer Control)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_CONSUMER, // Report ID
+ 0x19, 0x01, // Usage Minimum (Consumer Control)
+ 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xA0, 0x02, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0xC0, // End Collection
#endif
#ifdef DIGITIZER_ENABLE
// Digitizer report descriptor
- 0x05, 0x0D, // Usage Page (Digitizers)
- 0x09, 0x01, // Usage (Digitizer)
- 0xA1, 0x01, // Collection (Application)
- 0x85, REPORT_ID_DIGITIZER, // Report ID
- 0x09, 0x22, // Usage (Finger)
- 0xA1, 0x00, // Collection (Physical)
+ 0x05, 0x0D, // Usage Page (Digitizers)
+ 0x09, 0x01, // Usage (Digitizer)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_DIGITIZER, // Report ID
+ 0x09, 0x22, // Usage (Finger)
+ 0xA1, 0x00, // Collection (Physical)
// Tip Switch (1 bit)
- 0x09, 0x42, // Usage (Tip Switch)
- 0x15, 0x00, // Logical Minimum
- 0x25, 0x01, // Logical Maximum
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x01, // Report Size (16)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x09, 0x42, // Usage (Tip Switch)
+ 0x15, 0x00, // Logical Minimum
+ 0x25, 0x01, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x01, // Report Size (16)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
// In Range (1 bit)
- 0x09, 0x32, // Usage (In Range)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x09, 0x32, // Usage (In Range)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
// Padding (6 bits)
- 0x95, 0x06, // Report Count (6)
- 0x81, 0x03, // Input (Constant)
+ 0x95, 0x06, // Report Count (6)
+ 0x81, 0x03, // Input (Constant)
// X/Y Position (4 bytes)
- 0x05, 0x01, // Usage Page (Generic Desktop)
- 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x10, // Report Size (16)
- 0x65, 0x33, // Unit (Inch, English Linear)
- 0x55, 0x0E, // Unit Exponent (-2)
- 0x09, 0x30, // Usage (X)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
- 0x09, 0x31, // Usage (Y)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
- 0xC0, // End Collection
- 0xC0, // End Collection
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x65, 0x33, // Unit (Inch, English Linear)
+ 0x55, 0x0E, // Unit Exponent (-2)
+ 0x09, 0x30, // Usage (X)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x09, 0x31, // Usage (Y)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0xC0, // End Collection
+ 0xC0, // End Collection
#endif
#ifdef PROGRAMMABLE_BUTTON_ENABLE
// Programmable buttons report descriptor
- 0x05, 0x0C, // Usage Page (Consumer)
- 0x09, 0x01, // Usage (Consumer Control)
- 0xA1, 0x01, // Collection (Application)
- 0x85, REPORT_ID_PROGRAMMABLE_BUTTON, // Report ID
- 0x09, 0x03, // Usage (Programmable Buttons)
- 0xA1, 0x04, // Collection (Named Array)
- 0x05, 0x09, // Usage Page (Button)
- 0x19, 0x01, // Usage Minimum (Button 1)
- 0x29, 0x20, // Usage Maximum (Button 32)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0x01, // Logical Maximum (1)
- 0x95, 0x20, // Report Count (32)
- 0x75, 0x01, // Report Size (1)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
- 0xC0, // End Collection
- 0xC0, // End Collection
+ 0x05, 0x0C, // Usage Page (Consumer)
+ 0x09, 0x01, // Usage (Consumer Control)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_PROGRAMMABLE_BUTTON, // Report ID
+ 0x09, 0x03, // Usage (Programmable Buttons)
+ 0xA1, 0x04, // Collection (Named Array)
+ 0x05, 0x09, // Usage Page (Button)
+ 0x19, 0x01, // Usage Minimum (Button 1)
+ 0x29, 0x20, // Usage Maximum (Button 32)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x95, 0x20, // Report Count (32)
+ 0x75, 0x01, // Report Size (1)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0xC0, // End Collection
+ 0xC0, // End Collection
#endif
#ifdef SHARED_EP_ENABLE
@@ -599,47 +603,47 @@ const PROGMEM uchar shared_hid_report[] = {
#ifdef RAW_ENABLE
const PROGMEM uchar raw_hid_report[] = {
- 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined)
- 0x09, RAW_USAGE_ID, // Usage (Vendor Defined)
- 0xA1, 0x01, // Collection (Application)
+ 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined)
+ 0x09, RAW_USAGE_ID, // Usage (Vendor Defined)
+ 0xA1, 0x01, // Collection (Application)
// Data to host
- 0x09, 0x62, // Usage (Vendor Defined)
- 0x15, 0x00, // Logical Minimum (0)
- 0x26, 0xFF, 0x00, // Logical Maximum (255)
- 0x95, RAW_BUFFER_SIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x09, 0x62, // Usage (Vendor Defined)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x95, RAW_BUFFER_SIZE, // 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
- 0x75, 0x08, // Report Size (8)
- 0x91, 0x02, // Output (Data, Variable, Absolute)
- 0xC0 // End Collection
+ 0x09, 0x63, // Usage (Vendor Defined)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x95, RAW_BUFFER_SIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x91, 0x02, // Output (Data, Variable, Absolute)
+ 0xC0 // End Collection
};
#endif
#if defined(CONSOLE_ENABLE)
const PROGMEM uchar console_hid_report[] = {
- 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible)
- 0x09, 0x74, // Usage (Vendor Defined - PJRC Teensy compatible)
- 0xA1, 0x01, // Collection (Application)
+ 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible)
+ 0x09, 0x74, // Usage (Vendor Defined - PJRC Teensy compatible)
+ 0xA1, 0x01, // Collection (Application)
// Data to host
- 0x09, 0x75, // Usage (Vendor Defined)
- 0x15, 0x00, // Logical Minimum (0x00)
- 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
- 0x95, CONSOLE_BUFFER_SIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x09, 0x75, // Usage (Vendor Defined)
+ 0x15, 0x00, // Logical Minimum (0x00)
+ 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
+ 0x95, CONSOLE_BUFFER_SIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
// Data from host
- 0x09, 0x76, // Usage (Vendor Defined)
- 0x15, 0x00, // Logical Minimum (0x00)
- 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
- 0x95, CONSOLE_BUFFER_SIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x91, 0x02, // Output (Data)
- 0xC0 // End Collection
+ 0x09, 0x76, // Usage (Vendor Defined)
+ 0x15, 0x00, // Logical Minimum (0x00)
+ 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
+ 0x95, CONSOLE_BUFFER_SIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x91, 0x02, // Output (Data)
+ 0xC0 // End Collection
};
#endif
@@ -939,16 +943,16 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorZero;
len = usbStringDescriptorZero.header.bLength;
break;
- case 1: // iManufacturer
+ case 1: // iManufacturer
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorManufacturer;
len = usbStringDescriptorManufacturer.header.bLength;
break;
- case 2: // iProduct
+ case 2: // iProduct
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct;
len = usbStringDescriptorProduct.header.bLength;
break;
#if defined(SERIAL_NUMBER)
- case 3: // iSerialNumber
+ case 3: // iSerialNumber
usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial;
len = usbStringDescriptorSerial.header.bLength;
break;