Guard USB HID descriptor definitions against clang-format

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
f/driver/keyboardiohid
Michael Richters 3 years ago
parent 29da47a155
commit eb94f08c35
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -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

@ -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

@ -86,6 +86,7 @@ void USB_PackMessages(bool pack);
#include <PluggableUSB.h>
// clang-format off
#define EPTYPE_DESCRIPTOR_SIZE uint32_t
#define EP_TYPE_INTERRUPT_IN (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \
UOTGHS_DEVEPTCFG_EPDIR_IN | \
@ -104,6 +105,7 @@ void USB_PackMessages(bool pack);
#define USB_Recv USBD_Recv
#define USB_Send USBD_Send
#define USB_Flush USBD_Flush
// clang-format on
#elif defined(ARDUINO_ARCH_SAMD)

@ -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_() {

@ -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_() {

@ -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_() {

@ -27,6 +27,7 @@ THE SOFTWARE.
#include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h"
static const uint8_t nkro_keyboard_hid_descriptor_[] PROGMEM = {
// clang-format off
// NKRO Keyboard
D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP,
D_USAGE, D_USAGE_KEYBOARD,
@ -34,7 +35,7 @@ static const uint8_t nkro_keyboard_hid_descriptor_[] PROGMEM = {
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_() {

@ -27,13 +27,14 @@ THE SOFTWARE.
#include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h"
static const uint8_t mouse_hid_descriptor_[] PROGMEM = {
/* Mouse relative */
// 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 */
// 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)
@ -43,7 +44,7 @@ static const uint8_t mouse_hid_descriptor_[] PROGMEM = {
D_REPORT_SIZE, 0x01, // REPORT_SIZE (1)
D_INPUT, (D_DATA | D_VARIABLE | D_ABSOLUTE), // INPUT (Data,Var,Abs)
/* X, Y, Wheel */
// X, Y, Wheel
D_USAGE_PAGE, D_PAGE_GENERIC_DESKTOP, // USAGE_PAGE (Generic Desktop)
D_USAGE, 0x30, // USAGE (X)
D_USAGE, 0x31, // USAGE (Y)
@ -54,7 +55,7 @@ static const uint8_t mouse_hid_descriptor_[] PROGMEM = {
D_REPORT_COUNT, 0x03, // REPORT_COUNT (3)
D_INPUT, (D_DATA | D_VARIABLE | D_RELATIVE), // INPUT (Data,Var,Rel)
/* Horizontal wheel */
// 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)
@ -63,8 +64,9 @@ static const uint8_t mouse_hid_descriptor_[] PROGMEM = {
D_REPORT_COUNT, 0x01, // REPORT_COUNT (1)
D_INPUT, (D_DATA | D_VARIABLE | D_RELATIVE), // INPUT (Data,Var,Rel)
/* End */
// End
D_END_COLLECTION // END_COLLECTION
// clang-format on
};
Mouse_::Mouse_() {

@ -27,21 +27,23 @@ THE SOFTWARE.
#include "kaleidoscope/driver/hid/keyboardio/usb/DescriptorPrimitives.h"
static const uint8_t system_control_hid_descriptor_[] PROGMEM = {
// 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 */
// 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_() {

@ -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

Loading…
Cancel
Save