Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: ui/events/ozone/evdev/event_converter_evdev.h

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_
7
8 #include <set>
9
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "base/message_loop/message_loop.h"
13 #include "ui/events/devices/input_device.h"
14 #include "ui/events/ozone/evdev/event_dispatch_callback.h"
15 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
16 #include "ui/gfx/geometry/size.h"
17
18 struct input_event;
19
20 namespace ui {
21 enum class DomCode;
22
23 class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdev
24 : public base::MessagePumpLibevent::Watcher {
25 public:
26 EventConverterEvdev(int fd,
27 const base::FilePath& path,
28 int id,
29 InputDeviceType type,
30 const std::string& name,
31 uint16_t vendor_id,
32 uint16_t product_id);
33 ~EventConverterEvdev() override;
34
35 int id() const { return input_device_.id; }
36
37 const base::FilePath& path() const { return path_; }
38
39 InputDeviceType type() const { return input_device_.type; }
40
41 const InputDevice& input_device() const { return input_device_; }
42
43 // Start reading events.
44 void Start();
45
46 // Stop reading events.
47 void Stop();
48
49 // Enable or disable this device. A disabled device still polls for
50 // input and can update state but must not dispatch any events to UI.
51 void SetEnabled(bool enabled);
52
53 // Cleanup after we stop reading events (release buttons, etc).
54 virtual void OnStopped();
55
56 // Prepare for disable (e.g. should release keys/buttons/touches).
57 virtual void OnDisabled();
58
59 // Start or restart (e.g. should reapply keys/buttons/touches).
60 virtual void OnEnabled();
61
62 // Returns true if the converter is used for a keyboard device.
63 virtual bool HasKeyboard() const;
64
65 // Returns true if the converter is used for a mouse device;
66 virtual bool HasMouse() const;
67
68 // Returns true if the converter is used for a touchpad device.
69 virtual bool HasTouchpad() const;
70
71 // Returns true if the converter is used for a touchscreen device.
72 virtual bool HasTouchscreen() const;
73
74 // Returns true if the converter is used for a device with a caps lock LED.
75 virtual bool HasCapsLockLed() const;
76
77 // Returns the size of the touchscreen device if the converter is used for a
78 // touchscreen device.
79 virtual gfx::Size GetTouchscreenSize() const;
80
81 // Returns the number of touch points this device supports. Should not be
82 // called unless HasTouchscreen() returns true
83 virtual int GetTouchPoints() const;
84
85 // Sets which keyboard keys should be processed. If |enable_filter| is
86 // false, all keys are allowed and |allowed_keys| is ignored.
87 virtual void SetKeyFilter(bool enable_filter,
88 std::vector<DomCode> allowed_keys);
89
90 // Update caps lock LED state.
91 virtual void SetCapsLockLed(bool enabled);
92
93 // Helper to generate a base::TimeDelta from an input_event's time
94 static base::TimeDelta TimeDeltaFromInputEvent(const input_event& event);
95
96 protected:
97 // base::MessagePumpLibevent::Watcher:
98 void OnFileCanWriteWithoutBlocking(int fd) override;
99
100 // File descriptor to read.
101 int fd_;
102
103 // Path to input device.
104 base::FilePath path_;
105
106 // Input device information, including id (which uniquely identifies an
107 // event converter) and type.
108 InputDevice input_device_;
109
110 // Whether we're polling for input on the device.
111 bool watching_ = false;
112
113 // Whether events should be dispatched to UI.
114 bool enabled_ = false;
115
116 // Controller for watching the input fd.
117 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
118
119 private:
120 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdev);
121 };
122
123 } // namespace ui
124
125 #endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/device_event_dispatcher_evdev.cc ('k') | ui/events/ozone/evdev/event_converter_evdev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698