Chromium Code Reviews| OLD | NEW |
|---|---|
| (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. | |
|
scottmg
2017/05/01 18:20:52
process -> processes
jkwang
2017/05/01 22:21:57
Done.
| |
| 43 void ProcessEvent(const struct input_event& input); | |
| 44 | |
| 45 private: | |
| 46 // This function release all the keys and reset all the axis. | |
|
scottmg
2017/05/01 18:20:52
release -> releases, reset -> resets, axis -> axes
jkwang
2017/05/01 22:21:57
Done.
| |
| 47 void ResetGamepad(); | |
| 48 | |
| 49 // This function read current gamepad status and resync the gamepad. | |
|
scottmg
2017/05/01 18:20:52
read -> reads, resync -> resyncs.
jkwang
2017/05/01 22:21:57
Done.
| |
| 50 void ResyncGamepad(); | |
| 51 | |
| 52 void OnButtonChange(unsigned int code, | |
| 53 double value, | |
| 54 const base::TimeTicks& timestamp); | |
| 55 void OnAbsChange(unsigned int code, | |
| 56 double value, | |
| 57 const base::TimeTicks& timestamp); | |
| 58 void OnSync(const base::TimeTicks& timestamp); | |
| 59 | |
| 60 // Sometimes, we want to drop abs values, when we do so, we no longer want to | |
| 61 // send gamepad frame event when we see next sync. This flag is set to false | |
| 62 // when each frame is sent. It is set to true when Btn or Abs event is sent. | |
| 63 bool will_send_frame_; | |
| 64 | |
| 65 // This is the abs_info for this gamepad. It will be used to map abs values. | |
| 66 struct input_absinfo abs_info_[ABS_CNT]; | |
| 67 | |
| 68 // This is the mapper for this gamepad. | |
|
scottmg
2017/05/01 18:20:52
This comment doesn't add any value.
jkwang
2017/05/01 22:21:57
Done.
| |
| 69 GamepadMapper mapper_; | |
| 70 | |
| 71 // Input device file descriptor. | |
| 72 ScopedInputDevice input_device_fd_; | |
| 73 | |
| 74 // Callbacks for dispatching events. | |
| 75 DeviceEventDispatcherEvdev* dispatcher_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev); | |
| 78 }; | |
| 79 | |
| 80 } // namespace ui | |
| 81 | |
| 82 #endif // UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_ | |
| OLD | NEW |