0

I have this standard HID descriptor below running on STM32, it works with standard keyboard keys, but not with special keypad ones:

#define HID_USAGE_KEY_KEYPAD_LEFT_PARENTHESIS (0xB6)                // Sel
#define HID_USAGE_KEY_KEYPAD_RIGHT_PARENTHESIS (0xB7)               // Sel

HID table:

0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)

// 1bte modifiers
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) 1bitx8
0x95, 0x08, //   REPORT_COUNT (8)
0x81, 0x02, //   INPUT (Data,Var,Abs)

// 1byte LED
0x95, 0x01, //   REPORT_COUNT (1)
0x75, 0x08, //   REPORT_SIZE (8)
0x81, 0x03, //   INPUT (Cnst,Var,Abs)
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)  1bitx3 filler
0x75, 0x03, //   REPORT_SIZE (3)
0x91, 0x03, //   OUTPUT (Cnst,Var,Abs)

// 6bytes
0x05, 0x07, //   USAGE_PAGE (Keyboard)
0x19, 0x00, //   USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0xff, //   USAGE_MAXIMUM (Keyboard Application)
0x15, 0x00, //   LOGICAL_MINIMUM (0)
0x25, 0xff, //   LOGICAL_MAXIMUM
0x75, 0x08, //   REPORT_SIZE (8)  8bit x 6byte
0x95, 0x06, //   REPORT_COUNT (6)
0x81, 0x00, //   INPUT (Data,Ary,Abs)

0xc0 // END_COLLECTION

I tried to set ranges to 00-FF, but looks like those keys are never seen by Windows 10. (also tried to capture raw key presses)

My report looks like:

typedef struct
{
  uint8_t MODIFIER; /* bitfield */
  uint8_t RESERVED;
  uint8_t KEYCODES[6]; 
} subKeyBoard;

Again, it works great with standard 101 keyboard keys. Numlock also doesn't make a difference.

I want these keys to be recognised:

#define HID_USAGE_KEY_KEYPAD_LEFT_PARENTHESIS (0xB6)                // Sel
#define HID_USAGE_KEY_KEYPAD_RIGHT_PARENTHESIS (0xB7)               // Sel

My HID descriptor can be wrong, it's hard to validate.

Eva4684
  • 21
  • 3
  • Not sure if it makes a difference, but the only error I see in the HID descriptor is that 0x25 0xFF (which means -1) should be 0x26 0xFF 0x00 (which means 255). The LOGICAL_MAXIMUM item is a signed value. – aja Apr 22 '23 at 10:14
  • Thank you. I didn't know that, will give it a go on Monday, although existing keys still worked with it, so I guess OS ignored it. – Eva4684 Apr 22 '23 at 16:03
  • How does it know if I mean 8bit or 16bit signed value? All examples use single byte 0x64 as max. – Eva4684 Apr 22 '23 at 16:07
  • Each item code has 2 bits that indicate the length of the item value (the spec explains that). For example, for LOGICAL_MAXIMUM you can code 2508, 260800 or 2708000000 and they all mean +8. The value is in Little Endian layout. – aja Apr 22 '23 at 21:23
  • Still no luck when I tried '0x26 0xFF 0x00' instead of '0x25 0xff', normal keys still work (like keypad 2), but extended don't. Can it have to do with language settings? – Eva4684 Apr 24 '23 at 10:17
  • 0x67 103d Keypad '=', also doesn't work, there is no tick for it in PC-AT in spec, does that matter? https://usb.org/sites/default/files/hut1_4.pdf – Eva4684 Apr 24 '23 at 10:42
  • One last thing to try is to change your interface descriptor to indicate that your device is not a Boot keyboard. I have had some success on PIC hardware by specifying bInterfaceClass=3, bInnterfaceSubclass=0,bInterfaceProtocol=0 rather than 3,1,1 for a Boot keyboard. I think I had Keypad keys working but that was many years ago and the supported keys seemed to vary by host operating system (Windows vs Linux in my case). – aja Apr 24 '23 at 12:00
  • Good idea, I tried 3,0,0 and 3,0,1 but didn't make a difference, QMK keyboard uses 3,0,1. I will ask around QMK/ZMK devs, because those seem to allow keypad codes. – Eva4684 Apr 24 '23 at 16:50

0 Answers0