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

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

Issue 2805793002: ozone: evdev: Add gamepad support (Closed)
Patch Set: Support Gamepad in Ozone. Created 3 years, 8 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 2017 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_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
6 #define UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
7
8 #include <vector>
9
10 #include "base/files/file_path.h"
11 #include "base/macros.h"
12 #include "ui/events/devices/input_device.h"
13 #include "ui/events/event.h"
14 #include "ui/events/ozone/evdev/event_converter_evdev.h"
15 #include "ui/events/ozone/evdev/event_device_info.h"
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
17 #include "ui/events/ozone/evdev/scoped_input_device.h"
18 #include "ui/events/ozone/gamepad/gamepad_mapping.h"
19
20 struct input_event;
21
22 namespace ui {
23
24 class DeviceEventDispatcherEvdev;
25
26 class EVENTS_OZONE_EVDEV_EXPORT GamepadEventConverterEvdev
27 : public EventConverterEvdev {
28 public:
29 GamepadEventConverterEvdev(ScopedInputDevice fd,
30 base::FilePath path,
31 int id,
32 const EventDeviceInfo& info,
33 DeviceEventDispatcherEvdev* dispatcher);
34
35 ~GamepadEventConverterEvdev() override;
36
37 // EventConverterEvdev:
38 void OnFileCanReadWithoutBlocking(int fd) override;
39 bool HasGamepad() const override;
40 void OnDisabled() override;
41
42 // This function process one input_event from evdev.
43 void ProcessEvent(const struct input_event& input);
44
45 private:
46 // This function release all the keys and reset all the axis.
47 void ResetGamepad();
48 void OnButtonChange(unsigned int code,
49 double value,
50 const base::TimeTicks& timestamp);
51 void OnAbsChange(unsigned int code,
52 double value,
53 const base::TimeTicks& timestamp);
54 void OnSync(const base::TimeTicks& timestamp);
55
56 // Sometimes, we want to drop abs values, when we do so, we no longer want to
57 // send gamepad frame event when we see next sync. This flag is set to false
58 // when each frame is sent. It is set to true when Btn or Abs event is sent.
59 bool will_send_frame_;
60
61 // This is the abs_info for this gamepad. It will be used to map abs values.
62 struct input_absinfo abs_info_[ABS_CNT];
63
64 // This is the mapper for this gamepad.
65 GamepadMapper mapper_;
66
67 // Input device file descriptor.
68 ScopedInputDevice input_device_fd_;
69
70 // Callbacks for dispatching events.
71 DeviceEventDispatcherEvdev* dispatcher_;
72
73 DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev);
74 };
75
76 } // namespace ui
77
78 #endif // UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698