IndexedDB: Protect against use-after-free in ChainedBlobWriter.
[chromium-blink-merge.git] / tools / usb_gadget / hid_constants.py
blobce8249c8d04248258412eff6543d9c160460d5cd
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """HID constant definitions.
6 """
8 import usb_constants
11 class DescriptorType(object):
12 """Class descriptors.
14 See Device Class Definition for Human Interface Devices (HID) Version 1.11
15 section 7.1.
16 """
17 HID = usb_constants.Type.CLASS | 0x01
18 REPORT = usb_constants.Type.CLASS | 0x02
19 PHYSICAL = usb_constants.Type.CLASS | 0x03
22 class Scope(object):
23 """Item scope.
25 See Device Class Definition for Human Interface Devices (HID) Version 1.11
26 section 6.2.2.2.
27 """
28 MAIN = 0
29 GLOBAL = 1
30 LOCAL = 2
33 class CollectionType(object):
34 """Collection types.
36 See Device Class Definition for Human Interface Devices (HID) Version 1.11
37 section 6.2.2.4.
38 """
39 PHYSICAL = 0
40 APPLICATION = 1
41 LOGICAL = 2
42 REPORT = 3
43 NAMED_ARRAY = 4
44 USAGE_SWITCH = 5
45 USAGE_MODIFIER = 6
48 class Request(object):
49 """Class specific requests.
51 See Device Class Definition for Human Interface Devices (HID) Version 1.11
52 section 7.2.
53 """
54 GET_REPORT = 1
55 GET_IDLE = 2
56 GET_PROTOCOL = 3
57 SET_REPORT = 9
58 SET_IDLE = 0x0A
59 SET_PROTOCOL = 0x0B
62 class ReportType(object):
63 """Report types.
65 See Device Class Definition for Human Interface Devices (HID) Version 1.11
66 section 7.2.1.
67 """
68 INPUT = 1
69 OUTPUT = 2
70 FEATURE = 3
73 class ModifierKey(object):
74 """Keyboard modifier key report values.
76 See Device Class Definition for Human Interface Devices (HID) Version 1.11
77 section 8.3 and HID Usage Tables Version 1.1 Table 12.
78 """
79 L_CTRL = 0x01
80 L_SHIFT = 0x02
81 L_ALT = 0x04
82 L_GUI = 0x08
83 R_CTRL = 0x10
84 R_SHIFT = 0x20
85 R_ALT = 0x40
86 R_GUI = 0x80
89 class LED(object):
90 """Keyboard LED report values.
92 See Device Class Definition for Human Interface Devices (HID) Version 1.11
93 section B.1 and HID Usage Tables Version 1.1 Table 13.
94 """
95 NUM_LOCK = 0x01
96 CAPS_LOCK = 0x02
97 SCROLL_LOCK = 0x04
98 COMPOSE = 0x08
99 KANA = 0x10
102 class Mouse(object):
103 """Mouse button report values.
105 See Device Class Definition for Human Interface Devices (HID) Version 1.11
106 section B.2.
108 BUTTON_1 = 0x01
109 BUTTON_2 = 0x02
110 BUTTON_3 = 0x04
113 KEY_CODES = {}
114 for key, code in zip(xrange(ord('a'), ord('z') + 1), xrange(4, 30)):
115 KEY_CODES[chr(key)] = code
116 for key, code in zip(xrange(ord('1'), ord('9') + 1), xrange(30, 39)):
117 KEY_CODES[chr(key)] = code
118 for key, code in zip(['Enter', 'Esc', 'Backspace', 'Tab', ' '], xrange(40, 45)):
119 KEY_CODES[key] = code
120 for key, code in zip('-=[]\\', xrange(45, 50)):
121 KEY_CODES[key] = code
122 for key, code in zip(';\'`,./', xrange(51, 57)):
123 KEY_CODES[key] = code
124 for key, code in zip(
125 ['CapsLock', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10',
126 'F11', 'F12', 'PrintScreen', 'ScrollLock', 'Pause', 'Insert', 'Home',
127 'PageUp', 'PageDown', 'Delete', 'End', 'PageDown', 'RightArrow',
128 'LeftArrow', 'DownArrow', 'UpArrow', 'NumLock'],
129 xrange(57, 84)):
130 KEY_CODES[key] = code
132 SHIFT_KEY_CODES = {}
133 for key, code in zip(xrange(ord('A'), ord('Z') + 1), xrange(4, 30)):
134 SHIFT_KEY_CODES[chr(key)] = code
135 for key, code in zip('!@#$%^&*()', xrange(30, 40)):
136 SHIFT_KEY_CODES[key] = code
137 for key, code in zip('_+{}|', xrange(45, 50)):
138 SHIFT_KEY_CODES[key] = code
139 for key, code in zip(':"~<>?', xrange(51, 57)):
140 SHIFT_KEY_CODES[key] = code