Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_ | |
| 6 #define UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/strings/string16.h" | |
| 11 #include "ui/events/keycodes/keyboard_codes.h" | |
| 12 #include "ui/events/ozone/layout/events_ozone_layout_export.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 enum class DomCode; | |
| 17 enum class DomKey; | |
| 18 | |
| 19 // A KeyboardLayoutEngine provides a platform-independent interface to | |
| 20 // key mapping. Key mapping provides a meaning (DomKey and character, | |
| 21 // and optionally Windows key code) for a physical key press (DomCode | |
| 22 // and modifier flags). | |
| 23 // | |
| 24 // The interface must support platforms that only provide a single opaque | |
| 25 // system layout, so there is no standalone 'KeyboardLayout' object. | |
|
Wez
2014/12/09 07:00:33
This comment is not very self-explanatory; IIUC yo
kpschoedel
2014/12/09 19:58:43
Indeed, took me a bit of pondering to remember wha
| |
| 26 class EVENTS_OZONE_LAYOUT_EXPORT KeyboardLayoutEngine { | |
| 27 public: | |
| 28 KeyboardLayoutEngine() {} | |
| 29 virtual ~KeyboardLayoutEngine() {} | |
| 30 | |
| 31 // Returns true if it is possible to change the current layout. | |
| 32 virtual bool CanSetCurrentLayout() const = 0; | |
| 33 | |
| 34 // Sets the current layout; returns true on success. | |
| 35 virtual bool SetCurrentLayoutByName(const std::string& layout_name) = 0; | |
| 36 | |
| 37 // Returns true if the current layout makes use of the ISO Level 5 Shift key. | |
| 38 virtual bool UsesISOLevel5Shift() const = 0; | |
| 39 | |
| 40 // Returns true if the current layout makes use of the AltGr | |
| 41 // (ISO Level 3 Shift) key. | |
| 42 virtual bool UsesAltGr() const = 0; | |
| 43 | |
| 44 // Provides the meaning of a physical key. | |
| 45 // | |
| 46 // The caller must supply valid addresses for all the output parameters; | |
| 47 // the function must not use their initial values. | |
| 48 // | |
| 49 // Returns true if it can determine the meaning of the (dom_code, flags) | |
| 50 // values, OR if it can determine that they have no meaning in the current | |
| 51 // layout (e.g. the key is unbound). In the latter case, the function sets | |
| 52 // *dom_key to UNIDENTIFIED, *character to 0, and *key_code to VKEY_UNKNOWN. | |
| 53 // | |
| 54 // Returns false if it cannot determine the meaning (and cannot determine | |
| 55 // that there is none); in this case it does not set any of the output | |
| 56 // parameters. | |
| 57 virtual bool Lookup(DomCode dom_code, | |
| 58 int flags, | |
| 59 DomKey* dom_key, | |
| 60 base::char16* character, | |
| 61 KeyboardCode* key_code) const = 0; | |
| 62 }; | |
| 63 | |
| 64 } // namespace ui | |
| 65 | |
| 66 #endif // UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_ | |
| OLD | NEW |