From 33bbf44199076912b794caa8a7583aeba0756675 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Wed, 14 Feb 2018 00:27:53 +0100 Subject: [PATCH] Fix system keyboard descriptor, so it is byte-aligned (#93) I have verified that the descriptor shows up correctly on Windows 7 and macOS The descriptor is based on the two following pages: https://github.com/Microsoft/Windows-driver-samples/tree/master/hid/hidusbfx2 and https://docs.microsoft.com/en-us/windows-hardware/drivers/gpiobtn/hid-button-report-descriptors Fixes #76 --- .../usb_descriptor_system_keyboard_report.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c b/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c index fe6e005..abe528c 100644 --- a/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c +++ b/right/src/usb_descriptors/usb_descriptor_system_keyboard_report.c @@ -5,14 +5,16 @@ uint8_t UsbSystemKeyboardReportDescriptor[USB_SYSTEM_KEYBOARD_REPORT_DESCRIPTOR_ HID_RI_USAGE_PAGE(8, HID_RI_USAGE_PAGE_GENERIC_DESKTOP), HID_RI_USAGE(8, HID_RI_USAGE_GENERIC_DESKTOP_SYSTEM_CONTROL), HID_RI_COLLECTION(8, HID_RI_COLLECTION_APPLICATION), - // System key - HID_RI_REPORT_SIZE(8, 2), - HID_RI_REPORT_COUNT(8, USB_SYSTEM_KEYBOARD_MAX_KEYS), - HID_RI_LOGICAL_MINIMUM(8, 1), - HID_RI_LOGICAL_MAXIMUM(8, 3), - HID_RI_USAGE(8, 0x82), - HID_RI_USAGE(8, 0x81), - HID_RI_USAGE(8, 0x83), - HID_RI_INPUT(8, HID_IOF_NO_PREFERRED_STATE | HID_IOF_NULLSTATE), + // System keys + HID_RI_USAGE_MINIMUM(8, 0x81), // SYSTEM_POWER_DOWN, SYSTEM_SLEEP and SYSTEM_WAKE_UP + HID_RI_USAGE_MAXIMUM(8, 0x83), + HID_RI_REPORT_SIZE(8, 1), + HID_RI_REPORT_COUNT(8, 3), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + + // Padding + HID_RI_REPORT_SIZE(8, 1), + HID_RI_REPORT_COUNT(8, 5), + HID_RI_INPUT(8, HID_IOF_CONSTANT | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), HID_RI_END_COLLECTION(0), };