Refactor `qmk compile-json` to `qmk compile` (#6592)
[jackhill/qmk/firmware.git] / docs / usb_nkro.txt
CommitLineData
995c3141
JH
1USB NKRO MEMO
2=============
32010/12/09
4
5
6References
7----------
8USB - boot mode, NKRO, compatibility, etc...
9 http://geekhack.org/showthread.php?t=13162
10NKey Rollover - Overview, Testing Methodology, and Results
11 http://geekhack.org/showwiki.php?title=NKey+Rollover+-+Overview+Testing+Methodology+and+Results
12dfj's NKRO(2010/06)
13 http://geekhack.org/showpost.php?p=191195&postcount=251
14 http://geekhack.org/showthread.php?p=204389#post204389
15
16
17Terminology
18---------
19NKRO
20ghost
21matrix
22mechanical with diodes
23membrane
24
25
26OS Support Status
27-----------------
28USB NKRO is possible *without* a custom driver.
29At least following OS's supports.
30 Windows7 64bit
31 WindowsXP
32 Windows2000 SP4
33 Ubuntu10.4(Linux 2.6)
34 MacOSX(To be tested)
35
36
37Custom Driver for USB NKRO
38--------------------------
39NOT NEEDED
40at least when using following report formats on Windows, Linux or MacOSX.
41
42
43USB NKRO methods
44----------------
451. Virtual keyboards
46 Keyboard can increase its KRO by using virtual keyboards with Standard or Extended report.
47 If the keyboard has 2 virtual keyboard with Standard report(6KRO), it gets 12KRO.
48 Using this method means the keyboard is a composite device.
49
502. Extended report
51 It needs large report size for this method to achieve NKRO.
52 If a keyboard has 101keys, it needs 103byte report. It seems to be inefficient.
53
543. Bitmap report
55 If the keyboard has less than 128keys, 16byte report will be enough for NKRO.
56 The 16byte report seems to be reasonable cost to get NKRO.
57
58
59Report Format
60-------------
61Other report formats than followings are possible, though these format are typical one.
62
631. Standard 8bytes
64 modifiers(bitmap) 1byte
65 reserved 1byte(not used)
66 keys(array) 1byte*6
67Standard report can send 6keys plus 8modifiers simultaneously.
68Standard report is used by most keyboards in the marketplace.
69Standard report is identical to boot protocol report.
70Standard report is hard to suffer from compatibility problems.
71
722. Extended standard 16,32,64bytes
73 modifiers(bitmap) 1byte
74 reserved 1byte(not used)
75 keys(array) 1byte*(14,32,62)
76Extended report can send N-keys by using N+2bytes.
77Extended report is expected to be compatible with boot protocol.
78
793. Bitmap 16,32,64bytes
80 keys(bitmap) (16,32)bytes
81Bitmap report can send at most 128keys by 16bytes and 256keys by 32bytes.
82Bitmap report can achieve USB NKRO efficiently in terms of report size.
83Bitmap report needs a deliberation for boot protocol implementation.
84Bitmap report descriptor sample:
85 0x05, 0x01, // Usage Page (Generic Desktop),
86 0x09, 0x06, // Usage (Keyboard),
87 0xA1, 0x01, // Collection (Application),
88 // bitmap of modifiers
89 0x75, 0x01, // Report Size (1),
90 0x95, 0x08, // Report Count (8),
91 0x05, 0x07, // Usage Page (Key Codes),
92 0x19, 0xE0, // Usage Minimum (224),
93 0x29, 0xE7, // Usage Maximum (231),
94 0x15, 0x00, // Logical Minimum (0),
95 0x25, 0x01, // Logical Maximum (1),
96 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte
97 // LED output report
98 0x95, 0x05, // Report Count (5),
99 0x75, 0x01, // Report Size (1),
100 0x05, 0x08, // Usage Page (LEDs),
101 0x19, 0x01, // Usage Minimum (1),
102 0x29, 0x05, // Usage Maximum (5),
103 0x91, 0x02, // Output (Data, Variable, Absolute),
104 0x95, 0x01, // Report Count (1),
105 0x75, 0x03, // Report Size (3),
106 0x91, 0x03, // Output (Constant),
107 // bitmap of keys
108 0x95, (REPORT_BYTES-1)*8, // Report Count (),
109 0x75, 0x01, // Report Size (1),
110 0x15, 0x00, // Logical Minimum (0),
111 0x25, 0x01, // Logical Maximum(1),
112 0x05, 0x07, // Usage Page (Key Codes),
113 0x19, 0x00, // Usage Minimum (0),
114 0x29, (REPORT_BYTES-1)*8-1, // Usage Maximum (),
115 0x81, 0x02, // Input (Data, Variable, Absolute),
116 0xc0 // End Collection
117where REPORT_BYTES is a report size in bytes.
118
119
120Considerations
121--------------
122Compatibility
123 boot protocol
124 minor/old system
125 Some BIOS doesn't send SET_PROTOCOL request, a keyboard can't switch to boot protocol mode.
126 This may cause a problem on a keyboard which uses other report than Standard.
127Reactivity
128 USB polling time
129 OS/Driver processing time
130
131
132Windows Problem
133---------------
1341. Windows accepts only 6keys in case of Standard report.
135 It should be able to send 6keys plus 8modifiers.
1362. Windows accepts only 10keys in case of 16bytes Extended report.
137 It should be able to send 14keys plus 8modifiers.
1383. Windows accepts only 18keys in case of 32bytes Extended report.
139 It should be able to send 30keys plus 8modifiers.
140If keys are pressed in excess of the number, wrong keys are registered on Windows.
141
142This problem will be reportedly fixed soon.(2010/12/05)
143 http://forums.anandtech.com/showpost.php?p=30873364&postcount=17
144
145
146Tools for testing NKRO
147----------------------
148Browser App:
149http://www.microsoft.com/appliedsciences/content/projects/KeyboardGhostingDemo.aspx
150http://random.xem.us/rollover.html
151
152Windows:
153AquaKeyTest.exe http://geekhack.org/showthread.php?t=6643
154
155Linux:
156xkeycaps
157xev
158showkeys
159
160EOF