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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // | 27 // |
28 // It also currently also applies the layout. | 28 // It also currently also applies the layout. |
29 class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev { | 29 class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev { |
30 public: | 30 public: |
31 KeyboardEvdev(EventModifiersEvdev* modifiers, | 31 KeyboardEvdev(EventModifiersEvdev* modifiers, |
32 KeyboardLayoutEngine* keyboard_layout_engine, | 32 KeyboardLayoutEngine* keyboard_layout_engine, |
33 const EventDispatchCallback& callback); | 33 const EventDispatchCallback& callback); |
34 ~KeyboardEvdev(); | 34 ~KeyboardEvdev(); |
35 | 35 |
36 // Handlers for raw key presses & releases. | 36 // Handlers for raw key presses & releases. |
37 void OnKeyChange(unsigned int code, bool down, base::TimeDelta timestamp); | 37 void OnKeyChange(unsigned int code, |
| 38 bool down, |
| 39 base::TimeDelta timestamp, |
| 40 int device_id); |
38 | 41 |
39 // Handle Caps Lock modifier. | 42 // Handle Caps Lock modifier. |
40 void SetCapsLockEnabled(bool enabled); | 43 void SetCapsLockEnabled(bool enabled); |
41 bool IsCapsLockEnabled(); | 44 bool IsCapsLockEnabled(); |
42 | 45 |
43 // Configuration for key repeat. | 46 // Configuration for key repeat. |
44 bool IsAutoRepeatEnabled(); | 47 bool IsAutoRepeatEnabled(); |
45 void SetAutoRepeatEnabled(bool enabled); | 48 void SetAutoRepeatEnabled(bool enabled); |
46 void SetAutoRepeatRate(const base::TimeDelta& delay, | 49 void SetAutoRepeatRate(const base::TimeDelta& delay, |
47 const base::TimeDelta& interval); | 50 const base::TimeDelta& interval); |
48 void GetAutoRepeatRate(base::TimeDelta* delay, base::TimeDelta* interval); | 51 void GetAutoRepeatRate(base::TimeDelta* delay, base::TimeDelta* interval); |
49 | 52 |
50 private: | 53 private: |
51 void UpdateModifier(int modifier_flag, bool down); | 54 void UpdateModifier(int modifier_flag, bool down); |
52 void UpdateCapsLockLed(); | 55 void UpdateCapsLockLed(); |
53 void UpdateKeyRepeat(unsigned int key, bool down); | 56 void UpdateKeyRepeat(unsigned int key, bool down, int device_id); |
54 void StartKeyRepeat(unsigned int key); | 57 void StartKeyRepeat(unsigned int key, int device_id); |
55 void StopKeyRepeat(); | 58 void StopKeyRepeat(); |
56 void ScheduleKeyRepeat(const base::TimeDelta& delay); | 59 void ScheduleKeyRepeat(const base::TimeDelta& delay); |
57 void OnRepeatTimeout(unsigned int sequence); | 60 void OnRepeatTimeout(unsigned int sequence); |
58 void DispatchKey(unsigned int key, | 61 void DispatchKey(unsigned int key, |
59 bool down, | 62 bool down, |
60 bool repeat, | 63 bool repeat, |
61 base::TimeDelta timestamp); | 64 base::TimeDelta timestamp, |
| 65 int device_id); |
62 | 66 |
63 // Aggregated key state. There is only one bit of state per key; we do not | 67 // Aggregated key state. There is only one bit of state per key; we do not |
64 // attempt to count presses of the same key on multiple keyboards. | 68 // attempt to count presses of the same key on multiple keyboards. |
65 // | 69 // |
66 // A key is down iff the most recent event pertaining to that key was a key | 70 // A key is down iff the most recent event pertaining to that key was a key |
67 // down event rather than a key up event. Therefore, a particular key position | 71 // down event rather than a key up event. Therefore, a particular key position |
68 // can be considered released even if it is being depresssed on one or more | 72 // can be considered released even if it is being depresssed on one or more |
69 // keyboards. | 73 // keyboards. |
70 std::bitset<KEY_CNT> key_state_; | 74 std::bitset<KEY_CNT> key_state_; |
71 | 75 |
72 // Callback for dispatching events. | 76 // Callback for dispatching events. |
73 EventDispatchCallback callback_; | 77 EventDispatchCallback callback_; |
74 | 78 |
75 // Shared modifier state. | 79 // Shared modifier state. |
76 EventModifiersEvdev* modifiers_; | 80 EventModifiersEvdev* modifiers_; |
77 | 81 |
78 // Shared layout engine. | 82 // Shared layout engine. |
79 KeyboardLayoutEngine* keyboard_layout_engine_; | 83 KeyboardLayoutEngine* keyboard_layout_engine_; |
80 | 84 |
81 // Key repeat state. | 85 // Key repeat state. |
82 bool repeat_enabled_; | 86 bool repeat_enabled_; |
83 unsigned int repeat_key_; | 87 unsigned int repeat_key_; |
84 unsigned int repeat_sequence_; | 88 unsigned int repeat_sequence_; |
| 89 int repeat_device_id_; |
85 base::TimeDelta repeat_delay_; | 90 base::TimeDelta repeat_delay_; |
86 base::TimeDelta repeat_interval_; | 91 base::TimeDelta repeat_interval_; |
87 | 92 |
88 base::WeakPtrFactory<KeyboardEvdev> weak_ptr_factory_; | 93 base::WeakPtrFactory<KeyboardEvdev> weak_ptr_factory_; |
89 | 94 |
90 DISALLOW_COPY_AND_ASSIGN(KeyboardEvdev); | 95 DISALLOW_COPY_AND_ASSIGN(KeyboardEvdev); |
91 }; | 96 }; |
92 | 97 |
93 } // namespace ui | 98 } // namespace ui |
94 | 99 |
95 #endif // UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ | 100 #endif // UI_EVENTS_OZONE_EVDEV_KEYBOARD_EVDEV_H_ |
OLD | NEW |