| 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 #ifndef CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // - converts numeric pad editing keys to their numeric forms; | 34 // - converts numeric pad editing keys to their numeric forms; |
| 35 // - converts top-row function keys to special keys where necessary; | 35 // - converts top-row function keys to special keys where necessary; |
| 36 // - handles various key combinations like Search+Backspace -> Delete | 36 // - handles various key combinations like Search+Backspace -> Delete |
| 37 // and Search+number to Fnumber; | 37 // and Search+number to Fnumber; |
| 38 // - handles key/pointer combinations like Alt+Button1 -> Button3. | 38 // - handles key/pointer combinations like Alt+Button1 -> Button3. |
| 39 class EventRewriter : public ui::EventRewriter { | 39 class EventRewriter : public ui::EventRewriter { |
| 40 public: | 40 public: |
| 41 enum DeviceType { | 41 enum DeviceType { |
| 42 kDeviceUnknown = 0, | 42 kDeviceUnknown = 0, |
| 43 kDeviceAppleKeyboard, | 43 kDeviceAppleKeyboard, |
| 44 kDeviceHotrodRemote, |
| 45 kDeviceVirtualCoreKeyboard, // X-server generated events. |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 // Does not take ownership of the |sticky_keys_controller|, which may also | 48 // Does not take ownership of the |sticky_keys_controller|, which may also |
| 47 // be NULL (for testing without ash), in which case sticky key operations | 49 // be NULL (for testing without ash), in which case sticky key operations |
| 48 // don't happen. | 50 // don't happen. |
| 49 explicit EventRewriter(ash::StickyKeysController* sticky_keys_controller); | 51 explicit EventRewriter(ash::StickyKeysController* sticky_keys_controller); |
| 50 virtual ~EventRewriter(); | 52 virtual ~EventRewriter(); |
| 51 | 53 |
| 52 // Calls KeyboardDeviceAddedInternal. | 54 // Calls KeyboardDeviceAddedInternal. |
| 53 DeviceType KeyboardDeviceAddedForTesting(int device_id, | 55 DeviceType KeyboardDeviceAddedForTesting(int device_id, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 ui::KeyboardCode output_key_code; | 103 ui::KeyboardCode output_key_code; |
| 102 int output_flags; | 104 int output_flags; |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 void DeviceKeyPressedOrReleased(int device_id); | 107 void DeviceKeyPressedOrReleased(int device_id); |
| 106 | 108 |
| 107 // Returns the PrefService that should be used. | 109 // Returns the PrefService that should be used. |
| 108 const PrefService* GetPrefService() const; | 110 const PrefService* GetPrefService() const; |
| 109 | 111 |
| 110 // Adds a device to |device_id_to_type_|. | 112 // Adds a device to |device_id_to_type_|. |
| 111 void KeyboardDeviceAdded(int device_id); | 113 DeviceType KeyboardDeviceAdded(int device_id); |
| 112 | 114 |
| 113 // Checks the type of the |device_name|, and inserts a new entry to | 115 // Checks the type of the |device_name|, |vendor_id| and |product_id|, and |
| 114 // |device_id_to_type_|. | 116 // inserts a new entry to |device_id_to_type_|. |
| 115 DeviceType KeyboardDeviceAddedInternal(int device_id, | 117 DeviceType KeyboardDeviceAddedInternal(int device_id, |
| 116 const std::string& device_name); | 118 const std::string& device_name, |
| 119 int vendor_id, |
| 120 int product_id); |
| 117 | 121 |
| 118 // Returns true if |last_keyboard_device_id_| is Apple's. | 122 // Returns true if |last_keyboard_device_id_| is Apple's. |
| 119 bool IsAppleKeyboard() const; | 123 bool IsAppleKeyboard() const; |
| 124 // Returns true if |last_keyboard_device_id_| is Hotrod remote. |
| 125 bool IsHotrodRemote() const; |
| 126 // Returns true if |last_keyboard_device_id_| is of given |device_type|. |
| 127 bool IsLastKeyboardOfType(DeviceType device_type) const; |
| 120 | 128 |
| 121 // Returns true if the target for |event| would prefer to receive raw function | 129 // Returns true if the target for |event| would prefer to receive raw function |
| 122 // keys instead of having them rewritten into back, forward, brightness, | 130 // keys instead of having them rewritten into back, forward, brightness, |
| 123 // volume, etc. or if the user has specified that they desire top-row keys to | 131 // volume, etc. or if the user has specified that they desire top-row keys to |
| 124 // be treated as function keys globally. | 132 // be treated as function keys globally. |
| 125 bool TopRowKeysAreFunctionKeys(const ui::KeyEvent& event) const; | 133 bool TopRowKeysAreFunctionKeys(const ui::KeyEvent& event) const; |
| 126 | 134 |
| 127 // Given modifier flags |original_flags|, returns the remapped modifiers | 135 // Given modifier flags |original_flags|, returns the remapped modifiers |
| 128 // according to user preferences and/or event properties. | 136 // according to user preferences and/or event properties. |
| 129 int GetRemappedModifierMasks(const PrefService& pref_service, | 137 int GetRemappedModifierMasks(const PrefService& pref_service, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // While the Diamond key is down, this holds the corresponding modifier | 196 // While the Diamond key is down, this holds the corresponding modifier |
| 189 // ui::EventFlags; otherwise it is EF_NONE. | 197 // ui::EventFlags; otherwise it is EF_NONE. |
| 190 int current_diamond_key_modifier_flags_; | 198 int current_diamond_key_modifier_flags_; |
| 191 | 199 |
| 192 DISALLOW_COPY_AND_ASSIGN(EventRewriter); | 200 DISALLOW_COPY_AND_ASSIGN(EventRewriter); |
| 193 }; | 201 }; |
| 194 | 202 |
| 195 } // namespace chromeos | 203 } // namespace chromeos |
| 196 | 204 |
| 197 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 205 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| OLD | NEW |