From eb94f08c35b53d1952713c16801df92fa6e10404 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Mon, 28 Mar 2022 18:13:39 -0500 Subject: [PATCH] Guard USB HID descriptor definitions against clang-format Signed-off-by: Michael Richters --- .../usb/BootKeyboard/BootKeyboard.cpp | 2 + .../usb/DeviceAPIs/AbsoluteMouseAPI.h | 3 + .../driver/hid/keyboardio/usb/HID-Settings.h | 68 +++++++------- .../usb/MultiReport/AbsoluteMouse.cpp | 14 +-- .../usb/MultiReport/ConsumerControl.cpp | 30 +++--- .../keyboardio/usb/MultiReport/Gamepad.cpp | 92 ++++++++++--------- .../keyboardio/usb/MultiReport/Keyboard.cpp | 10 +- .../hid/keyboardio/usb/MultiReport/Mouse.cpp | 78 ++++++++-------- .../usb/MultiReport/SystemControl.cpp | 32 ++++--- .../usb/SingleReport/SingleAbsoluteMouse.cpp | 10 +- 10 files changed, 180 insertions(+), 159 deletions(-) diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/BootKeyboard/BootKeyboard.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/BootKeyboard/BootKeyboard.cpp index 36d0a093..efeeefcf 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/BootKeyboard/BootKeyboard.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/BootKeyboard/BootKeyboard.cpp @@ -29,6 +29,7 @@ THE SOFTWARE. // See Appendix B of USB HID spec static const uint8_t boot_keyboard_hid_descriptor_[] PROGMEM = { + // clang-format off // Keyboard D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, D_USAGE, D_USAGE_KEYBOARD, @@ -71,6 +72,7 @@ static const uint8_t boot_keyboard_hid_descriptor_[] PROGMEM = { D_USAGE_MAXIMUM, 0xff, D_INPUT, (D_DATA | D_ARRAY | D_ABSOLUTE), D_END_COLLECTION + // clang-format off }; #ifdef ARCH_HAS_CONFIGURABLE_EP_SIZES diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/DeviceAPIs/AbsoluteMouseAPI.h b/src/kaleidoscope/driver/hid/keyboardio/usb/DeviceAPIs/AbsoluteMouseAPI.h index 3989ef76..0bce2256 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/DeviceAPIs/AbsoluteMouseAPI.h +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/DeviceAPIs/AbsoluteMouseAPI.h @@ -32,6 +32,7 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/MouseButtons.h" #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" +// clang-format off #define DESCRIPTOR_ABS_MOUSE_BUTTONS \ /* 8 Buttons */ \ @@ -64,6 +65,8 @@ THE SOFTWARE. D_REPORT_COUNT, 0x01, /* REPORT_COUNT (1) */ \ D_INPUT, (D_DATA|D_VARIABLE|D_RELATIVE), +// clang-format on + #pragma pack(push, 1) typedef union { // Absolute mouse report: 8 buttons, 2 absolute axis, wheel diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/HID-Settings.h b/src/kaleidoscope/driver/hid/keyboardio/usb/HID-Settings.h index 0c0f871b..603e2660 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/HID-Settings.h +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/HID-Settings.h @@ -80,62 +80,64 @@ void USB_PackMessages(bool pack); #include -#define EPTYPE_DESCRIPTOR_SIZE uint8_t +#define EPTYPE_DESCRIPTOR_SIZE uint8_t #elif defined(ARDUINO_ARCH_SAM) #include -#define EPTYPE_DESCRIPTOR_SIZE uint32_t -#define EP_TYPE_INTERRUPT_IN (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \ - UOTGHS_DEVEPTCFG_EPDIR_IN | \ - UOTGHS_DEVEPTCFG_EPTYPE_BLK | \ - UOTGHS_DEVEPTCFG_EPBK_1_BANK | \ - UOTGHS_DEVEPTCFG_NBTRANS_1_TRANS | \ - UOTGHS_DEVEPTCFG_ALLOC) -#define EP_TYPE_INTERRUPT_OUT (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \ - UOTGHS_DEVEPTCFG_EPTYPE_BLK | \ - UOTGHS_DEVEPTCFG_EPBK_1_BANK | \ - UOTGHS_DEVEPTCFG_NBTRANS_1_TRANS | \ - UOTGHS_DEVEPTCFG_ALLOC) -#define USB_EP_SIZE EPX_SIZE -#define USB_SendControl USBD_SendControl -#define USB_Available USBD_Available -#define USB_Recv USBD_Recv -#define USB_Send USBD_Send -#define USB_Flush USBD_Flush +// clang-format off +#define EPTYPE_DESCRIPTOR_SIZE uint32_t +#define EP_TYPE_INTERRUPT_IN (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \ + UOTGHS_DEVEPTCFG_EPDIR_IN | \ + UOTGHS_DEVEPTCFG_EPTYPE_BLK | \ + UOTGHS_DEVEPTCFG_EPBK_1_BANK | \ + UOTGHS_DEVEPTCFG_NBTRANS_1_TRANS | \ + UOTGHS_DEVEPTCFG_ALLOC) +#define EP_TYPE_INTERRUPT_OUT (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \ + UOTGHS_DEVEPTCFG_EPTYPE_BLK | \ + UOTGHS_DEVEPTCFG_EPBK_1_BANK | \ + UOTGHS_DEVEPTCFG_NBTRANS_1_TRANS | \ + UOTGHS_DEVEPTCFG_ALLOC) +#define USB_EP_SIZE EPX_SIZE +#define USB_SendControl USBD_SendControl +#define USB_Available USBD_Available +#define USB_Recv USBD_Recv +#define USB_Send USBD_Send +#define USB_Flush USBD_Flush +// clang-format on #elif defined(ARDUINO_ARCH_SAMD) #include -#define EPTYPE_DESCRIPTOR_SIZE uint32_t -#define EP_TYPE_INTERRUPT_IN USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_IN(0); -#define EP_TYPE_INTERRUPT_OUT USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_OUT(0); -#define USB_EP_SIZE EPX_SIZE -//#define USB_SendControl USBDevice.sendControl -> real C++ functions to take care of PGM overloading -#define USB_Available USBDevice.available -#define USB_Recv USBDevice.recv -#define USB_RecvControl USBDevice.recvControl -#define USB_Send USBDevice.send -#define USB_Flush USBDevice.flush +#define EPTYPE_DESCRIPTOR_SIZE uint32_t +#define EP_TYPE_INTERRUPT_IN USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_IN(0); +#define EP_TYPE_INTERRUPT_OUT USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_OUT(0); +#define USB_EP_SIZE EPX_SIZE +//#define USB_SendControl USBDevice.sendControl -> real C++ functions to take care of PGM overloading +#define USB_Available USBDevice.available +#define USB_Recv USBDevice.recv +#define USB_RecvControl USBDevice.recvControl +#define USB_Send USBDevice.send +#define USB_Flush USBDevice.flush int USB_SendControl(void* y, uint8_t z); int USB_SendControl(uint8_t x, const void* y, uint8_t z); -#define TRANSFER_PGM 0 -#define TRANSFER_RELEASE 0 +#define TRANSFER_PGM 0 +#define TRANSFER_RELEASE 0 #elif defined(ARDUINO_ARCH_GD32) #include "USBCore.h" -#define EPTYPE_DESCRIPTOR_SIZE unsigned int +#define EPTYPE_DESCRIPTOR_SIZE unsigned int // Should eventually get defined upstream #ifndef USB_DEVICE_CLASS_HUMAN_INTERFACE -#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 +#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 #endif #define ARCH_HAS_CONFIGURABLE_EP_SIZES diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/AbsoluteMouse.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/AbsoluteMouse.cpp index dc33161d..4c8b9f99 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/AbsoluteMouse.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/AbsoluteMouse.cpp @@ -27,17 +27,19 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" static const uint8_t absolute_mouse_hid_descriptor_[] PROGMEM = { - /* Mouse absolute */ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) 54 */ - D_USAGE, D_USAGE_MOUSE, /* USAGE (Mouse) */ - D_COLLECTION, D_APPLICATION, /* COLLECTION (Application) */ - D_REPORT_ID, HID_REPORTID_MOUSE_ABSOLUTE, /* REPORT_ID */ + // clang-format off + // Mouse absolute + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) 54 + D_USAGE, D_USAGE_MOUSE, // USAGE (Mouse) + D_COLLECTION, D_APPLICATION, // COLLECTION (Application) + D_REPORT_ID, HID_REPORTID_MOUSE_ABSOLUTE, // REPORT_ID DESCRIPTOR_ABS_MOUSE_BUTTONS DESCRIPTOR_ABS_MOUSE_XY DESCRIPTOR_ABS_MOUSE_WHEEL - D_END_COLLECTION /* End */ + D_END_COLLECTION // End + // clang-format off }; AbsoluteMouse_::AbsoluteMouse_() { diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/ConsumerControl.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/ConsumerControl.cpp index db572ee1..c7e6303d 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/ConsumerControl.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/ConsumerControl.cpp @@ -27,20 +27,22 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" static const uint8_t consumer_control_hid_descriptor_[] PROGMEM = { - /* Consumer Control (Sound/Media keys) */ - D_USAGE_PAGE, 0x0C, /* usage page (consumer device) */ - D_USAGE, 0x01, /* usage -- consumer control */ - D_COLLECTION, D_APPLICATION, /* collection (application) */ - D_REPORT_ID, HID_REPORTID_CONSUMERCONTROL, /* report id */ - /* 4 Media Keys */ - D_LOGICAL_MINIMUM, 0x00, /* logical minimum */ - D_MULTIBYTE(D_LOGICAL_MAXIMUM), 0xFF, 0x03, /* logical maximum (3ff) */ - D_USAGE_MINIMUM, 0x00, /* usage minimum (0) */ - D_MULTIBYTE(D_USAGE_MAXIMUM), 0xFF, 0x03, /* usage maximum (3ff) */ - D_REPORT_COUNT, 0x04, /* report count (4) */ - D_REPORT_SIZE, 0x10, /* report size (16) */ - D_INPUT, 0x00, /* input */ - D_END_COLLECTION /* end collection */ + // clang-format off + // Consumer Control (Sound/Media keys) + D_USAGE_PAGE, 0x0C, // usage page (consumer device) + D_USAGE, 0x01, // usage -- consumer control + D_COLLECTION, D_APPLICATION, // collection (application) + D_REPORT_ID, HID_REPORTID_CONSUMERCONTROL, // report id + // 4 Media Keys + D_LOGICAL_MINIMUM, 0x00, // logical minimum + D_MULTIBYTE(D_LOGICAL_MAXIMUM), 0xFF, 0x03, // logical maximum (3ff) + D_USAGE_MINIMUM, 0x00, // usage minimum (0) + D_MULTIBYTE(D_USAGE_MAXIMUM), 0xFF, 0x03, // usage maximum (3ff) + D_REPORT_COUNT, 0x04, // report count (4) + D_REPORT_SIZE, 0x10, // report size (16) + D_INPUT, 0x00, // input + D_END_COLLECTION // end collection + // clang-format on }; ConsumerControl_::ConsumerControl_() { diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Gamepad.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Gamepad.cpp index c5ddbf21..63d23a85 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Gamepad.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Gamepad.cpp @@ -27,51 +27,53 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" static const uint8_t gamepad_hid_descriptor_[] PROGMEM = { - /* Gamepad with 32 buttons and 6 axis*/ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) */ - D_USAGE, D_USAGE_JOYSTICK, /* USAGE (Joystick) */ - D_COLLECTION, D_APPLICATION, /* COLLECTION (Application) */ - D_REPORT_ID, HID_REPORTID_GAMEPAD, /* REPORT_ID */ - /* 32 Buttons */ - D_USAGE_PAGE, D_PAGE_BUTTON, /* USAGE_PAGE (Button) */ - D_USAGE_MINIMUM, 0x01, /* USAGE_MINIMUM (Button 1) */ - D_USAGE_MAXIMUM, 0x20, /* USAGE_MAXIMUM (Button 32) */ - D_LOGICAL_MINIMUM, 0x00, /* LOGICAL_MINIMUM (0) */ - D_LOGICAL_MAXIMUM, 0x01, /* LOGICAL_MAXIMUM (1) */ - D_REPORT_SIZE, 0x01, /* REPORT_SIZE (1) */ - D_REPORT_COUNT, 0x20, /* REPORT_COUNT (32) */ - D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), /* INPUT (Data,Var,Abs) */ - /* 4 16bit Axis */ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) */ - D_COLLECTION, D_PHYSICAL, /* COLLECTION (Physical) */ - D_USAGE, 0x30, /* USAGE (X) */ - D_USAGE, 0x31, /* USAGE (Y) */ - D_USAGE, 0x33, /* USAGE (Rx) */ - D_USAGE, 0x34, /* USAGE (Ry) */ - D_MULTIBYTE(D_LOGICAL_MINIMUM), 0x00, 0x80, /* LOGICAL_MINIMUM (-32768) */ - D_MULTIBYTE(D_LOGICAL_MAXIMUM), 0xFF, 0x7F, /* LOGICAL_MAXIMUM (32767) */ - D_REPORT_SIZE, 0x10, /* REPORT_SIZE (16) */ - D_REPORT_COUNT, 0x04, /* REPORT_COUNT (4) */ - D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), /* INPUT (Data,Var,Abs) */ - /* 2 8bit Axis */ - D_USAGE, 0x32, /* USAGE (Z) */ - D_USAGE, 0x35, /* USAGE (Rz) */ - D_LOGICAL_MINIMUM, 0x80, /* LOGICAL_MINIMUM (-128) */ - D_LOGICAL_MAXIMUM, 0x7F, /* LOGICAL_MAXIMUM (127) */ - D_REPORT_SIZE, 0x08, /* REPORT_SIZE (8) */ - D_REPORT_COUNT, 0x02, /* REPORT_COUNT (2) */ - D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), /* INPUT (Data,Var,Abs) */ - D_END_COLLECTION, /* END_COLLECTION */ - /* 2 Hat Switches */ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) */ - D_USAGE, 0x39, /* USAGE (Hat switch) */ - D_USAGE, 0x39, /* USAGE (Hat switch) */ - D_LOGICAL_MINIMUM, 0x01, /* LOGICAL_MINIMUM (1) */ - D_LOGICAL_MAXIMUM, 0x08, /* LOGICAL_MAXIMUM (8) */ - D_REPORT_COUNT, 0x02, /* REPORT_COUNT (2) */ - D_REPORT_SIZE, 0x04, /* REPORT_SIZE (4) */ - D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), /* INPUT (Data,Var,Abs) */ - D_END_COLLECTION /* END_COLLECTION */ + // clang-format off + // Gamepad with 32 buttons and 6 axis + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) + D_USAGE, D_USAGE_JOYSTICK, // USAGE (Joystick) + D_COLLECTION, D_APPLICATION, // COLLECTION (Application) + D_REPORT_ID, HID_REPORTID_GAMEPAD, // REPORT_ID + // 32 Buttons + D_USAGE_PAGE, D_PAGE_BUTTON, // USAGE_PAGE (Button) + D_USAGE_MINIMUM, 0x01, // USAGE_MINIMUM (Button 1) + D_USAGE_MAXIMUM, 0x20, // USAGE_MAXIMUM (Button 32) + D_LOGICAL_MINIMUM, 0x00, // LOGICAL_MINIMUM (0) + D_LOGICAL_MAXIMUM, 0x01, // LOGICAL_MAXIMUM (1) + D_REPORT_SIZE, 0x01, // REPORT_SIZE (1) + D_REPORT_COUNT, 0x20, // REPORT_COUNT (32) + D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs) + // 4 16bit Axis + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) + D_COLLECTION, D_PHYSICAL, // COLLECTION (Physical) + D_USAGE, 0x30, // USAGE (X) + D_USAGE, 0x31, // USAGE (Y) + D_USAGE, 0x33, // USAGE (Rx) + D_USAGE, 0x34, // USAGE (Ry) + D_MULTIBYTE(D_LOGICAL_MINIMUM), 0x00, 0x80, // LOGICAL_MINIMUM (-32768) + D_MULTIBYTE(D_LOGICAL_MAXIMUM), 0xFF, 0x7F, // LOGICAL_MAXIMUM (32767) + D_REPORT_SIZE, 0x10, // REPORT_SIZE (16) + D_REPORT_COUNT, 0x04, // REPORT_COUNT (4) + D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs) + // 2 8bit Axis + D_USAGE, 0x32, // USAGE (Z) + D_USAGE, 0x35, // USAGE (Rz) + D_LOGICAL_MINIMUM, 0x80, // LOGICAL_MINIMUM (-128) + D_LOGICAL_MAXIMUM, 0x7F, // LOGICAL_MAXIMUM (127) + D_REPORT_SIZE, 0x08, // REPORT_SIZE (8) + D_REPORT_COUNT, 0x02, // REPORT_COUNT (2) + D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs) + D_END_COLLECTION, // END_COLLECTION + // 2 Hat Switches + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) + D_USAGE, 0x39, // USAGE (Hat switch) + D_USAGE, 0x39, // USAGE (Hat switch) + D_LOGICAL_MINIMUM, 0x01, // LOGICAL_MINIMUM (1) + D_LOGICAL_MAXIMUM, 0x08, // LOGICAL_MAXIMUM (8) + D_REPORT_COUNT, 0x02, // REPORT_COUNT (2) + D_REPORT_SIZE, 0x04, // REPORT_SIZE (4) + D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs) + D_END_COLLECTION // END_COLLECTION + // clang-format on }; Gamepad_::Gamepad_() { diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Keyboard.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Keyboard.cpp index d13e30db..2e5bdb94 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Keyboard.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Keyboard.cpp @@ -27,14 +27,15 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" static const uint8_t nkro_keyboard_hid_descriptor_[] PROGMEM = { - // NKRO Keyboard + // clang-format off + // NKRO Keyboard D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, D_USAGE, D_USAGE_KEYBOARD, D_COLLECTION, D_APPLICATION, D_REPORT_ID, HID_REPORTID_NKRO_KEYBOARD, D_USAGE_PAGE, D_PAGE_KEYBOARD, - /* Key modifier byte */ + // Key modifier byte D_USAGE_MINIMUM, HID_KEYBOARD_FIRST_MODIFIER, D_USAGE_MAXIMUM, HID_KEYBOARD_LAST_MODIFIER, D_LOGICAL_MINIMUM, 0x00, @@ -43,7 +44,7 @@ static const uint8_t nkro_keyboard_hid_descriptor_[] PROGMEM = { D_REPORT_COUNT, 0x08, D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), - /* 5 LEDs for num lock etc, 3 left for advanced, custom usage */ + // 5 LEDs for num lock etc, 3 left for advanced, custom usage D_USAGE_PAGE, D_PAGE_LEDS, D_USAGE_MINIMUM, 0x01, D_USAGE_MAXIMUM, 0x08, @@ -51,7 +52,7 @@ static const uint8_t nkro_keyboard_hid_descriptor_[] PROGMEM = { D_REPORT_SIZE, 0x01, D_OUTPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), - /* NKRO Keyboard */ + // NKRO Keyboard D_USAGE_PAGE, D_PAGE_KEYBOARD, // Padding 4 bits, to skip NO_EVENT & 3 error states. @@ -73,6 +74,7 @@ static const uint8_t nkro_keyboard_hid_descriptor_[] PROGMEM = { D_INPUT, (D_CONSTANT), D_END_COLLECTION, + // clang-format on }; Keyboard_::Keyboard_() { diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Mouse.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Mouse.cpp index 2dca172c..34e74952 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Mouse.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/Mouse.cpp @@ -27,44 +27,46 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" static const uint8_t mouse_hid_descriptor_[] PROGMEM = { - /* Mouse relative */ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) - D_USAGE, D_USAGE_MOUSE, // USAGE (Mouse) - D_COLLECTION, D_APPLICATION, // COLLECTION (Application) - D_REPORT_ID, HID_REPORTID_MOUSE, // REPORT_ID (Mouse) - - /* 8 Buttons */ - D_USAGE_PAGE, D_PAGE_BUTTON, // USAGE_PAGE (Button) - D_USAGE_MINIMUM, 0x01, // USAGE_MINIMUM (Button 1) - D_USAGE_MAXIMUM, 0x08, // USAGE_MAXIMUM (Button 8) - D_LOGICAL_MINIMUM, 0x00, // LOGICAL_MINIMUM (0) - D_LOGICAL_MAXIMUM, 0x01, // LOGICAL_MAXIMUM (1) - D_REPORT_COUNT, 0x08, // REPORT_COUNT (8) - D_REPORT_SIZE, 0x01, // REPORT_SIZE (1) - D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs) - - /* X, Y, Wheel */ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) - D_USAGE, 0x30, // USAGE (X) - D_USAGE, 0x31, // USAGE (Y) - D_USAGE, 0x38, // USAGE (Wheel) - D_LOGICAL_MINIMUM, 0x81, // LOGICAL_MINIMUM (-127) - D_LOGICAL_MAXIMUM, 0x7f, // LOGICAL_MAXIMUM (127) - D_REPORT_SIZE, 0x08, // REPORT_SIZE (8) - D_REPORT_COUNT, 0x03, // REPORT_COUNT (3) - D_INPUT, (D_DATA | D_VARIABLE | D_RELATIVE), // INPUT (Data,Var,Rel) - - /* Horizontal wheel */ - D_USAGE_PAGE, D_PAGE_CONSUMER, // USAGE_PAGE (Consumer) - D_PAGE_ORDINAL, 0x38, 0x02, // PAGE (AC Pan) - D_LOGICAL_MINIMUM, 0x81, // LOGICAL_MINIMUM (-127) - D_LOGICAL_MAXIMUM, 0x7f, // LOGICAL_MAXIMUM (127) - D_REPORT_SIZE, 0x08, // REPORT_SIZE (8) - D_REPORT_COUNT, 0x01, // REPORT_COUNT (1) - D_INPUT, (D_DATA | D_VARIABLE | D_RELATIVE), // INPUT (Data,Var,Rel) - - /* End */ - D_END_COLLECTION // END_COLLECTION + // clang-format off + // Mouse relative + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) + D_USAGE, D_USAGE_MOUSE, // USAGE (Mouse) + D_COLLECTION, D_APPLICATION, // COLLECTION (Application) + D_REPORT_ID, HID_REPORTID_MOUSE, // REPORT_ID (Mouse) + + // 8 Buttons + D_USAGE_PAGE, D_PAGE_BUTTON, // USAGE_PAGE (Button) + D_USAGE_MINIMUM, 0x01, // USAGE_MINIMUM (Button 1) + D_USAGE_MAXIMUM, 0x08, // USAGE_MAXIMUM (Button 8) + D_LOGICAL_MINIMUM, 0x00, // LOGICAL_MINIMUM (0) + D_LOGICAL_MAXIMUM, 0x01, // LOGICAL_MAXIMUM (1) + D_REPORT_COUNT, 0x08, // REPORT_COUNT (8) + D_REPORT_SIZE, 0x01, // REPORT_SIZE (1) + D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs) + + // X, Y, Wheel + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) + D_USAGE, 0x30, // USAGE (X) + D_USAGE, 0x31, // USAGE (Y) + D_USAGE, 0x38, // USAGE (Wheel) + D_LOGICAL_MINIMUM, 0x81, // LOGICAL_MINIMUM (-127) + D_LOGICAL_MAXIMUM, 0x7f, // LOGICAL_MAXIMUM (127) + D_REPORT_SIZE, 0x08, // REPORT_SIZE (8) + D_REPORT_COUNT, 0x03, // REPORT_COUNT (3) + D_INPUT, (D_DATA | D_VARIABLE | D_RELATIVE), // INPUT (Data,Var,Rel) + + // Horizontal wheel + D_USAGE_PAGE, D_PAGE_CONSUMER, // USAGE_PAGE (Consumer) + D_PAGE_ORDINAL, 0x38, 0x02, // PAGE (AC Pan) + D_LOGICAL_MINIMUM, 0x81, // LOGICAL_MINIMUM (-127) + D_LOGICAL_MAXIMUM, 0x7f, // LOGICAL_MAXIMUM (127) + D_REPORT_SIZE, 0x08, // REPORT_SIZE (8) + D_REPORT_COUNT, 0x01, // REPORT_COUNT (1) + D_INPUT, (D_DATA | D_VARIABLE | D_RELATIVE), // INPUT (Data,Var,Rel) + + // End + D_END_COLLECTION // END_COLLECTION + // clang-format on }; Mouse_::Mouse_() { diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/SystemControl.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/SystemControl.cpp index 66a4c1f8..ee3b65a0 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/SystemControl.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/MultiReport/SystemControl.cpp @@ -27,21 +27,23 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h" static const uint8_t system_control_hid_descriptor_[] PROGMEM = { - //TODO(anyone) limit to system keys only? - /* System Control (Power Down, Sleep, Wakeup, ...) */ - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) */ - D_USAGE, 0x80, /* USAGE (System Control) */ - D_COLLECTION, D_APPLICATION, /* COLLECTION (Application) */ - D_REPORT_ID, HID_REPORTID_SYSTEMCONTROL, /* REPORT_ID */ - /* 1 system key */ - D_LOGICAL_MINIMUM, 0x00, /* LOGICAL_MINIMUM (0) */ - D_MULTIBYTE(D_LOGICAL_MAXIMUM), 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ - D_USAGE_MINIMUM, 0x00, /* USAGE_MINIMUM (Undefined) */ - D_USAGE_MAXIMUM, 0xff, /* USAGE_MAXIMUM (System Menu Down) */ - D_REPORT_COUNT, 0x01, /* REPORT_COUNT (1) */ - D_REPORT_SIZE, 0x08, /* REPORT_SIZE (8) */ - D_INPUT, (D_DATA | D_ARRAY | D_ABSOLUTE), /* INPUT (Data,Ary,Abs) */ - D_END_COLLECTION /* END_COLLECTION */ + // clang-format off + // TODO(anyone) limit to system keys only? + // System Control (Power Down, Sleep, Wakeup, ...) + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) + D_USAGE, 0x80, // USAGE (System Control) + D_COLLECTION, D_APPLICATION, // COLLECTION (Application) + D_REPORT_ID, HID_REPORTID_SYSTEMCONTROL, // REPORT_ID + // 1 system key + D_LOGICAL_MINIMUM, 0x00, // LOGICAL_MINIMUM (0) + D_MULTIBYTE(D_LOGICAL_MAXIMUM), 0xff, 0x00, // LOGICAL_MAXIMUM (255) + D_USAGE_MINIMUM, 0x00, // USAGE_MINIMUM (Undefined) + D_USAGE_MAXIMUM, 0xff, // USAGE_MAXIMUM (System Menu Down) + D_REPORT_COUNT, 0x01, // REPORT_COUNT (1) + D_REPORT_SIZE, 0x08, // REPORT_SIZE (8) + D_INPUT, (D_DATA | D_ARRAY | D_ABSOLUTE), // INPUT (Data,Ary,Abs) + D_END_COLLECTION // END_COLLECTION + // clang-format on }; SystemControl_::SystemControl_() { diff --git a/src/kaleidoscope/driver/hid/keyboardio/usb/SingleReport/SingleAbsoluteMouse.cpp b/src/kaleidoscope/driver/hid/keyboardio/usb/SingleReport/SingleAbsoluteMouse.cpp index 1bab6158..48eb89ff 100644 --- a/src/kaleidoscope/driver/hid/keyboardio/usb/SingleReport/SingleAbsoluteMouse.cpp +++ b/src/kaleidoscope/driver/hid/keyboardio/usb/SingleReport/SingleAbsoluteMouse.cpp @@ -27,14 +27,16 @@ THE SOFTWARE. #include "kaleidoscope/driver/hid/keyboardio/usb/HIDReportObserver.h" static const uint8_t _hidSingleReportDescriptorAbsoluteMouse[] PROGMEM = { - D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, /* USAGE_PAGE (Generic Desktop) 54 */ - D_USAGE, D_USAGE_MOUSE, /* USAGE (Mouse) */ - D_COLLECTION, D_APPLICATION, /* COLLECTION (Application) */ + // clang-format off + D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop) 54 + D_USAGE, D_USAGE_MOUSE, // USAGE (Mouse) + D_COLLECTION, D_APPLICATION, // COLLECTION (Application) DESCRIPTOR_ABS_MOUSE_BUTTONS DESCRIPTOR_ABS_MOUSE_XY DESCRIPTOR_ABS_MOUSE_WHEEL - D_END_COLLECTION /* End */ + D_END_COLLECTION // End + // clang-format on }; #ifdef ARCH_HAS_CONFIGURABLE_EP_SIZES