Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / events / keycodes / keyboard_code_conversion_mac.h
blobf4ba52c429780ad699bec4c9bf24bfd27a6acf09
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_MAC_H_
6 #define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_MAC_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/basictypes.h"
11 #include "ui/events/events_base_export.h"
12 #include "ui/events/keycodes/keyboard_codes_posix.h"
14 namespace ui {
16 enum class DomCode;
18 // We use windows virtual keycodes throughout our keyboard event related code,
19 // including unit tests. But Mac uses a different set of virtual keycodes.
20 // This function converts a windows virtual keycode into Mac's virtual key code
21 // and corresponding unicode character. |flags| is the Cocoa modifiers mask
22 // such as NSControlKeyMask, NSShiftKeyMask, etc.
23 // When success, the corresponding Mac's virtual key code will be returned.
24 // |keyboard_character| is the corresponding keyboard character, suitable for
25 // use in -[NSEvent characters]. If NSShiftKeyMask appears in |flags|,
26 // |us_keyboard_shifted_character| is |keyboard_character| with a shift modifier
27 // applied using a US keyboard layout (otherwise unmodified).
28 // |us_keyboard_shifted_character| is suitable for -[NSEvent
29 // charactersIgnoringModifiers] (which ignores all modifiers except for shift).
30 // -1 will be returned if the keycode can't be converted.
31 // This function is mainly for simulating keyboard events in unit tests.
32 // See |KeyboardCodeFromNSEvent| for reverse conversion.
33 EVENTS_BASE_EXPORT int MacKeyCodeForWindowsKeyCode(
34 KeyboardCode keycode,
35 NSUInteger flags,
36 unichar* us_keyboard_shifted_character,
37 unichar* keyboard_character);
39 // This implementation cribbed from:
40 // third_party/WebKit/Source/web/mac/WebInputEventFactory.mm
41 // Converts |event| into a |KeyboardCode|. The mapping is not direct as the Mac
42 // has a different notion of key codes.
43 EVENTS_BASE_EXPORT KeyboardCode KeyboardCodeFromNSEvent(NSEvent* event);
45 EVENTS_BASE_EXPORT DomCode CodeFromNSEvent(NSEvent* event);
47 } // namespace ui
49 #endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_MAC_H_