diff options
Diffstat (limited to 'tmk_core/protocol/vusb')
-rw-r--r-- | tmk_core/protocol/vusb/protocol.c | 4 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/usb_util.c | 4 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 359 |
3 files changed, 187 insertions, 180 deletions
diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c index 644e77e021..20d0530483 100644 --- a/tmk_core/protocol/vusb/protocol.c +++ b/tmk_core/protocol/vusb/protocol.c @@ -97,7 +97,9 @@ static void vusb_wakeup(void) { * * FIXME: Needs doc */ -static void setup_usb(void) { initForUsbConnectivity(); } +static void setup_usb(void) { + initForUsbConnectivity(); +} uint16_t sof_timer = 0; diff --git a/tmk_core/protocol/vusb/usb_util.c b/tmk_core/protocol/vusb/usb_util.c index 4ee2d3188b..38c4352d55 100644 --- a/tmk_core/protocol/vusb/usb_util.c +++ b/tmk_core/protocol/vusb/usb_util.c @@ -16,7 +16,9 @@ #include <usbdrv/usbdrv.h> #include "usb_util.h" -void usb_disconnect(void) { usbDeviceDisconnect(); } +void usb_disconnect(void) { + usbDeviceDisconnect(); +} bool usb_connected_state(void) { usbPoll(); diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index bd0f1c21aa..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 @@ -647,7 +651,6 @@ const PROGMEM uchar console_hid_report[] = { # define USB_MAX_POWER_CONSUMPTION 500 #endif -// TODO: change this to 10ms to match LUFA #ifndef USB_POLLING_INTERVAL_MS # define USB_POLLING_INTERVAL_MS 1 #endif @@ -940,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; |