最終更新:2017-07-13 (木) 18:18:50 (613d)  

HID/キーボード はてなブックマークを見る
Top / HID / キーボード

Device Class Definition for Human Interface Devicesの例

ブートプロトコル

  • Usage Page (Generic Desktop),
    	Usage (Keyboard),
    	Collection (Application),
    	Report Size (1),
    	Report Count (8),
    	Usage Page (Key Codes),
    	Usage Minimum (224),
    	Usage Maximum (231),
    	Logical Minimum (0),
    	Logical Maximum (1),
    	Input (Data, Variable, Absolute), ;Modifier byte
    	Report Count (1),
    	Report Size (8),
    	Input (Constant), ;Reserved byte
    	Report Count (5),
    	Report Size (1),
    	Usage Page (LEDs),
    	Usage Minimum (1),
    	Usage Maximum (5),
    	Output (Data, Variable, Absolute), ;LED report
    	Report Count (1),
    	Report Size (3),
    	Output (Constant), ;LED report padding
    	Report Count (6),
    	Report Size (8),
    	Logical Minimum (0),
    	Logical Maximum(255),
    	Usage Page (Key Codes),
    	Usage Minimum (0),
    	Usage Maximum (255),
    	Input (Data, Array),
    End Collection

キーボードのレポート

  • Input
    バイトメモ
    0Modifier keys
    1Reserved
    2Keycode 1
    3Keycode 2
    4Keycode 3
    5Keycode 4
    6Keycode 5
    7Keycode 6
  • Output
    バイトメモ
    0NUM LOCK
    1CAPS LOCK
    2SCROLL LOCK
    3COMPOSE
    4KANA
    5 to 7CONSTANT

Modifier

  • Since only one array element can be reported in each array field, modifier keys
    should be reported as bitmap data (a group of 1-bit variable fields). For example,
    keys such as CTRL, SHIFT, ALT, and GUI keys make up the 8 bit modifier byte in a
    standard keyboard report. Although these usage codes are defined in the Usage
    Table as E0–E7, the usage is not sent as array data. The modifier byte is defined
    as follows.
    0LEFT CTRL
    1LEFT SHIFT
    2LEFT ALT
    3LEFT GUI
    4RIGHT CTRL
    5RIGHT SHIFT
    6RIGHT ALT
    7RIGHT GUI

55Y9024 (ThinkPad USB トラックポイントキーボード)

  • 05 01             Usage Page (Generic Desktop Controls)
    09 06             Usage (Keyboard)
    A1 01             Collection (Application)
    05 07               Usage Page (Keyboard)
    19 E0               Usage Minimum (0xE0)
    29 E7               Usage Maximum (0xE7)
    15 00               Logical Minimum (0)
    25 01               Logical Maximum (1)
    95 08               Report Count (8)
    75 01               Report Size (1)
    81 02               Input (Var)
    95 08               Report Count (8)
    75 01               Report Size (1)
    81 01               Input (Const)
    05 08               Usage Page (LEDs)
    19 01               Usage Minimum (1)
    29 03               Usage Maximum (3)
    95 03               Report Count (3)
    75 01               Report Size (1)
    91 02               Output (Var)
    95 01               Report Count (1)
    75 05               Report Size (5)
    91 01               Output (Const)
    05 07               Usage Page (Keyboard)
    19 00               Usage Minimum (0)
    2A FF 00            Usage Maximum (255)
    15 00               Logical Minimum (0)
    26 FF 00            Logical Maximum (255)
    95 06               Report Count (6)
    75 08               Report Size (8)
    81 00               Input ()
    C0                End Collection

ThinkPad Compact USB Keyboard with TrackPoint

  • 0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
    0x09, 0x06,        // Usage (Keyboard)
    0xA1, 0x01,        // Collection (Application)
    0x05, 0x07,        //   Usage Page (Kbrd/Keypad)
    0x19, 0xE0,        //   Usage Minimum (0xE0)
    0x29, 0xE7,        //   Usage Maximum (0xE7)
    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,No Wrap,Linear,Preferred State,No Null Position)
    0x95, 0x01,        //   Report Count (1)
    0x75, 0x08,        //   Report Size (8)
    0x81, 0x01,        //   Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
    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,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
    0x95, 0x01,        //   Report Count (1)
    0x75, 0x03,        //   Report Size (3)
    0x91, 0x01,        //   Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
    0x95, 0x06,        //   Report Count (6)
    0x75, 0x08,        //   Report Size (8)
    0x16, 0x00, 0x00,  //   Logical Minimum (0)
    0x26, 0xAF, 0x00,  //   Logical Maximum (175)
    0x05, 0x07,        //   Usage Page (Kbrd/Keypad)
    0x1A, 0x00, 0x00,  //   Usage Minimum (0x00)
    0x2A, 0xAF, 0x00,  //   Usage Maximum (0xAF)
    0x81, 0x00,        //   Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
    0x05, 0x0C,        //   Usage Page (Consumer)
    0x09, 0x00,        //   Usage (Unassigned)
    0x15, 0x80,        //   Logical Minimum (-128)
    0x25, 0x7F,        //   Logical Maximum (127)
    0x75, 0x08,        //   Report Size (8)
    0x95, 0x08,        //   Report Count (8)
    0xB1, 0x02,        //   Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
    0xC0,              // End Collection
    
    // 81 bytes

関連