OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/test/chromedriver/keycode_text_conversion.h" | 5 #include "chrome/test/chromedriver/keycode_text_conversion.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 | 10 |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/test/chromedriver/ui_events.h" | 12 #include "chrome/test/chromedriver/chrome/ui_events.h" |
13 | 13 |
14 std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers) { | 14 std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers) { |
15 UINT scan_code = ::MapVirtualKeyW(key_code, MAPVK_VK_TO_VSC); | 15 UINT scan_code = ::MapVirtualKeyW(key_code, MAPVK_VK_TO_VSC); |
16 BYTE keyboard_state[256]; | 16 BYTE keyboard_state[256]; |
17 memset(keyboard_state, 0, 256); | 17 memset(keyboard_state, 0, 256); |
18 if (modifiers & kShiftKeyModifierMask) | 18 if (modifiers & kShiftKeyModifierMask) |
19 keyboard_state[VK_SHIFT] |= 0x80; | 19 keyboard_state[VK_SHIFT] |= 0x80; |
20 if (modifiers & kControlKeyModifierMask) | 20 if (modifiers & kControlKeyModifierMask) |
21 keyboard_state[VK_CONTROL] |= 0x80; | 21 keyboard_state[VK_CONTROL] |= 0x80; |
22 if (modifiers & kAltKeyModifierMask) | 22 if (modifiers & kAltKeyModifierMask) |
(...skipping 25 matching lines...) Expand all Loading... |
48 modifiers |= kShiftKeyModifierMask; | 48 modifiers |= kShiftKeyModifierMask; |
49 if (win_modifiers & 0x02) | 49 if (win_modifiers & 0x02) |
50 modifiers |= kControlKeyModifierMask; | 50 modifiers |= kControlKeyModifierMask; |
51 if (win_modifiers & 0x04) | 51 if (win_modifiers & 0x04) |
52 modifiers |= kAltKeyModifierMask; | 52 modifiers |= kAltKeyModifierMask; |
53 // Ignore bit 0x08: It is for Hankaku key. | 53 // Ignore bit 0x08: It is for Hankaku key. |
54 *necessary_modifiers = modifiers; | 54 *necessary_modifiers = modifiers; |
55 } | 55 } |
56 return translated; | 56 return translated; |
57 } | 57 } |
OLD | NEW |