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

Side by Side Diff: ui/ozone/platform/caca/caca_event_source.cc

Issue 1878083002: Implement IsAsciiUpper and IsAsciiLower in base/strings/string_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync Created 4 years, 8 months 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 "ui/ozone/platform/caca/caca_event_source.h" 5 #include "ui/ozone/platform/caca/caca_event_source.h"
6 6
7 #include <caca.h> 7 #include <caca.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string_util.h"
12 #include "ui/events/event.h" 13 #include "ui/events/event.h"
13 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
14 #include "ui/events/keycodes/keyboard_codes.h" 15 #include "ui/events/keycodes/keyboard_codes.h"
15 #include "ui/ozone/platform/caca/caca_window.h" 16 #include "ui/ozone/platform/caca/caca_window.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 namespace { 20 namespace {
20 21
21 ui::KeyboardCode GetKeyboardCode(const caca_event_t& event) { 22 ui::KeyboardCode GetKeyboardCode(const caca_event_t& event) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 ui::VKEY_F6, 68 ui::VKEY_F6,
68 ui::VKEY_F7, 69 ui::VKEY_F7,
69 ui::VKEY_F8, 70 ui::VKEY_F8,
70 ui::VKEY_F9, 71 ui::VKEY_F9,
71 ui::VKEY_F10, 72 ui::VKEY_F10,
72 ui::VKEY_F11, 73 ui::VKEY_F11,
73 ui::VKEY_F12, 74 ui::VKEY_F12,
74 }; 75 };
75 76
76 int key_code = caca_get_event_key_ch(&event); 77 int key_code = caca_get_event_key_ch(&event);
77 if (key_code >= 'a' && key_code <= 'z') 78 if (base::IsAsciiLower(key_code))
78 return static_cast<ui::KeyboardCode>(key_code - ('a' - 'A')); 79 return static_cast<ui::KeyboardCode>(key_code - ('a' - 'A'));
79 if (key_code >= '0' && key_code <= 'Z') 80 if (key_code >= '0' && key_code <= 'Z')
80 return static_cast<ui::KeyboardCode>(key_code); 81 return static_cast<ui::KeyboardCode>(key_code);
81 if (static_cast<unsigned int>(key_code) < arraysize(kCacaKeyMap)) 82 if (static_cast<unsigned int>(key_code) < arraysize(kCacaKeyMap))
82 return kCacaKeyMap[key_code]; 83 return kCacaKeyMap[key_code];
83 84
84 return ui::VKEY_UNKNOWN; 85 return ui::VKEY_UNKNOWN;
85 } 86 }
86 87
87 int ModifierFromKey(const caca_event_t& event) { 88 int ModifierFromKey(const caca_event_t& event) {
88 int key_code = caca_get_event_key_ch(&event); 89 int key_code = caca_get_event_key_ch(&event);
89 if (key_code >= 'A' && key_code <= 'Z') 90 if (base::IsAsciiUpper(key_code))
90 return ui::EF_SHIFT_DOWN; 91 return ui::EF_SHIFT_DOWN;
91 if ((key_code >= CACA_KEY_CTRL_A && key_code <= CACA_KEY_CTRL_G) || 92 if ((key_code >= CACA_KEY_CTRL_A && key_code <= CACA_KEY_CTRL_G) ||
92 (key_code >= CACA_KEY_CTRL_J && key_code <= CACA_KEY_CTRL_L) || 93 (key_code >= CACA_KEY_CTRL_J && key_code <= CACA_KEY_CTRL_L) ||
93 (key_code >= CACA_KEY_CTRL_N && key_code <= CACA_KEY_CTRL_R) || 94 (key_code >= CACA_KEY_CTRL_N && key_code <= CACA_KEY_CTRL_R) ||
94 (key_code >= CACA_KEY_CTRL_T && key_code <= CACA_KEY_CTRL_Z)) 95 (key_code >= CACA_KEY_CTRL_T && key_code <= CACA_KEY_CTRL_Z))
95 return ui::EF_CONTROL_DOWN; 96 return ui::EF_CONTROL_DOWN;
96 97
97 return ui::EF_NONE; 98 return ui::EF_NONE;
98 } 99 }
99 100
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 window->OnCacaEvent(&mouse_event); 225 window->OnCacaEvent(&mouse_event);
225 break; 226 break;
226 } 227 }
227 default: 228 default:
228 NOTIMPLEMENTED(); 229 NOTIMPLEMENTED();
229 break; 230 break;
230 } 231 }
231 } 232 }
232 233
233 } // namespace ui 234 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698