Skip to content

Instantly share code, notes, and snippets.

@rixtox
Last active July 5, 2022 10:46
Show Gist options
  • Save rixtox/c0ee9255d533aa00c70eb0f2be810d3c to your computer and use it in GitHub Desktop.
Save rixtox/c0ee9255d533aa00c70eb0f2be810d3c to your computer and use it in GitHub Desktop.
// USB Vendor ID: 0x05AC
// USB Product ID: 0x0251
/* The upper label indicates the key's function.
* The lower label indicates the USB/HID Keyboard report value.
* The keyboard report (endpoint 0x81) has the following data structure:
* ```
* struct kdb_report {
* uint8_t modifier;
* uint8_t reserved;
* uint8_t keys[5];
* uint8_t fn;
* }
* ```
* There's another endpoint 0x82 used for the media keys. It has only one byte of data:
* ```
* struct media_report {
* uint8_t mask;
* }
* ```
* Thus for normal keys the `HH` hex lower lable represents the `kdb_report.keys[x]` value.
* For modifier keys the `_HH` hex lower label represents the `kbd_report.modifier` value.
* For fn key, the `.HH` hex lower label represents the `kbd_report.fn` value.
* For the eject key, the `^HH` hex lower label represents the `media_report.mask` value.
*/
===== ==== ==== ==== ==== ==== ==== ==== ==== ==== ===== ===== ===== ===== ======= ====== ======= ===== ===== ===== =====
| ESC | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | EJT | | F13 | F14 | F15 | | F16 | F17 | F18 | F19 |
| 29 | 3a | 3b | 3c | 3d | 3e | 3f | 40 | 41 | 42 | 43 | 44 | 45 | ^08 | | 68 | 69 | 6a | | 6b | 6c | 6d | 6e |
===== ==== ==== ==== ==== ==== ==== ==== ==== ==== ===== ===== ===== ===== ======= ====== ======= ===== ===== ===== =====
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | ^ | ¥ | BSP | | fn | HOME | PG_UP | | CLR | = | / | * |
| 1e | 1f | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 2d | 2e | 89 | 2a | | .01 | 4a | 4b | | 53 | 67 | 54 | 55 |
======== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ===== ======= ====== ======= ===== ===== ===== =====
| TAB | q | w | e | r | t | y | u | i | o | p | @ | [ | | | DEL | END | PG_DW | | 7 | 8 | 9 | - |
| 2b | 14 | 1a | 08 | 15 | 17 | 1c | 18 | 0c | 12 | 13 | 2f | 30 | | | 4c | 4d | 4e | | 5f | 60 | 61 | 56 |
===== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== === L_ RET | ======= ====== ======= ===== ===== ===== =====
| L_CTL | a | s | d | f | g | h | j | k | l | ; | : | ] | 28 | | 4 | 5 | 6 | + |
| _01 | 04 | 16 | 07 | 09 | 0a | 0b | 0d | 0e | 0f | 33 | 34 | 32 | | | 5c | 5d | 5e | 57 |
======= ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====== ====== ===== ===== ===== =====
| L_SHIFT | z | x | c | v | b | n | m | , | . | / | _ | R_SHIFT | | UP | | 1 | 2 | 3 | |
| _02 | 1d | 1b | 06 | 19 | 05 | 11 | 10 | 36 | 37 | 38 | 87 | _20 | | 52 | | 59 | 5a | 5b | ENT |
========= ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ========= ======= ====== ======= ===== ===== ==== | |
| L_ALT | L_CMD | 英数 | SPC | かな | R_CMD | R_ALT | CAPS_LCK | | LEFT | DOWN | RIGHT | | 0 | , | . | 58 |
| _04 | _08 | 91 | 2c | 90 | _80 | _40 | 39 | | 50 | 51 | 4f | | 62 | 85 | 63 | |
========= ======= ====== =============== ====== ======= ======= ========== ======= ====== ======= ===== ===== ===== =====
// Not included:
=======
| R_CTL |
| _10 |
=======
/* While pressing L_SHIFT or R_SHIFT,
* pressing other keys would yield the following:
*/
! " # $ % & ' ( ) 0 = ~ |
1e 1f 20 21 22 23 24 25 26 27 2d 2e 89
Q W E R T Y U I O P ` {
14 1a 08 15 17 1c 18 0c 12 13 2f 30
A S D F G H J K L + * }
04 16 07 09 0a 0b 0d 0e 0f 33 34 32
Z X C V B N M < > ? _
1d 1b 06 19 05 11 10 36 37 38 87
/* While pressing L_ALT or R_ALT,
* pressing other keys would yield the following:
*/
¡ ™ £ ¢ ∞ § ¶ • ª º – ≠ \
1e 1f 20 21 22 23 24 25 26 27 2d 2e 89
œ ∑ ´ ® † ¥ ¨ ˆ ø π “ ‘
14 1a 08 15 17 1c 18 0c 12 13 2f 30
å ß ∂ ƒ © ˙ ∆ ˚ ¬ … æ «
04 16 07 09 0a 0b 0d 0e 0f 33 34 32
Ω ≈ ç √ ∫ ˜ µ ≤ ≥ ÷ `
1d 1b 06 19 05 11 10 36 37 38 87
Low Speed device @ 7 (0xFA132000): ............................................. Composite device: "Apple Keyboard"
Port Information: 0x0019
Captive
External Device
Connected
Enabled
Number Of Endpoints (includes EP0):
Total Endpoints for Configuration 1 (current): 3
Device Descriptor
Descriptor Version Number: 0x0200
Device Class: 0 (Composite)
Device Subclass: 0
Device Protocol: 0
Device MaxPacketSize: 8
Device VendorID/ProductID: 0x05AC/0x0251 (Apple Inc.)
Device Version Number: 0x0074
Number of Configurations: 1
Manufacturer String: 1 "Apple Inc."
Product String: 2 "Apple Keyboard"
Serial Number String: 0 (none)
Configuration Descriptor (current config)
Length (and contents): 59
Raw Descriptor (hex) 0000: 09 02 3B 00 02 01 00 A0 0A 09 04 00 00 01 03 01
Raw Descriptor (hex) 0010: 01 00 09 21 11 01 0F 01 22 4B 00 07 05 81 03 08
Raw Descriptor (hex) 0020: 00 0A 09 04 01 00 01 03 00 00 00 09 21 11 01 00
Raw Descriptor (hex) 0030: 01 22 2F 00 07 05 82 03 01 00 0A
Number of Interfaces: 2
Configuration Value: 1
Attributes: 0xA0 (bus-powered, remote wakeup)
MaxPower: 20 mA
Interface #0 - HID/Boot Interface
Alternate Setting 0
Number of Endpoints 1
Interface Class: 3 (HID)
Interface Subclass; 1 (Boot Interface)
Interface Protocol: 1
HID Descriptor
Descriptor Version Number: 0x0111
Country Code: 15
Descriptor Count: 1
Descriptor 1
Type: 0x22 (Report Descriptor)
Length (and contents): 75
Raw Descriptor (hex) 0000: 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
Raw Descriptor (hex) 0010: 75 01 95 08 81 02 95 01 75 08 81 01 05 08 19 01
Raw Descriptor (hex) 0020: 29 05 95 05 75 01 91 02 95 01 75 03 91 01 05 07
Raw Descriptor (hex) 0030: 19 00 2A FF 00 95 05 75 08 15 00 26 FF 00 81 00
Raw Descriptor (hex) 0040: 05 FF 09 03 75 08 95 01 81 02 C0
Parsed Report Descriptor:
Usage Page (Generic Desktop)
Usage (Keyboard)
Collection (Application)
Usage Page (Keyboard/Keypad)
Usage Minimum........... (224)
Usage Maximum........... (231)
Logical Minimum......... (0)
Logical Maximum......... (1)
Report Size............. (1)
Report Count............ (8)
Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Report Count............ (1)
Report Size............. (8)
Input................... (Constant, Array, Absolute)
Usage Page (LED)
Usage Minimum........... (1)
Usage Maximum........... (5)
Report Count............ (5)
Report Size............. (1)
Output.................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
Report Count............ (1)
Report Size............. (3)
Output.................. (Constant, Array, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
Usage Page (Keyboard/Keypad)
Usage Minimum........... (0)
Usage Maximum........... (255)
Report Count............ (5)
Report Size............. (8)
Logical Minimum......... (0)
Logical Maximum......... (255)
Input................... (Data, Array, Absolute)
Usage Page (255)
Usage 3 (0x3)
Report Size............. (8)
Report Count............ (1)
Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
End Collection
Endpoint 0x81 - Interrupt Input
Address: 0x81 (IN)
Attributes: 0x03 (Interrupt)
Max Packet Size: 8
Polling Interval: 10 ms
Interface #1 - HID
Alternate Setting 0
Number of Endpoints 1
Interface Class: 3 (HID)
Interface Subclass; 0
Interface Protocol: 0
HID Descriptor
Descriptor Version Number: 0x0111
Country Code: 0
Descriptor Count: 1
Descriptor 1
Type: 0x22 (Report Descriptor)
Length (and contents): 47
Raw Descriptor (hex) 0000: 05 0C 09 01 A1 01 05 0C 75 01 95 01 15 00 25 01
Raw Descriptor (hex) 0010: 09 CD 81 06 09 B5 81 02 09 B6 81 02 09 B8 81 06
Raw Descriptor (hex) 0020: 09 E2 81 06 09 EA 81 02 09 E9 81 02 81 01 C0
Parsed Report Descriptor:
Usage Page (Consumer)
Usage 1 (0x1)
Collection (Application)
Usage Page (Consumer)
Report Size............. (1)
Report Count............ (1)
Logical Minimum......... (0)
Logical Maximum......... (1)
Usage 205 (0xcd)
Input................... (Data, Variable, Relative, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Usage 181 (0xb5)
Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Usage 182 (0xb6)
Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Usage 184 (0xb8)
Input................... (Data, Variable, Relative, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Usage 226 (0xe2)
Input................... (Data, Variable, Relative, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Usage 234 (0xea)
Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Usage 233 (0xe9)
Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
Input................... (Constant, Array, Absolute)
End Collection
Endpoint 0x82 - Interrupt Input
Address: 0x82 (IN)
Attributes: 0x03 (Interrupt)
Max Packet Size: 1
Polling Interval: 10 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment