| 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 #include "chrome/browser/chromeos/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/sticky_keys/sticky_keys_controller.h" | 9 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const struct ModifierRemapping { | 74 const struct ModifierRemapping { |
| 75 int flag; | 75 int flag; |
| 76 int remap_to; | 76 int remap_to; |
| 77 const char* pref_name; | 77 const char* pref_name; |
| 78 EventRewriter::MutableKeyState result; | 78 EventRewriter::MutableKeyState result; |
| 79 } kModifierRemappings[] = { | 79 } kModifierRemappings[] = { |
| 80 {// kModifierRemappingCtrl references this entry by index. | 80 {// kModifierRemappingCtrl references this entry by index. |
| 81 ui::EF_CONTROL_DOWN, | 81 ui::EF_CONTROL_DOWN, |
| 82 input_method::kControlKey, | 82 input_method::kControlKey, |
| 83 prefs::kLanguageRemapControlKeyTo, | 83 prefs::kLanguageRemapControlKeyTo, |
| 84 {ui::EF_CONTROL_DOWN, | 84 {ui::EF_CONTROL_DOWN, ui::DomCode::CONTROL_LEFT, ui::DomKey::CONTROL, |
| 85 ui::DomCode::CONTROL_LEFT, | |
| 86 ui::DomKey::CONTROL, | |
| 87 0, | |
| 88 ui::VKEY_CONTROL}}, | 85 ui::VKEY_CONTROL}}, |
| 89 {// kModifierRemappingNeoMod3 references this entry by index. | 86 {// kModifierRemappingNeoMod3 references this entry by index. |
| 90 ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, | 87 ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, |
| 91 input_method::kNumModifierKeys, | 88 input_method::kNumModifierKeys, |
| 92 nullptr, | 89 nullptr, |
| 93 {ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, | 90 {ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, ui::DomCode::CAPS_LOCK, |
| 94 ui::DomCode::CAPS_LOCK, | 91 ui::DomKey::ALT_GRAPH, ui::VKEY_ALTGR}}, |
| 95 ui::DomKey::ALT_GRAPH, | |
| 96 0, | |
| 97 ui::VKEY_ALTGR}}, | |
| 98 {ui::EF_COMMAND_DOWN, | 92 {ui::EF_COMMAND_DOWN, |
| 99 input_method::kSearchKey, | 93 input_method::kSearchKey, |
| 100 prefs::kLanguageRemapSearchKeyTo, | 94 prefs::kLanguageRemapSearchKeyTo, |
| 101 {ui::EF_COMMAND_DOWN, | 95 {ui::EF_COMMAND_DOWN, ui::DomCode::OS_LEFT, ui::DomKey::OS, |
| 102 ui::DomCode::OS_LEFT, | |
| 103 ui::DomKey::OS, | |
| 104 0, | |
| 105 ui::VKEY_LWIN}}, | 96 ui::VKEY_LWIN}}, |
| 106 {ui::EF_ALT_DOWN, | 97 {ui::EF_ALT_DOWN, |
| 107 input_method::kAltKey, | 98 input_method::kAltKey, |
| 108 prefs::kLanguageRemapAltKeyTo, | 99 prefs::kLanguageRemapAltKeyTo, |
| 109 {ui::EF_ALT_DOWN, | 100 {ui::EF_ALT_DOWN, ui::DomCode::ALT_LEFT, ui::DomKey::ALT, ui::VKEY_MENU}}, |
| 110 ui::DomCode::ALT_LEFT, | |
| 111 ui::DomKey::ALT, | |
| 112 0, | |
| 113 ui::VKEY_MENU}}, | |
| 114 {ui::EF_NONE, | 101 {ui::EF_NONE, |
| 115 input_method::kVoidKey, | 102 input_method::kVoidKey, |
| 116 nullptr, | 103 nullptr, |
| 117 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::NONE, 0, ui::VKEY_UNKNOWN}}, | 104 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::NONE, ui::VKEY_UNKNOWN}}, |
| 118 {ui::EF_MOD3_DOWN, | 105 {ui::EF_MOD3_DOWN, |
| 119 input_method::kCapsLockKey, | 106 input_method::kCapsLockKey, |
| 120 prefs::kLanguageRemapCapsLockKeyTo, | 107 prefs::kLanguageRemapCapsLockKeyTo, |
| 121 {ui::EF_MOD3_DOWN, | 108 {ui::EF_MOD3_DOWN, ui::DomCode::CAPS_LOCK, ui::DomKey::CAPS_LOCK, |
| 122 ui::DomCode::CAPS_LOCK, | |
| 123 ui::DomKey::CAPS_LOCK, | |
| 124 0, | |
| 125 ui::VKEY_CAPITAL}}, | 109 ui::VKEY_CAPITAL}}, |
| 126 {ui::EF_NONE, | 110 {ui::EF_NONE, |
| 127 input_method::kEscapeKey, | 111 input_method::kEscapeKey, |
| 128 nullptr, | 112 nullptr, |
| 129 {ui::EF_NONE, | 113 {ui::EF_NONE, ui::DomCode::ESCAPE, ui::DomKey::ESCAPE, ui::VKEY_ESCAPE}}, |
| 130 ui::DomCode::ESCAPE, | |
| 131 ui::DomKey::ESCAPE, | |
| 132 0, | |
| 133 ui::VKEY_ESCAPE}}, | |
| 134 {ui::EF_NONE, | 114 {ui::EF_NONE, |
| 135 input_method::kNumModifierKeys, | 115 input_method::kNumModifierKeys, |
| 136 prefs::kLanguageRemapDiamondKeyTo, | 116 prefs::kLanguageRemapDiamondKeyTo, |
| 137 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, 0, ui::VKEY_F15}}}; | 117 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}}; |
| 138 | 118 |
| 139 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0]; | 119 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0]; |
| 140 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1]; | 120 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1]; |
| 141 | 121 |
| 142 // Gets a remapped key for |pref_name| key. For example, to find out which | 122 // Gets a remapped key for |pref_name| key. For example, to find out which |
| 143 // key Search is currently remapped to, call the function with | 123 // key Search is currently remapped to, call the function with |
| 144 // prefs::kLanguageRemapSearchKeyTo. | 124 // prefs::kLanguageRemapSearchKeyTo. |
| 145 const ModifierRemapping* GetRemappedKey(const std::string& pref_name, | 125 const ModifierRemapping* GetRemappedKey(const std::string& pref_name, |
| 146 const PrefService& pref_service) { | 126 const PrefService& pref_service) { |
| 147 if (!pref_service.FindPreference(pref_name.c_str())) | 127 if (!pref_service.FindPreference(pref_name.c_str())) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return ((test.key_code == ui::VKEY_UNKNOWN) || | 223 return ((test.key_code == ui::VKEY_UNKNOWN) || |
| 244 (test.key_code == suspect.key_code)) && | 224 (test.key_code == suspect.key_code)) && |
| 245 ((suspect.flags & test.flags) == test.flags); | 225 ((suspect.flags & test.flags) == test.flags); |
| 246 } | 226 } |
| 247 | 227 |
| 248 void ApplyRemapping(const EventRewriter::MutableKeyState& changes, | 228 void ApplyRemapping(const EventRewriter::MutableKeyState& changes, |
| 249 EventRewriter::MutableKeyState* state) { | 229 EventRewriter::MutableKeyState* state) { |
| 250 state->flags |= changes.flags; | 230 state->flags |= changes.flags; |
| 251 if (changes.code != ui::DomCode::NONE) | 231 if (changes.code != ui::DomCode::NONE) |
| 252 state->code = changes.code; | 232 state->code = changes.code; |
| 253 if (changes.key != ui::DomKey::NONE) { | 233 if (changes.key != ui::DomKey::NONE) |
| 254 state->key = changes.key; | 234 state->key = changes.key; |
| 255 state->character = changes.character; | |
| 256 } | |
| 257 if (changes.key_code != ui::VKEY_UNKNOWN) | 235 if (changes.key_code != ui::VKEY_UNKNOWN) |
| 258 state->key_code = changes.key_code; | 236 state->key_code = changes.key_code; |
| 259 } | 237 } |
| 260 | 238 |
| 261 // Given a set of KeyboardRemapping structs, finds a matching struct | 239 // Given a set of KeyboardRemapping structs, finds a matching struct |
| 262 // if possible, and updates the remapped event values. Returns true if a | 240 // if possible, and updates the remapped event values. Returns true if a |
| 263 // remapping was found and remapped values were updated. | 241 // remapping was found and remapped values were updated. |
| 264 bool RewriteWithKeyboardRemappings( | 242 bool RewriteWithKeyboardRemappings( |
| 265 const KeyboardRemapping* mappings, | 243 const KeyboardRemapping* mappings, |
| 266 size_t num_mappings, | 244 size_t num_mappings, |
| 267 const EventRewriter::MutableKeyState& input_state, | 245 const EventRewriter::MutableKeyState& input_state, |
| 268 EventRewriter::MutableKeyState* remapped_state) { | 246 EventRewriter::MutableKeyState* remapped_state) { |
| 269 for (size_t i = 0; i < num_mappings; ++i) { | 247 for (size_t i = 0; i < num_mappings; ++i) { |
| 270 const KeyboardRemapping& map = mappings[i]; | 248 const KeyboardRemapping& map = mappings[i]; |
| 271 if (MatchKeyboardRemapping(input_state, map.condition)) { | 249 if (MatchKeyboardRemapping(input_state, map.condition)) { |
| 272 remapped_state->flags = (input_state.flags & ~map.condition.flags); | 250 remapped_state->flags = (input_state.flags & ~map.condition.flags); |
| 273 ApplyRemapping(map.result, remapped_state); | 251 ApplyRemapping(map.result, remapped_state); |
| 274 return true; | 252 return true; |
| 275 } | 253 } |
| 276 } | 254 } |
| 277 return false; | 255 return false; |
| 278 } | 256 } |
| 279 | 257 |
| 280 void SetMeaningForLayout(ui::EventType type, | 258 void SetMeaningForLayout(ui::EventType type, |
| 281 EventRewriter::MutableKeyState* state) { | 259 EventRewriter::MutableKeyState* state) { |
| 282 // Currently layout is applied by creating a temporary key event with the | 260 // Currently layout is applied by creating a temporary key event with the |
| 283 // current physical state, and extracting the layout results. | 261 // current physical state, and extracting the layout results. |
| 284 ui::KeyEvent key(type, state->key_code, state->code, state->flags); | 262 ui::KeyEvent key(type, state->key_code, state->code, state->flags); |
| 285 state->key = key.GetDomKey(); | 263 state->key = key.GetDomKey(); |
| 286 state->character = key.GetCharacter(); | |
| 287 } | 264 } |
| 288 | 265 |
| 289 ui::DomCode RelocateModifier(ui::DomCode code, ui::DomKeyLocation location) { | 266 ui::DomCode RelocateModifier(ui::DomCode code, ui::DomKeyLocation location) { |
| 290 bool right = (location == ui::DomKeyLocation::RIGHT); | 267 bool right = (location == ui::DomKeyLocation::RIGHT); |
| 291 switch (code) { | 268 switch (code) { |
| 292 case ui::DomCode::CONTROL_LEFT: | 269 case ui::DomCode::CONTROL_LEFT: |
| 293 case ui::DomCode::CONTROL_RIGHT: | 270 case ui::DomCode::CONTROL_RIGHT: |
| 294 return right ? ui::DomCode::CONTROL_RIGHT : ui::DomCode::CONTROL_LEFT; | 271 return right ? ui::DomCode::CONTROL_RIGHT : ui::DomCode::CONTROL_LEFT; |
| 295 case ui::DomCode::SHIFT_LEFT: | 272 case ui::DomCode::SHIFT_LEFT: |
| 296 case ui::DomCode::SHIFT_RIGHT: | 273 case ui::DomCode::SHIFT_RIGHT: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 312 EventRewriter::EventRewriter(ash::StickyKeysController* sticky_keys_controller) | 289 EventRewriter::EventRewriter(ash::StickyKeysController* sticky_keys_controller) |
| 313 : last_keyboard_device_id_(ui::ED_UNKNOWN_DEVICE), | 290 : last_keyboard_device_id_(ui::ED_UNKNOWN_DEVICE), |
| 314 ime_keyboard_for_testing_(NULL), | 291 ime_keyboard_for_testing_(NULL), |
| 315 pref_service_for_testing_(NULL), | 292 pref_service_for_testing_(NULL), |
| 316 sticky_keys_controller_(sticky_keys_controller), | 293 sticky_keys_controller_(sticky_keys_controller), |
| 317 current_diamond_key_modifier_flags_(ui::EF_NONE), | 294 current_diamond_key_modifier_flags_(ui::EF_NONE), |
| 318 pressed_modifier_latches_(ui::EF_NONE), | 295 pressed_modifier_latches_(ui::EF_NONE), |
| 319 latched_modifier_latches_(ui::EF_NONE), | 296 latched_modifier_latches_(ui::EF_NONE), |
| 320 used_modifier_latches_(ui::EF_NONE) {} | 297 used_modifier_latches_(ui::EF_NONE) {} |
| 321 | 298 |
| 322 EventRewriter::~EventRewriter() { | 299 EventRewriter::~EventRewriter() {} |
| 323 } | |
| 324 | 300 |
| 325 EventRewriter::DeviceType EventRewriter::KeyboardDeviceAddedForTesting( | 301 EventRewriter::DeviceType EventRewriter::KeyboardDeviceAddedForTesting( |
| 326 int device_id, | 302 int device_id, |
| 327 const std::string& device_name) { | 303 const std::string& device_name) { |
| 328 // Tests must avoid XI2 reserved device IDs. | 304 // Tests must avoid XI2 reserved device IDs. |
| 329 DCHECK((device_id < 0) || (device_id > 1)); | 305 DCHECK((device_id < 0) || (device_id > 1)); |
| 330 return KeyboardDeviceAddedInternal(device_id, device_name, kUnknownVendorId, | 306 return KeyboardDeviceAddedInternal(device_id, device_name, kUnknownVendorId, |
| 331 kUnknownProductId); | 307 kUnknownProductId); |
| 332 } | 308 } |
| 333 | 309 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 return sticky_keys_controller_->NextDispatchEvent(new_event); | 354 return sticky_keys_controller_->NextDispatchEvent(new_event); |
| 379 } | 355 } |
| 380 NOTREACHED(); | 356 NOTREACHED(); |
| 381 return ui::EVENT_REWRITE_CONTINUE; | 357 return ui::EVENT_REWRITE_CONTINUE; |
| 382 } | 358 } |
| 383 | 359 |
| 384 void EventRewriter::BuildRewrittenKeyEvent( | 360 void EventRewriter::BuildRewrittenKeyEvent( |
| 385 const ui::KeyEvent& key_event, | 361 const ui::KeyEvent& key_event, |
| 386 const MutableKeyState& state, | 362 const MutableKeyState& state, |
| 387 scoped_ptr<ui::Event>* rewritten_event) { | 363 scoped_ptr<ui::Event>* rewritten_event) { |
| 388 ui::KeyEvent* rewritten_key_event = new ui::KeyEvent( | 364 ui::KeyEvent* rewritten_key_event = |
| 389 key_event.type(), state.key_code, state.code, state.flags, state.key, | 365 new ui::KeyEvent(key_event.type(), state.key_code, state.code, |
| 390 state.character, key_event.time_stamp()); | 366 state.flags, state.key, key_event.time_stamp()); |
| 391 rewritten_event->reset(rewritten_key_event); | 367 rewritten_event->reset(rewritten_key_event); |
| 392 } | 368 } |
| 393 | 369 |
| 394 void EventRewriter::DeviceKeyPressedOrReleased(int device_id) { | 370 void EventRewriter::DeviceKeyPressedOrReleased(int device_id) { |
| 395 std::map<int, DeviceType>::const_iterator iter = | 371 std::map<int, DeviceType>::const_iterator iter = |
| 396 device_id_to_type_.find(device_id); | 372 device_id_to_type_.find(device_id); |
| 397 DeviceType type; | 373 DeviceType type; |
| 398 if (iter != device_id_to_type_.end()) | 374 if (iter != device_id_to_type_.end()) |
| 399 type = iter->second; | 375 type = iter->second; |
| 400 else | 376 else |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 if (key_event.source_device_id() != ui::ED_UNKNOWN_DEVICE) | 485 if (key_event.source_device_id() != ui::ED_UNKNOWN_DEVICE) |
| 510 DeviceKeyPressedOrReleased(key_event.source_device_id()); | 486 DeviceKeyPressedOrReleased(key_event.source_device_id()); |
| 511 | 487 |
| 512 // Drop repeated keys from Hotrod remote. | 488 // Drop repeated keys from Hotrod remote. |
| 513 if ((key_event.flags() & ui::EF_IS_REPEAT) && | 489 if ((key_event.flags() & ui::EF_IS_REPEAT) && |
| 514 (key_event.type() == ui::ET_KEY_PRESSED) && IsHotrodRemote() && | 490 (key_event.type() == ui::ET_KEY_PRESSED) && IsHotrodRemote() && |
| 515 key_event.key_code() != ui::VKEY_BACK) { | 491 key_event.key_code() != ui::VKEY_BACK) { |
| 516 return ui::EVENT_REWRITE_DISCARD; | 492 return ui::EVENT_REWRITE_DISCARD; |
| 517 } | 493 } |
| 518 | 494 |
| 519 MutableKeyState state = {key_event.flags(), | 495 MutableKeyState state = {key_event.flags(), key_event.code(), |
| 520 key_event.code(), | 496 key_event.GetDomKey(), key_event.key_code()}; |
| 521 key_event.GetDomKey(), | |
| 522 key_event.GetCharacter(), | |
| 523 key_event.key_code()}; | |
| 524 | 497 |
| 525 // Do not rewrite an event sent by ui_controls::SendKeyPress(). See | 498 // Do not rewrite an event sent by ui_controls::SendKeyPress(). See |
| 526 // crbug.com/136465. | 499 // crbug.com/136465. |
| 527 if (!(key_event.flags() & ui::EF_FINAL)) { | 500 if (!(key_event.flags() & ui::EF_FINAL)) { |
| 528 if (RewriteModifierKeys(key_event, &state)) { | 501 if (RewriteModifierKeys(key_event, &state)) { |
| 529 // Early exit with completed event. | 502 // Early exit with completed event. |
| 530 BuildRewrittenKeyEvent(key_event, state, rewritten_event); | 503 BuildRewrittenKeyEvent(key_event, state, rewritten_event); |
| 531 return ui::EVENT_REWRITE_REWRITTEN; | 504 return ui::EVENT_REWRITE_REWRITTEN; |
| 532 } | 505 } |
| 533 RewriteNumPadKeys(key_event, &state); | 506 RewriteNumPadKeys(key_event, &state); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 break; | 774 break; |
| 802 #endif | 775 #endif |
| 803 default: | 776 default: |
| 804 break; | 777 break; |
| 805 } | 778 } |
| 806 | 779 |
| 807 if (remapped_key) { | 780 if (remapped_key) { |
| 808 state->key_code = remapped_key->result.key_code; | 781 state->key_code = remapped_key->result.key_code; |
| 809 state->code = remapped_key->result.code; | 782 state->code = remapped_key->result.code; |
| 810 state->key = remapped_key->result.key; | 783 state->key = remapped_key->result.key; |
| 811 state->character = remapped_key->result.character; | |
| 812 incoming.flags |= characteristic_flag; | 784 incoming.flags |= characteristic_flag; |
| 813 characteristic_flag = remapped_key->flag; | 785 characteristic_flag = remapped_key->flag; |
| 814 state->code = RelocateModifier( | 786 state->code = RelocateModifier( |
| 815 state->code, ui::KeycodeConverter::DomCodeToLocation(incoming.code)); | 787 state->code, ui::KeycodeConverter::DomCodeToLocation(incoming.code)); |
| 816 } | 788 } |
| 817 | 789 |
| 818 // Next, remap modifier bits. | 790 // Next, remap modifier bits. |
| 819 state->flags |= | 791 state->flags |= |
| 820 GetRemappedModifierMasks(*pref_service, key_event, incoming.flags); | 792 GetRemappedModifierMasks(*pref_service, key_event, incoming.flags); |
| 821 if (key_event.type() == ui::ET_KEY_PRESSED) | 793 if (key_event.type() == ui::ET_KEY_PRESSED) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 848 return exact_event; | 820 return exact_event; |
| 849 } | 821 } |
| 850 | 822 |
| 851 void EventRewriter::RewriteNumPadKeys(const ui::KeyEvent& key_event, | 823 void EventRewriter::RewriteNumPadKeys(const ui::KeyEvent& key_event, |
| 852 MutableKeyState* state) { | 824 MutableKeyState* state) { |
| 853 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || | 825 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || |
| 854 key_event.type() == ui::ET_KEY_RELEASED); | 826 key_event.type() == ui::ET_KEY_RELEASED); |
| 855 static const struct NumPadRemapping { | 827 static const struct NumPadRemapping { |
| 856 ui::KeyboardCode input_key_code; | 828 ui::KeyboardCode input_key_code; |
| 857 EventRewriter::MutableKeyState result; | 829 EventRewriter::MutableKeyState result; |
| 858 } kNumPadRemappings[] = {{ui::VKEY_DELETE, | 830 } kNumPadRemappings[] = { |
| 859 {ui::EF_NONE, | 831 {ui::VKEY_DELETE, |
| 860 ui::DomCode::NONE, | 832 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'.'>::Character, |
| 861 ui::DomKey::CHARACTER, | 833 ui::VKEY_DECIMAL}}, |
| 862 '.', | 834 {ui::VKEY_INSERT, |
| 863 ui::VKEY_DECIMAL}}, | 835 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'0'>::Character, |
| 864 {ui::VKEY_INSERT, | 836 ui::VKEY_NUMPAD0}}, |
| 865 {ui::EF_NONE, | 837 {ui::VKEY_END, |
| 866 ui::DomCode::NONE, | 838 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'1'>::Character, |
| 867 ui::DomKey::CHARACTER, | 839 ui::VKEY_NUMPAD1}}, |
| 868 '0', | 840 {ui::VKEY_DOWN, |
| 869 ui::VKEY_NUMPAD0}}, | 841 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'2'>::Character, |
| 870 {ui::VKEY_END, | 842 ui::VKEY_NUMPAD2}}, |
| 871 {ui::EF_NONE, | 843 {ui::VKEY_NEXT, |
| 872 ui::DomCode::NONE, | 844 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'3'>::Character, |
| 873 ui::DomKey::CHARACTER, | 845 ui::VKEY_NUMPAD3}}, |
| 874 '1', | 846 {ui::VKEY_LEFT, |
| 875 ui::VKEY_NUMPAD1}}, | 847 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'4'>::Character, |
| 876 {ui::VKEY_DOWN, | 848 ui::VKEY_NUMPAD4}}, |
| 877 {ui::EF_NONE, | 849 {ui::VKEY_CLEAR, |
| 878 ui::DomCode::NONE, | 850 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'5'>::Character, |
| 879 ui::DomKey::CHARACTER, | 851 ui::VKEY_NUMPAD5}}, |
| 880 '2', | 852 {ui::VKEY_RIGHT, |
| 881 ui::VKEY_NUMPAD2}}, | 853 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'6'>::Character, |
| 882 {ui::VKEY_NEXT, | 854 ui::VKEY_NUMPAD6}}, |
| 883 {ui::EF_NONE, | 855 {ui::VKEY_HOME, |
| 884 ui::DomCode::NONE, | 856 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'7'>::Character, |
| 885 ui::DomKey::CHARACTER, | 857 ui::VKEY_NUMPAD7}}, |
| 886 '3', | 858 {ui::VKEY_UP, |
| 887 ui::VKEY_NUMPAD3}}, | 859 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'8'>::Character, |
| 888 {ui::VKEY_LEFT, | 860 ui::VKEY_NUMPAD8}}, |
| 889 {ui::EF_NONE, | 861 {ui::VKEY_PRIOR, |
| 890 ui::DomCode::NONE, | 862 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::Constant<'9'>::Character, |
| 891 ui::DomKey::CHARACTER, | 863 ui::VKEY_NUMPAD9}}}; |
| 892 '4', | |
| 893 ui::VKEY_NUMPAD4}}, | |
| 894 {ui::VKEY_CLEAR, | |
| 895 {ui::EF_NONE, | |
| 896 ui::DomCode::NONE, | |
| 897 ui::DomKey::CHARACTER, | |
| 898 '5', | |
| 899 ui::VKEY_NUMPAD5}}, | |
| 900 {ui::VKEY_RIGHT, | |
| 901 {ui::EF_NONE, | |
| 902 ui::DomCode::NONE, | |
| 903 ui::DomKey::CHARACTER, | |
| 904 '6', | |
| 905 ui::VKEY_NUMPAD6}}, | |
| 906 {ui::VKEY_HOME, | |
| 907 {ui::EF_NONE, | |
| 908 ui::DomCode::NONE, | |
| 909 ui::DomKey::CHARACTER, | |
| 910 '7', | |
| 911 ui::VKEY_NUMPAD7}}, | |
| 912 {ui::VKEY_UP, | |
| 913 {ui::EF_NONE, | |
| 914 ui::DomCode::NONE, | |
| 915 ui::DomKey::CHARACTER, | |
| 916 '8', | |
| 917 ui::VKEY_NUMPAD8}}, | |
| 918 {ui::VKEY_PRIOR, | |
| 919 {ui::EF_NONE, | |
| 920 ui::DomCode::NONE, | |
| 921 ui::DomKey::CHARACTER, | |
| 922 '9', | |
| 923 ui::VKEY_NUMPAD9}}}; | |
| 924 for (const auto& map : kNumPadRemappings) { | 864 for (const auto& map : kNumPadRemappings) { |
| 925 if (state->key_code == map.input_key_code) { | 865 if (state->key_code == map.input_key_code) { |
| 926 if (ui::KeycodeConverter::DomCodeToLocation(state->code) == | 866 if (ui::KeycodeConverter::DomCodeToLocation(state->code) == |
| 927 ui::DomKeyLocation::NUMPAD) { | 867 ui::DomKeyLocation::NUMPAD) { |
| 928 ApplyRemapping(map.result, state); | 868 ApplyRemapping(map.result, state); |
| 929 } | 869 } |
| 930 return; | 870 return; |
| 931 } | 871 } |
| 932 } | 872 } |
| 933 } | 873 } |
| 934 | 874 |
| 935 void EventRewriter::RewriteExtendedKeys(const ui::KeyEvent& key_event, | 875 void EventRewriter::RewriteExtendedKeys(const ui::KeyEvent& key_event, |
| 936 MutableKeyState* state) { | 876 MutableKeyState* state) { |
| 937 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || | 877 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || |
| 938 key_event.type() == ui::ET_KEY_RELEASED); | 878 key_event.type() == ui::ET_KEY_RELEASED); |
| 939 MutableKeyState incoming = *state; | 879 MutableKeyState incoming = *state; |
| 940 | 880 |
| 941 if ((incoming.flags & (ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN)) == | 881 if ((incoming.flags & (ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN)) == |
| 942 (ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN)) { | 882 (ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN)) { |
| 943 // Allow Search to avoid rewriting extended keys. | 883 // Allow Search to avoid rewriting extended keys. |
| 944 // For these, we only remove the EF_COMMAND_DOWN flag. | 884 // For these, we only remove the EF_COMMAND_DOWN flag. |
| 945 static const KeyboardRemapping::Condition kAvoidRemappings[] = { | 885 static const KeyboardRemapping::Condition kAvoidRemappings[] = { |
| 946 {// Alt+Backspace | 886 {// Alt+Backspace |
| 947 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN, | 887 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN, ui::VKEY_BACK}, |
| 948 ui::VKEY_BACK}, | |
| 949 {// Control+Alt+Up | 888 {// Control+Alt+Up |
| 950 ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_COMMAND_DOWN, | 889 ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_COMMAND_DOWN, |
| 951 ui::VKEY_UP}, | 890 ui::VKEY_UP}, |
| 952 {// Alt+Up | 891 {// Alt+Up |
| 953 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN, | 892 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN, ui::VKEY_UP}, |
| 954 ui::VKEY_UP}, | |
| 955 {// Control+Alt+Down | 893 {// Control+Alt+Down |
| 956 ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_COMMAND_DOWN, | 894 ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_COMMAND_DOWN, |
| 957 ui::VKEY_DOWN}, | 895 ui::VKEY_DOWN}, |
| 958 {// Alt+Down | 896 {// Alt+Down |
| 959 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN, | 897 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN, ui::VKEY_DOWN}}; |
| 960 ui::VKEY_DOWN}}; | |
| 961 for (const auto& condition : kAvoidRemappings) { | 898 for (const auto& condition : kAvoidRemappings) { |
| 962 if (MatchKeyboardRemapping(*state, condition)) { | 899 if (MatchKeyboardRemapping(*state, condition)) { |
| 963 state->flags = incoming.flags & ~ui::EF_COMMAND_DOWN; | 900 state->flags = incoming.flags & ~ui::EF_COMMAND_DOWN; |
| 964 return; | 901 return; |
| 965 } | 902 } |
| 966 } | 903 } |
| 967 } | 904 } |
| 968 | 905 |
| 969 if (incoming.flags & ui::EF_COMMAND_DOWN) { | 906 if (incoming.flags & ui::EF_COMMAND_DOWN) { |
| 970 static const KeyboardRemapping kSearchRemappings[] = { | 907 static const KeyboardRemapping kSearchRemappings[] = { |
| 971 {// Search+BackSpace -> Delete | 908 {// Search+BackSpace -> Delete |
| 972 {ui::EF_COMMAND_DOWN, ui::VKEY_BACK}, | 909 {ui::EF_COMMAND_DOWN, ui::VKEY_BACK}, |
| 973 {ui::EF_NONE, | 910 {ui::EF_NONE, ui::DomCode::DEL, ui::DomKey::DEL, ui::VKEY_DELETE}}, |
| 974 ui::DomCode::DEL, | |
| 975 ui::DomKey::DEL, | |
| 976 0x7F, | |
| 977 ui::VKEY_DELETE}}, | |
| 978 {// Search+Left -> Home | 911 {// Search+Left -> Home |
| 979 {ui::EF_COMMAND_DOWN, ui::VKEY_LEFT}, | 912 {ui::EF_COMMAND_DOWN, ui::VKEY_LEFT}, |
| 980 {ui::EF_NONE, ui::DomCode::HOME, ui::DomKey::HOME, 0, ui::VKEY_HOME}}, | 913 {ui::EF_NONE, ui::DomCode::HOME, ui::DomKey::HOME, ui::VKEY_HOME}}, |
| 981 {// Search+Up -> Prior (aka PageUp) | 914 {// Search+Up -> Prior (aka PageUp) |
| 982 {ui::EF_COMMAND_DOWN, ui::VKEY_UP}, | 915 {ui::EF_COMMAND_DOWN, ui::VKEY_UP}, |
| 983 {ui::EF_NONE, | 916 {ui::EF_NONE, ui::DomCode::PAGE_UP, ui::DomKey::PAGE_UP, |
| 984 ui::DomCode::PAGE_UP, | |
| 985 ui::DomKey::PAGE_UP, | |
| 986 0, | |
| 987 ui::VKEY_PRIOR}}, | 917 ui::VKEY_PRIOR}}, |
| 988 {// Search+Right -> End | 918 {// Search+Right -> End |
| 989 {ui::EF_COMMAND_DOWN, ui::VKEY_RIGHT}, | 919 {ui::EF_COMMAND_DOWN, ui::VKEY_RIGHT}, |
| 990 {ui::EF_NONE, ui::DomCode::END, ui::DomKey::END, 0, ui::VKEY_END}}, | 920 {ui::EF_NONE, ui::DomCode::END, ui::DomKey::END, ui::VKEY_END}}, |
| 991 {// Search+Down -> Next (aka PageDown) | 921 {// Search+Down -> Next (aka PageDown) |
| 992 {ui::EF_COMMAND_DOWN, ui::VKEY_DOWN}, | 922 {ui::EF_COMMAND_DOWN, ui::VKEY_DOWN}, |
| 993 {ui::EF_NONE, | 923 {ui::EF_NONE, ui::DomCode::PAGE_DOWN, ui::DomKey::PAGE_DOWN, |
| 994 ui::DomCode::PAGE_DOWN, | |
| 995 ui::DomKey::PAGE_DOWN, | |
| 996 0, | |
| 997 ui::VKEY_NEXT}}, | 924 ui::VKEY_NEXT}}, |
| 998 {// Search+Period -> Insert | 925 {// Search+Period -> Insert |
| 999 {ui::EF_COMMAND_DOWN, ui::VKEY_OEM_PERIOD}, | 926 {ui::EF_COMMAND_DOWN, ui::VKEY_OEM_PERIOD}, |
| 1000 {ui::EF_NONE, | 927 {ui::EF_NONE, ui::DomCode::INSERT, ui::DomKey::INSERT, |
| 1001 ui::DomCode::INSERT, | |
| 1002 ui::DomKey::INSERT, | |
| 1003 0, | |
| 1004 ui::VKEY_INSERT}}}; | 928 ui::VKEY_INSERT}}}; |
| 1005 if (RewriteWithKeyboardRemappings( | 929 if (RewriteWithKeyboardRemappings( |
| 1006 kSearchRemappings, arraysize(kSearchRemappings), incoming, state)) { | 930 kSearchRemappings, arraysize(kSearchRemappings), incoming, state)) { |
| 1007 return; | 931 return; |
| 1008 } | 932 } |
| 1009 } | 933 } |
| 1010 | 934 |
| 1011 if (incoming.flags & ui::EF_ALT_DOWN) { | 935 if (incoming.flags & ui::EF_ALT_DOWN) { |
| 1012 static const KeyboardRemapping kNonSearchRemappings[] = { | 936 static const KeyboardRemapping kNonSearchRemappings[] = { |
| 1013 {// Alt+BackSpace -> Delete | 937 {// Alt+BackSpace -> Delete |
| 1014 {ui::EF_ALT_DOWN, ui::VKEY_BACK}, | 938 {ui::EF_ALT_DOWN, ui::VKEY_BACK}, |
| 1015 {ui::EF_NONE, | 939 {ui::EF_NONE, ui::DomCode::DEL, ui::DomKey::DEL, ui::VKEY_DELETE}}, |
| 1016 ui::DomCode::DEL, | |
| 1017 ui::DomKey::DEL, | |
| 1018 0x7F, | |
| 1019 ui::VKEY_DELETE}}, | |
| 1020 {// Control+Alt+Up -> Home | 940 {// Control+Alt+Up -> Home |
| 1021 {ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN, ui::VKEY_UP}, | 941 {ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN, ui::VKEY_UP}, |
| 1022 {ui::EF_NONE, ui::DomCode::HOME, ui::DomKey::HOME, 0, ui::VKEY_HOME}}, | 942 {ui::EF_NONE, ui::DomCode::HOME, ui::DomKey::HOME, ui::VKEY_HOME}}, |
| 1023 {// Alt+Up -> Prior (aka PageUp) | 943 {// Alt+Up -> Prior (aka PageUp) |
| 1024 {ui::EF_ALT_DOWN, ui::VKEY_UP}, | 944 {ui::EF_ALT_DOWN, ui::VKEY_UP}, |
| 1025 {ui::EF_NONE, | 945 {ui::EF_NONE, ui::DomCode::PAGE_UP, ui::DomKey::PAGE_UP, |
| 1026 ui::DomCode::PAGE_UP, | |
| 1027 ui::DomKey::PAGE_UP, | |
| 1028 0, | |
| 1029 ui::VKEY_PRIOR}}, | 946 ui::VKEY_PRIOR}}, |
| 1030 {// Control+Alt+Down -> End | 947 {// Control+Alt+Down -> End |
| 1031 {ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN, ui::VKEY_DOWN}, | 948 {ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN, ui::VKEY_DOWN}, |
| 1032 {ui::EF_NONE, ui::DomCode::END, ui::DomKey::END, 0, ui::VKEY_END}}, | 949 {ui::EF_NONE, ui::DomCode::END, ui::DomKey::END, ui::VKEY_END}}, |
| 1033 {// Alt+Down -> Next (aka PageDown) | 950 {// Alt+Down -> Next (aka PageDown) |
| 1034 {ui::EF_ALT_DOWN, ui::VKEY_DOWN}, | 951 {ui::EF_ALT_DOWN, ui::VKEY_DOWN}, |
| 1035 {ui::EF_NONE, | 952 {ui::EF_NONE, ui::DomCode::PAGE_DOWN, ui::DomKey::PAGE_DOWN, |
| 1036 ui::DomCode::PAGE_DOWN, | |
| 1037 ui::DomKey::PAGE_DOWN, | |
| 1038 0, | |
| 1039 ui::VKEY_NEXT}}}; | 953 ui::VKEY_NEXT}}}; |
| 1040 if (RewriteWithKeyboardRemappings(kNonSearchRemappings, | 954 if (RewriteWithKeyboardRemappings(kNonSearchRemappings, |
| 1041 arraysize(kNonSearchRemappings), incoming, | 955 arraysize(kNonSearchRemappings), incoming, |
| 1042 state)) { | 956 state)) { |
| 1043 return; | 957 return; |
| 1044 } | 958 } |
| 1045 } | 959 } |
| 1046 } | 960 } |
| 1047 | 961 |
| 1048 void EventRewriter::RewriteFunctionKeys(const ui::KeyEvent& key_event, | 962 void EventRewriter::RewriteFunctionKeys(const ui::KeyEvent& key_event, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1060 // Search? Top Row Result | 974 // Search? Top Row Result |
| 1061 // ------- -------- ------ | 975 // ------- -------- ------ |
| 1062 // No Fn Unchanged | 976 // No Fn Unchanged |
| 1063 // No System Fn -> System | 977 // No System Fn -> System |
| 1064 // Yes Fn Fn -> System | 978 // Yes Fn Fn -> System |
| 1065 // Yes System Search+Fn -> Fn | 979 // Yes System Search+Fn -> Fn |
| 1066 if (top_row_keys_are_function_keys == search_is_pressed) { | 980 if (top_row_keys_are_function_keys == search_is_pressed) { |
| 1067 // Rewrite the F1-F12 keys on a Chromebook keyboard to system keys. | 981 // Rewrite the F1-F12 keys on a Chromebook keyboard to system keys. |
| 1068 static const KeyboardRemapping kFkeysToSystemKeys[] = { | 982 static const KeyboardRemapping kFkeysToSystemKeys[] = { |
| 1069 {{ui::EF_NONE, ui::VKEY_F1}, | 983 {{ui::EF_NONE, ui::VKEY_F1}, |
| 1070 {ui::EF_NONE, | 984 {ui::EF_NONE, ui::DomCode::BROWSER_BACK, ui::DomKey::BROWSER_BACK, |
| 1071 ui::DomCode::BROWSER_BACK, | |
| 1072 ui::DomKey::BROWSER_BACK, | |
| 1073 0, | |
| 1074 ui::VKEY_BROWSER_BACK}}, | 985 ui::VKEY_BROWSER_BACK}}, |
| 1075 {{ui::EF_NONE, ui::VKEY_F2}, | 986 {{ui::EF_NONE, ui::VKEY_F2}, |
| 1076 {ui::EF_NONE, | 987 {ui::EF_NONE, ui::DomCode::BROWSER_FORWARD, |
| 1077 ui::DomCode::BROWSER_FORWARD, | 988 ui::DomKey::BROWSER_FORWARD, ui::VKEY_BROWSER_FORWARD}}, |
| 1078 ui::DomKey::BROWSER_FORWARD, | |
| 1079 0, | |
| 1080 ui::VKEY_BROWSER_FORWARD}}, | |
| 1081 {{ui::EF_NONE, ui::VKEY_F3}, | 989 {{ui::EF_NONE, ui::VKEY_F3}, |
| 1082 {ui::EF_NONE, | 990 {ui::EF_NONE, ui::DomCode::BROWSER_REFRESH, |
| 1083 ui::DomCode::BROWSER_REFRESH, | 991 ui::DomKey::BROWSER_REFRESH, ui::VKEY_BROWSER_REFRESH}}, |
| 1084 ui::DomKey::BROWSER_REFRESH, | |
| 1085 0, | |
| 1086 ui::VKEY_BROWSER_REFRESH}}, | |
| 1087 {{ui::EF_NONE, ui::VKEY_F4}, | 992 {{ui::EF_NONE, ui::VKEY_F4}, |
| 1088 {ui::EF_NONE, | 993 {ui::EF_NONE, ui::DomCode::ZOOM_TOGGLE, ui::DomKey::ZOOM_TOGGLE, |
| 1089 ui::DomCode::ZOOM_TOGGLE, | |
| 1090 ui::DomKey::ZOOM_TOGGLE, | |
| 1091 0, | |
| 1092 ui::VKEY_MEDIA_LAUNCH_APP2}}, | 994 ui::VKEY_MEDIA_LAUNCH_APP2}}, |
| 1093 {{ui::EF_NONE, ui::VKEY_F5}, | 995 {{ui::EF_NONE, ui::VKEY_F5}, |
| 1094 {ui::EF_NONE, | 996 {ui::EF_NONE, ui::DomCode::SELECT_TASK, |
| 1095 ui::DomCode::SELECT_TASK, | 997 ui::DomKey::LAUNCH_MY_COMPUTER, ui::VKEY_MEDIA_LAUNCH_APP1}}, |
| 1096 ui::DomKey::LAUNCH_MY_COMPUTER, | |
| 1097 0, | |
| 1098 ui::VKEY_MEDIA_LAUNCH_APP1}}, | |
| 1099 {{ui::EF_NONE, ui::VKEY_F6}, | 998 {{ui::EF_NONE, ui::VKEY_F6}, |
| 1100 {ui::EF_NONE, | 999 {ui::EF_NONE, ui::DomCode::BRIGHTNESS_DOWN, |
| 1101 ui::DomCode::BRIGHTNESS_DOWN, | 1000 ui::DomKey::BRIGHTNESS_DOWN, ui::VKEY_BRIGHTNESS_DOWN}}, |
| 1102 ui::DomKey::BRIGHTNESS_DOWN, | |
| 1103 0, | |
| 1104 ui::VKEY_BRIGHTNESS_DOWN}}, | |
| 1105 {{ui::EF_NONE, ui::VKEY_F7}, | 1001 {{ui::EF_NONE, ui::VKEY_F7}, |
| 1106 {ui::EF_NONE, | 1002 {ui::EF_NONE, ui::DomCode::BRIGHTNESS_UP, ui::DomKey::BRIGHTNESS_UP, |
| 1107 ui::DomCode::BRIGHTNESS_UP, | |
| 1108 ui::DomKey::BRIGHTNESS_UP, | |
| 1109 0, | |
| 1110 ui::VKEY_BRIGHTNESS_UP}}, | 1003 ui::VKEY_BRIGHTNESS_UP}}, |
| 1111 {{ui::EF_NONE, ui::VKEY_F8}, | 1004 {{ui::EF_NONE, ui::VKEY_F8}, |
| 1112 {ui::EF_NONE, | 1005 {ui::EF_NONE, ui::DomCode::VOLUME_MUTE, ui::DomKey::VOLUME_MUTE, |
| 1113 ui::DomCode::VOLUME_MUTE, | |
| 1114 ui::DomKey::VOLUME_MUTE, | |
| 1115 0, | |
| 1116 ui::VKEY_VOLUME_MUTE}}, | 1006 ui::VKEY_VOLUME_MUTE}}, |
| 1117 {{ui::EF_NONE, ui::VKEY_F9}, | 1007 {{ui::EF_NONE, ui::VKEY_F9}, |
| 1118 {ui::EF_NONE, | 1008 {ui::EF_NONE, ui::DomCode::VOLUME_DOWN, ui::DomKey::VOLUME_DOWN, |
| 1119 ui::DomCode::VOLUME_DOWN, | |
| 1120 ui::DomKey::VOLUME_DOWN, | |
| 1121 0, | |
| 1122 ui::VKEY_VOLUME_DOWN}}, | 1009 ui::VKEY_VOLUME_DOWN}}, |
| 1123 {{ui::EF_NONE, ui::VKEY_F10}, | 1010 {{ui::EF_NONE, ui::VKEY_F10}, |
| 1124 {ui::EF_NONE, | 1011 {ui::EF_NONE, ui::DomCode::VOLUME_UP, ui::DomKey::VOLUME_UP, |
| 1125 ui::DomCode::VOLUME_UP, | |
| 1126 ui::DomKey::VOLUME_UP, | |
| 1127 0, | |
| 1128 ui::VKEY_VOLUME_UP}}, | 1012 ui::VKEY_VOLUME_UP}}, |
| 1129 }; | 1013 }; |
| 1130 MutableKeyState incoming_without_command = *state; | 1014 MutableKeyState incoming_without_command = *state; |
| 1131 incoming_without_command.flags &= ~ui::EF_COMMAND_DOWN; | 1015 incoming_without_command.flags &= ~ui::EF_COMMAND_DOWN; |
| 1132 if (RewriteWithKeyboardRemappings(kFkeysToSystemKeys, | 1016 if (RewriteWithKeyboardRemappings(kFkeysToSystemKeys, |
| 1133 arraysize(kFkeysToSystemKeys), | 1017 arraysize(kFkeysToSystemKeys), |
| 1134 incoming_without_command, state)) { | 1018 incoming_without_command, state)) { |
| 1135 return; | 1019 return; |
| 1136 } | 1020 } |
| 1137 } else if (search_is_pressed) { | 1021 } else if (search_is_pressed) { |
| 1138 // Allow Search to avoid rewriting F1-F12. | 1022 // Allow Search to avoid rewriting F1-F12. |
| 1139 state->flags &= ~ui::EF_COMMAND_DOWN; | 1023 state->flags &= ~ui::EF_COMMAND_DOWN; |
| 1140 return; | 1024 return; |
| 1141 } | 1025 } |
| 1142 } | 1026 } |
| 1143 | 1027 |
| 1144 if (state->flags & ui::EF_COMMAND_DOWN) { | 1028 if (state->flags & ui::EF_COMMAND_DOWN) { |
| 1145 // Remap Search+<number> to F<number>. | 1029 // Remap Search+<number> to F<number>. |
| 1146 // We check the DOM3 |code| here instead of the VKEY, as these keys may | 1030 // We check the DOM3 |code| here instead of the VKEY, as these keys may |
| 1147 // have different |KeyboardCode|s when modifiers are pressed, such as shift. | 1031 // have different |KeyboardCode|s when modifiers are pressed, such as shift. |
| 1148 static const struct { | 1032 static const struct { |
| 1149 ui::DomCode input_dom_code; | 1033 ui::DomCode input_dom_code; |
| 1150 EventRewriter::MutableKeyState result; | 1034 EventRewriter::MutableKeyState result; |
| 1151 } kNumberKeysToFkeys[] = { | 1035 } kNumberKeysToFkeys[] = { |
| 1152 {ui::DomCode::DIGIT1, | 1036 {ui::DomCode::DIGIT1, |
| 1153 {ui::EF_NONE, ui::DomCode::F1, ui::DomKey::F1, 0, ui::VKEY_F1}}, | 1037 {ui::EF_NONE, ui::DomCode::F1, ui::DomKey::F1, ui::VKEY_F1}}, |
| 1154 {ui::DomCode::DIGIT2, | 1038 {ui::DomCode::DIGIT2, |
| 1155 {ui::EF_NONE, ui::DomCode::F2, ui::DomKey::F2, 0, ui::VKEY_F2}}, | 1039 {ui::EF_NONE, ui::DomCode::F2, ui::DomKey::F2, ui::VKEY_F2}}, |
| 1156 {ui::DomCode::DIGIT3, | 1040 {ui::DomCode::DIGIT3, |
| 1157 {ui::EF_NONE, ui::DomCode::F3, ui::DomKey::F3, 0, ui::VKEY_F3}}, | 1041 {ui::EF_NONE, ui::DomCode::F3, ui::DomKey::F3, ui::VKEY_F3}}, |
| 1158 {ui::DomCode::DIGIT4, | 1042 {ui::DomCode::DIGIT4, |
| 1159 {ui::EF_NONE, ui::DomCode::F4, ui::DomKey::F4, 0, ui::VKEY_F4}}, | 1043 {ui::EF_NONE, ui::DomCode::F4, ui::DomKey::F4, ui::VKEY_F4}}, |
| 1160 {ui::DomCode::DIGIT5, | 1044 {ui::DomCode::DIGIT5, |
| 1161 {ui::EF_NONE, ui::DomCode::F5, ui::DomKey::F5, 0, ui::VKEY_F5}}, | 1045 {ui::EF_NONE, ui::DomCode::F5, ui::DomKey::F5, ui::VKEY_F5}}, |
| 1162 {ui::DomCode::DIGIT6, | 1046 {ui::DomCode::DIGIT6, |
| 1163 {ui::EF_NONE, ui::DomCode::F6, ui::DomKey::F6, 0, ui::VKEY_F6}}, | 1047 {ui::EF_NONE, ui::DomCode::F6, ui::DomKey::F6, ui::VKEY_F6}}, |
| 1164 {ui::DomCode::DIGIT7, | 1048 {ui::DomCode::DIGIT7, |
| 1165 {ui::EF_NONE, ui::DomCode::F7, ui::DomKey::F7, 0, ui::VKEY_F7}}, | 1049 {ui::EF_NONE, ui::DomCode::F7, ui::DomKey::F7, ui::VKEY_F7}}, |
| 1166 {ui::DomCode::DIGIT8, | 1050 {ui::DomCode::DIGIT8, |
| 1167 {ui::EF_NONE, ui::DomCode::F8, ui::DomKey::F8, 0, ui::VKEY_F8}}, | 1051 {ui::EF_NONE, ui::DomCode::F8, ui::DomKey::F8, ui::VKEY_F8}}, |
| 1168 {ui::DomCode::DIGIT9, | 1052 {ui::DomCode::DIGIT9, |
| 1169 {ui::EF_NONE, ui::DomCode::F9, ui::DomKey::F9, 0, ui::VKEY_F9}}, | 1053 {ui::EF_NONE, ui::DomCode::F9, ui::DomKey::F9, ui::VKEY_F9}}, |
| 1170 {ui::DomCode::DIGIT0, | 1054 {ui::DomCode::DIGIT0, |
| 1171 {ui::EF_NONE, ui::DomCode::F10, ui::DomKey::F10, 0, ui::VKEY_F10}}, | 1055 {ui::EF_NONE, ui::DomCode::F10, ui::DomKey::F10, ui::VKEY_F10}}, |
| 1172 {ui::DomCode::MINUS, | 1056 {ui::DomCode::MINUS, |
| 1173 {ui::EF_NONE, ui::DomCode::F11, ui::DomKey::F11, 0, ui::VKEY_F11}}, | 1057 {ui::EF_NONE, ui::DomCode::F11, ui::DomKey::F11, ui::VKEY_F11}}, |
| 1174 {ui::DomCode::EQUAL, | 1058 {ui::DomCode::EQUAL, |
| 1175 {ui::EF_NONE, ui::DomCode::F12, ui::DomKey::F12, 0, ui::VKEY_F12}}}; | 1059 {ui::EF_NONE, ui::DomCode::F12, ui::DomKey::F12, ui::VKEY_F12}}}; |
| 1176 for (const auto& map : kNumberKeysToFkeys) { | 1060 for (const auto& map : kNumberKeysToFkeys) { |
| 1177 if (state->code == map.input_dom_code) { | 1061 if (state->code == map.input_dom_code) { |
| 1178 state->flags &= ~ui::EF_COMMAND_DOWN; | 1062 state->flags &= ~ui::EF_COMMAND_DOWN; |
| 1179 ApplyRemapping(map.result, state); | 1063 ApplyRemapping(map.result, state); |
| 1180 return; | 1064 return; |
| 1181 } | 1065 } |
| 1182 } | 1066 } |
| 1183 } | 1067 } |
| 1184 } | 1068 } |
| 1185 | 1069 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 for (const auto& keyboard : keyboards) { | 1125 for (const auto& keyboard : keyboards) { |
| 1242 if (keyboard.id == device_id) { | 1126 if (keyboard.id == device_id) { |
| 1243 return KeyboardDeviceAddedInternal( | 1127 return KeyboardDeviceAddedInternal( |
| 1244 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); | 1128 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); |
| 1245 } | 1129 } |
| 1246 } | 1130 } |
| 1247 return kDeviceUnknown; | 1131 return kDeviceUnknown; |
| 1248 } | 1132 } |
| 1249 | 1133 |
| 1250 } // namespace chromeos | 1134 } // namespace chromeos |
| OLD | NEW |