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 UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ |
6 #define UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ |
7 | 7 |
8 #include <bitset> | 8 #include <bitset> |
9 #include <linux/input.h> | 9 #include <linux/input.h> |
10 | 10 |
11 #include "ui/events/ozone/evdev/event_device_util.h" | 11 #include "ui/events/ozone/evdev/event_device_util.h" |
12 #include "ui/events/ozone/evdev/event_dispatch_callback.h" | 12 #include "ui/events/ozone/evdev/event_dispatch_callback.h" |
13 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 13 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| 14 #include "ui/events/ozone/layout/keyboard_layout_engine.h" |
14 | 15 |
15 namespace ui { | 16 namespace ui { |
16 | 17 |
17 class EventModifiersEvdev; | 18 class EventModifiersEvdev; |
18 | 19 |
19 // Keyboard for evdev. | 20 // Keyboard for evdev. |
20 // | 21 // |
21 // This object is responsible for combining all attached keyboards into | 22 // This object is responsible for combining all attached keyboards into |
22 // one logical keyboard, applying modifiers & implementing key repeat. | 23 // one logical keyboard, applying modifiers & implementing key repeat. |
23 // | 24 // |
24 // It also currently also applies the layout (hardcoded as US). | 25 // It also currently also applies the layout. |
25 // | 26 // |
26 // TODO(spang): Implement key repeat & turn off kernel repeat. | 27 // TODO(spang): Implement key repeat & turn off kernel repeat. |
27 class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev { | 28 class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev { |
28 public: | 29 public: |
29 KeyboardEvdev(EventModifiersEvdev* modifiers, | 30 KeyboardEvdev(EventModifiersEvdev* modifiers, |
| 31 KeyboardLayoutEngine* keyboard_layout_engine, |
30 const EventDispatchCallback& callback); | 32 const EventDispatchCallback& callback); |
31 ~KeyboardEvdev(); | 33 ~KeyboardEvdev(); |
32 | 34 |
33 // Handlers for raw key presses & releases. | 35 // Handlers for raw key presses & releases. |
34 void OnKeyChange(unsigned int code, bool down); | 36 void OnKeyChange(unsigned int code, bool down); |
35 | 37 |
36 private: | 38 private: |
37 void UpdateModifier(unsigned int key, bool down); | 39 void UpdateModifier(unsigned int key, bool down); |
38 void DispatchKey(unsigned int key, bool down); | 40 void DispatchKey(unsigned int key, bool down); |
39 | 41 |
40 // Aggregated key state. There is only one bit of state per key; we do not | 42 // Aggregated key state. There is only one bit of state per key; we do not |
41 // attempt to count presses of the same key on multiple keyboards. | 43 // attempt to count presses of the same key on multiple keyboards. |
42 // | 44 // |
43 // A key is down iff the most recent event pertaining to that key was a key | 45 // A key is down iff the most recent event pertaining to that key was a key |
44 // down event rather than a key up event. Therefore, a particular key position | 46 // down event rather than a key up event. Therefore, a particular key position |
45 // can be considered released even if it is being depresssed on one or more | 47 // can be considered released even if it is being depresssed on one or more |
46 // keyboards. | 48 // keyboards. |
47 std::bitset<KEY_CNT> key_state_; | 49 std::bitset<KEY_CNT> key_state_; |
48 | 50 |
49 // Callback for dispatching events. | 51 // Callback for dispatching events. |
50 EventDispatchCallback callback_; | 52 EventDispatchCallback callback_; |
51 | 53 |
52 // Shared modifier state. | 54 // Shared modifier state. |
53 EventModifiersEvdev* modifiers_; | 55 EventModifiersEvdev* modifiers_; |
54 | 56 |
| 57 KeyboardLayoutEngine* keyboard_layout_engine_; |
| 58 |
55 DISALLOW_COPY_AND_ASSIGN(KeyboardEvdev); | 59 DISALLOW_COPY_AND_ASSIGN(KeyboardEvdev); |
56 }; | 60 }; |
57 | 61 |
58 } // namespace ui | 62 } // namespace ui |
59 | 63 |
60 #endif // UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ | 64 #endif // UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ |
OLD | NEW |