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