Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: chrome/browser/extensions/api/braille_display_private/brlapi_keycode_map.cc

Issue 2463983002: Implement support for chorded braille commands (Closed)
Patch Set: Add more commands. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/extensions/api/braille_display_private/brlapi_keycode_m ap.h" 5 #include "chrome/browser/extensions/api/braille_display_private/brlapi_keycode_m ap.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversion_utils.h" 10 #include "base/strings/utf_string_conversion_utils.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 case BRLAPI_KEY_CMD_BOT: 135 case BRLAPI_KEY_CMD_BOT:
136 event->command = KEY_COMMAND_BOTTOM; 136 event->command = KEY_COMMAND_BOTTOM;
137 break; 137 break;
138 default: 138 default:
139 switch (code & BRLAPI_KEY_CMD_BLK_MASK) { 139 switch (code & BRLAPI_KEY_CMD_BLK_MASK) {
140 case BRLAPI_KEY_CMD_ROUTE: 140 case BRLAPI_KEY_CMD_ROUTE:
141 event->command = KEY_COMMAND_ROUTING; 141 event->command = KEY_COMMAND_ROUTING;
142 event->display_position.reset(new int(argument)); 142 event->display_position.reset(new int(argument));
143 break; 143 break;
144 case BRLAPI_KEY_CMD_PASSDOTS: 144 case BRLAPI_KEY_CMD_PASSDOTS:
145 event->command = KEY_COMMAND_DOTS; 145 unsigned int dots = argument & kAllDots;
146 event->braille_dots.reset(new int(argument & kAllDots)); 146 event->braille_dots.reset(new int(dots));
147 if (dots && argument & BRLAPI_DOTC)
dmazzoni 2016/11/01 16:22:37 nit: I prefer parens around the bitwise and clause
David Tseng 2016/11/01 20:11:59 Done.
148 event->command = KEY_COMMAND_CHORD;
149 else
150 event->command = KEY_COMMAND_DOTS;
dmazzoni 2016/11/01 16:23:04 nit: indentation of this line and two lines previo
David Tseng 2016/11/01 20:11:59 Done.
147 MapModifierFlags(code, event); 151 MapModifierFlags(code, event);
148 break; 152 break;
149 } 153 }
150 } 154 }
151 } 155 }
152 156
153 } // namespace 157 } // namespace
154 158
155 std::unique_ptr<KeyEvent> BrlapiKeyCodeToEvent(brlapi_keyCode_t code) { 159 std::unique_ptr<KeyEvent> BrlapiKeyCodeToEvent(brlapi_keyCode_t code) {
156 std::unique_ptr<KeyEvent> result(new KeyEvent); 160 std::unique_ptr<KeyEvent> result(new KeyEvent);
157 result->command = KEY_COMMAND_NONE; 161 result->command = KEY_COMMAND_NONE;
158 switch (code & BRLAPI_KEY_TYPE_MASK) { 162 switch (code & BRLAPI_KEY_TYPE_MASK) {
159 case BRLAPI_KEY_TYPE_SYM: 163 case BRLAPI_KEY_TYPE_SYM:
160 MapKeySym(code, result.get()); 164 MapKeySym(code, result.get());
161 break; 165 break;
162 case BRLAPI_KEY_TYPE_CMD: 166 case BRLAPI_KEY_TYPE_CMD:
163 MapCommand(code, result.get()); 167 MapCommand(code, result.get());
164 break; 168 break;
165 } 169 }
166 if (result->command == KEY_COMMAND_NONE) 170 if (result->command == KEY_COMMAND_NONE)
167 result.reset(); 171 result.reset();
168 return result; 172 return result;
169 } 173 }
170 174
171 } // namespace braille_display_private 175 } // namespace braille_display_private
172 } // namespace api 176 } // namespace api
173 } // namespace extensions 177 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698