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

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, 7 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 #include "ui/events/ozone/gamepad/webgamepad_constants.h"
20
21 struct input_event;
22
23 namespace ui {
24
25 class DeviceEventDispatcherEvdev;
26
27 class EVENTS_OZONE_EVDEV_EXPORT GamepadEventConverterEvdev
28 : public EventConverterEvdev {
29 public:
30 GamepadEventConverterEvdev(ScopedInputDevice fd,
31 base::FilePath path,
32 int id,
33 const EventDeviceInfo& info,
34 DeviceEventDispatcherEvdev* dispatcher);
35
36 ~GamepadEventConverterEvdev() override;
37
38 // EventConverterEvdev:
39 void OnFileCanReadWithoutBlocking(int fd) override;
40 bool HasGamepad() const override;
41 void OnDisabled() override;
42
43 // This function processes one input_event from evdev.
44 void ProcessEvent(const struct input_event& input,
45 const base::TimeTicks& timestamp);
46
47 private:
48 // This function releases all the keys and resets all the axises.
49 void ResetGamepad();
50
51 // This function reads current gamepad status and resyncs the gamepad.
52 void ResyncGamepad();
53
54 void OnButtonChange(unsigned int code,
55 double value,
56 const base::TimeTicks& timestamp);
57 void OnAbsChange(unsigned int code,
58 double value,
59 const base::TimeTicks& timestamp);
60 void OnSync(const base::TimeTicks& timestamp);
61
62 // Sometimes, we want to drop abs values, when we do so, we no longer want to
63 // send gamepad frame event when we see next sync. This flag is set to false
64 // when each frame is sent. It is set to true when Btn or Abs event is sent.
65 bool will_send_frame_;
66
67 // Internal representation of all axis information.
68 class AxisInfos;
69 AxisInfos* axis_infos_;
spang 2017/05/05 15:37:43 Why is this a pointer? You should be able to put t
jkwang 2017/05/05 21:32:57 Putting array here means we need a declaration of
70
71 // These values keeps the state of previous hat.
72 bool last_hat_left_press_;
73 bool last_hat_right_press_;
74 bool last_hat_up_press_;
75 bool last_hat_down_press_;
76
77 GamepadMapper mapper_;
78
79 // Input device file descriptor.
80 ScopedInputDevice input_device_fd_;
81
82 // Callbacks for dispatching events.
83 DeviceEventDispatcherEvdev* dispatcher_;
84
85 DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev);
86 };
87
88 } // namespace ui
89
90 #endif // UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698