OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Braille command definitions. | 6 * @fileoverview Braille command definitions. |
7 * These types are adapted from Chrome's private braille API. | 7 * These types are adapted from Chrome's private braille API. |
8 * They can be found in the Chrome source repo at: | 8 * They can be found in the Chrome source repo at: |
9 * src/chrome/common/extensions/api/braille_display_private.idl | 9 * src/chrome/common/extensions/api/braille_display_private.idl |
10 * We define them here since they don't actually exist as bindings under | 10 * We define them here since they don't actually exist as bindings under |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 var SPECIAL_CODES = { | 87 var SPECIAL_CODES = { |
88 'Backspace': 0x08, | 88 'Backspace': 0x08, |
89 'Tab': 0x09, | 89 'Tab': 0x09, |
90 'Enter': 0x0A | 90 'Enter': 0x0A |
91 }; | 91 }; |
92 // Note, the Chrome virtual keyboard falls back on the first character of the | 92 // Note, the Chrome virtual keyboard falls back on the first character of the |
93 // key code if the key is not one of the above. Do the same here. | 93 // key code if the key is not one of the above. Do the same here. |
94 return SPECIAL_CODES[keyCode] || keyCode.charCodeAt(0); | 94 return SPECIAL_CODES[keyCode] || keyCode.charCodeAt(0); |
95 }; | 95 }; |
96 | 96 |
97 /* | |
98 * Note: Some of the below mappings contain raw braille dot | |
99 * patterns. These are written out in binary form to make clear | |
100 * exactly what dots in the braille cell make up the pattern. The | |
101 * braille cell is arranged in a 2 by 4 dot grid with each dot | |
102 * assigned a number from 1-8. | |
103 * 1 4 | |
104 * 2 5 | |
105 * 3 6 | |
106 * 7 8 | |
107 * | |
108 * In binary form, the dot number minus 1 maps to the bit position | |
109 * (from right to left). | |
110 * For example, dots 1-6-7 would be | |
111 * 0b1100001 | |
112 */ | |
113 | |
114 /** | |
115 * Maps a braille pattern to a standard key code. | |
116 * @type {!Object<number, string>} | |
117 */ | |
118 cvox.BrailleKeyEvent.brailleDotsToStandardKeyCode = { | |
119 0b1: 'A', | |
120 0b11: 'B', | |
121 0b1001: 'C', | |
122 0b11001: 'D', | |
123 0b10001: 'E', | |
124 0b1011: 'F', | |
125 0b11011: 'G', | |
126 0b10011: 'H', | |
127 0b1010: 'I', | |
dmazzoni
2017/04/17 04:53:25
nit: indent
David Tseng
2017/04/17 16:10:51
Done.
| |
128 0b11010: 'J', | |
129 0b101: 'K', | |
130 0b111: 'L', | |
131 0b1101: 'M', | |
132 0b11101: 'N', | |
133 0b10101: 'O', | |
134 0b1111: 'P', | |
135 0b11111: 'Q', | |
136 0b10111: 'R', | |
137 0b1110: 'S', | |
138 0b11110: 'T', | |
139 0b100101: 'U', | |
140 0b100111: 'V', | |
141 0b111010: 'W', | |
142 0b101101: 'X', | |
143 0b111101: 'Y', | |
dmazzoni
2017/04/17 04:53:25
nit: indent
David Tseng
2017/04/17 16:10:51
Done.
| |
144 0b110101: 'Z', | |
145 0b110100: '0', | |
146 0b10: '1', | |
147 0b110: '2', | |
148 0b10010: '3', | |
149 0b110010: '4', | |
150 0b100010: '5', | |
151 0b10110: '6', | |
152 0b110110: '7', | |
153 0b100110: '8', | |
154 0b10100: '9' | |
155 }; | |
156 | |
157 /** | |
158 * Maps a braille chord pattern to a standard key code. | |
159 * @type {!Object<number, string>} | |
160 */ | |
161 cvox.BrailleKeyEvent.brailleChordsToStandardKeyCode = { | |
162 0b1000000: 'Backspace', | |
163 0b10100: 'Tab', | |
164 0b110101: 'Escape', | |
165 0b101000: 'Enter' | |
166 }; | |
167 | |
168 /** | |
169 * Maps a braille dot chord pattern to standard key modifiers. | |
170 */ | |
171 cvox.BrailleKeyEvent.brailleDotsToModifiers = { | |
172 0b010010: {ctrlKey: true}, | |
173 0b100100: {altKey: true}, | |
174 0b1000100: {shiftKey: true}, | |
175 0b1010010: {ctrlKey: true, shiftKey: true}, | |
dmazzoni
2017/04/17 04:53:25
Can you sequence ctrl and shift instead? I wonder
David Tseng
2017/04/17 16:10:51
I do think 2-5, 3-6 are pretty nice chords and sho
| |
176 0b1100100: {altKey: true, shiftKey: true} | |
177 }; | |
178 | |
97 | 179 |
98 /** | 180 /** |
99 * Map from DOM level 4 key codes to legacy numeric key codes. | 181 * Map from DOM level 4 key codes to legacy numeric key codes. |
100 * @private {Object<number>} | 182 * @private {Object<number>} |
101 */ | 183 */ |
102 cvox.BrailleKeyEvent.legacyKeyCodeMap_ = { | 184 cvox.BrailleKeyEvent.legacyKeyCodeMap_ = { |
103 'Backspace': 8, | 185 'Backspace': 8, |
104 'Tab': 9, | 186 'Tab': 9, |
105 'Enter': 13, | 187 'Enter': 13, |
106 'Escape': 27, | 188 'Escape': 27, |
107 'Home': 36, | 189 'Home': 36, |
108 'ArrowLeft': 37, | 190 'ArrowLeft': 37, |
109 'ArrowUp': 38, | 191 'ArrowUp': 38, |
110 'ArrowRight': 39, | 192 'ArrowRight': 39, |
111 'ArrowDown': 40, | 193 'ArrowDown': 40, |
112 'PageUp': 33, | 194 'PageUp': 33, |
113 'PageDown': 34, | 195 'PageDown': 34, |
114 'End': 35, | 196 'End': 35, |
115 'Insert': 45, | 197 'Insert': 45, |
116 'Delete': 46 | 198 'Delete': 46, |
199 'AudioVolumeDown': 174, | |
200 'AudioVolumeUp': 175 | |
117 }; | 201 }; |
118 | 202 |
119 // Add the F1 to F12 keys. | |
120 (function() { | 203 (function() { |
204 // Add 0-9. | |
205 for (var i = '0'.charCodeAt(0); i < '9'.charCodeAt(0); ++i) { | |
206 cvox.BrailleKeyEvent.legacyKeyCodeMap_[String.fromCharCode(i)] = i; | |
207 } | |
208 | |
209 // Add A-Z. | |
210 for (var i = 'A'.charCodeAt(0); i < 'Z'.charCodeAt(0); ++i) { | |
211 cvox.BrailleKeyEvent.legacyKeyCodeMap_[String.fromCharCode(i)] = i; | |
212 } | |
213 | |
214 // Add the F1 to F12 keys. | |
121 for (var i = 0; i < 12; ++i) { | 215 for (var i = 0; i < 12; ++i) { |
122 cvox.BrailleKeyEvent.legacyKeyCodeMap_['F' + (i + 1)] = 112 + i; | 216 cvox.BrailleKeyEvent.legacyKeyCodeMap_['F' + (i + 1)] = 112 + i; |
123 } | 217 } |
124 })(); | 218 })(); |
125 | 219 |
126 | 220 |
127 /** | 221 /** |
128 * The state of a braille display as represented in the | 222 * The state of a braille display as represented in the |
129 * chrome.brailleDisplayPrivate API. | 223 * chrome.brailleDisplayPrivate API. |
130 * @typedef {{available: boolean, textRowCount: number, | 224 * @typedef {{available: boolean, textRowCount: number, |
131 * textColumnCount: number}} | 225 * textColumnCount: number}} |
132 */ | 226 */ |
133 cvox.BrailleDisplayState; | 227 cvox.BrailleDisplayState; |
OLD | NEW |