Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
attempt copy paste arduino bootkeyboard
diff --git a/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/usbd_mhid.h b/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/usbd_mhid.h
index af483adc6..576fab0d6 100644
--- a/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/usbd_mhid.h
+++ b/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/usbd_mhid.h
@@ -6,7 +6,7 @@
#define USBD_MHID_CONFIG_DESC_SIZE 32
#define USBD_MHID_DESC_SIZE 9
-#define USBD_MHID_REPORT_DESC_SIZE 178
+#define USBD_MHID_REPORT_DESC_SIZE 69
#define USBD_MHID_DIGITIZER_REPORT_DESC_SIZE 65
diff --git a/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/src/usbd_mhid.c b/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/src/usbd_mhid.c
index de9806131..02aec45d6 100644
--- a/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/src/usbd_mhid.c
+++ b/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/src/usbd_mhid.c
@@ -97,109 +97,51 @@ static const uint8_t USBD_MHID_CfgDesc[USBD_MHID_CONFIG_DESC_SIZE] =
__ALIGN_BEGIN static const uint8_t USBD_MHID_DefaultReportDesc[USBD_MHID_REPORT_DESC_SIZE] __ALIGN_END =
{
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x02, // USAGE (Mouse)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x85, 0x01, // REPORT_ID (1)
- 0x09, 0x01, // USAGE (Pointer)
- 0xa1, 0x00, // COLLECTION (Physical)
- 0x05, 0x09, // USAGE_PAGE (Button)
- 0x19, 0x01, // USAGE_MINIMUM (Button 1)
- 0x29, 0x03, // USAGE_MAXIMUM (Button 3)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x95, 0x03, // REPORT_COUNT (3)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x05, // REPORT_SIZE (5)
- 0x81, 0x03, // INPUT (Cnst,Var,Abs)
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x30, // USAGE (X)
- 0x09, 0x31, // USAGE (Y)
- // 0x36, 0x01, 0x80, // PHYSICAL_MINIMUM (-32767)
- // 0x46, 0xff, 0x7f, // PHYSICAL_MAXIMUM (32767)
- 0x16, 0x01, 0x80, // LOGICAL_MINIMUM (-32767)
- 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
- // 0x15, 0x81, // LOGICAL_MINIMUM (-127)
- // 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
- 0x75, 0x10, // REPORT_SIZE (16)
- 0x95, 0x02, // REPORT_COUNT (2)
- 0x81, 0x06, // INPUT (Data,Var,Rel)
- 0x09, 0x38, // USAGE (WHEEL)
- 0x15, 0x81, // LOGICAL_MINIMUM (-127)
- 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x81, 0x06, // INPUT (Data,Var,Rel)
- 0xc0, // END_COLLECTION
- 0xc0, // END_COLLECTION
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x06, // USAGE (Keyboard)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x85, 0x02, // REPORT_ID (2)
- 0x05, 0x07, // USAGE_PAGE (Keyboard)
- 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
- 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x95, 0x08, // REPORT_COUNT (8)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x81, 0x01, // INPUT (Cnst,Ary,Abs)
- // We don't use OUT endpoint to receive LED reports from host
- // 0x95, 0x05, // REPORT_COUNT (5)
- // 0x75, 0x01, // REPORT_SIZE (1)
- // 0x05, 0x08, // USAGE_PAGE (LEDs)
- // 0x19, 0x01, // USAGE_MINIMUM (Num Lock)
- // 0x29, 0x05, // USAGE_MAXIMUM (Kana)
- // 0x91, 0x02, // OUTPUT (Data,Var,Abs)
- // 0x95, 0x01, // REPORT_COUNT (1)
- // 0x75, 0x03, // REPORT_SIZE (3)
- // 0x91, 0x01, // OUTPUT (Cnst,Ary,Abs)
- 0x95, 0x06, // REPORT_COUNT (6)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0xdd, // LOGICAL_MAXIMUM (221)
- 0x05, 0x07, // USAGE_PAGE (Keyboard)
- 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
- 0x29, 0xdd, // USAGE_MAXIMUM (Keypad Hexadecimal)
- 0x81, 0x00, // INPUT (Data,Ary,Abs)
- 0xc0, // END_COLLECTION
- 0x05, 0x0d, // USAGE_PAGE (Digitizer)
- 0x09, 0x02, // USAGE (Pen)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x85, 0x03, // REPORT_ID (3)
- 0x09, 0x20, // USAGE (Stylus)
- 0xa1, 0x00, // COLLECTION (Physical)
- 0x09, 0x42, // USAGE (Tip Switch)
- 0x09, 0x32, // USAGE (In Rnage)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x95, 0x02, // REPORT_COUNT (2)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x95, 0x06, // REPORT_COUNT (6)
- 0x81, 0x01, // INPUT (Cnst,Ary,Abs)
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x01, // USAGE (Pointer)
- 0xa1, 0x00, // COLLECTION (Physical)
- 0x09, 0x30, // USAGE (X)
- 0x09, 0x31, // USAGE (Y)
- 0x16, 0x00, 0x00, // LOGICAL_MINIMUM (0)
- 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
- 0x36, 0x00, 0x00, // PHYSICAL_MINIMUM (0)
- 0x46, 0xff, 0x7f, // PHYSICAL_MAXIMUM (32767)
- 0x65, 0x00, // UNIT (None)
- 0x75, 0x10, // REPORT_SIZE (16)
- 0x95, 0x02, // REPORT_COUNT (2)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0xc0, // END_COLLECTION
- 0xc0, // END_COLLECTION
- 0xc0 // END_COLLECTION
+ // Keyboard
+ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 47 */
+ 0x09, 0x06, /* USAGE (Keyboard) */
+ 0xa1, 0x01, /* COLLECTION (Application) */
+ 0x05, 0x07, /* USAGE_PAGE (Keyboard) */
+
+ /* Keyboard Modifiers (shift, alt, ...) */
+ 0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */
+ 0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
+ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
+ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
+ 0x75, 0x01, /* REPORT_SIZE (1) */
+ 0x95, 0x08, /* REPORT_COUNT (8) */
+ 0x81, 0x02, /* INPUT (Data,Var,Abs) */
+
+ /* Reserved byte, used for consumer reports, only works with linux */
+ 0x05, 0x0C, /* Usage Page (Consumer) */
+ 0x95, 0x01, /* REPORT_COUNT (1) */
+ 0x75, 0x08, /* REPORT_SIZE (8) */
+ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
+ 0x26, 0xFF, 0x00, /* LOGICAL_MAXIMUM (255) */
+ 0x19, 0x00, /* USAGE_MINIMUM (0) */
+ 0x29, 0xFF, /* USAGE_MAXIMUM (255) */
+ 0x81, 0x00, /* INPUT (Data,Ary,Abs) */
+
+ /* 5 LEDs for num lock etc, 3 left for advanced, custom usage */
+ 0x05, 0x08, /* USAGE_PAGE (LEDs) */
+ 0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */
+ 0x29, 0x08, /* USAGE_MAXIMUM (Kana + 3 custom)*/
+ 0x95, 0x08, /* REPORT_COUNT (8) */
+ 0x75, 0x01, /* REPORT_SIZE (1) */
+ 0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
+
+ /* 6 Keyboard keys */
+ 0x05, 0x07, /* USAGE_PAGE (Keyboard) */
+ 0x95, 0x06, /* REPORT_COUNT (6) */
+ 0x75, 0x08, /* REPORT_SIZE (8) */
+ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
+ 0x26, 0xE7, 0x00, /* LOGICAL_MAXIMUM (231) */
+ 0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */
+ 0x29, 0xE7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
+ 0x81, 0x00, /* INPUT (Data,Ary,Abs) */
+
+ /* End */
+ 0xc0 /* END_COLLECTION */
};
static uint8_t USBD_MHID_Init(void* pdev, USBD_Composite_Class_Data* cls, uint8_t cfgidx)
diff --git a/wiring/inc/spark_wiring_usbkeyboard.h b/wiring/inc/spark_wiring_usbkeyboard.h
index 84bf58692..e30810835 100644
--- a/wiring/inc/spark_wiring_usbkeyboard.h
+++ b/wiring/inc/spark_wiring_usbkeyboard.h
@@ -34,7 +34,7 @@
typedef struct
{
- uint8_t reportId; // 0x02
+ /*uint8_t reportId; // 0x02*/
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
diff --git a/wiring/src/spark_wiring_usbkeyboard.cpp b/wiring/src/spark_wiring_usbkeyboard.cpp
index ab06089fb..0ca2ba130 100644
--- a/wiring/src/spark_wiring_usbkeyboard.cpp
+++ b/wiring/src/spark_wiring_usbkeyboard.cpp
@@ -168,7 +168,7 @@ extern const uint8_t usb_hid_asciimap[128] =
USBKeyboard::USBKeyboard(void)
{
memset((void*)&keyReport, 0, sizeof(keyReport));
- keyReport.reportId = 0x02;
+ /*keyReport.reportId = 0x02;*/
HAL_USB_HID_Init(0, NULL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.