Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
spang
2017/04/13 00:52:19
2017
jkwang
2017/04/19 19:42:23
Done.
| |
| 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 <bitset> | |
|
spang
2017/04/13 00:52:20
unused?
jkwang
2017/04/19 19:42:23
Done.
| |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/files/file_path.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/message_loop/message_pump_libevent.h" | |
| 14 #include "ui/events/devices/input_device.h" | |
| 15 #include "ui/events/event.h" | |
| 16 #include "ui/events/ozone/evdev/event_converter_evdev.h" | |
| 17 #include "ui/events/ozone/evdev/event_device_info.h" | |
| 18 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | |
| 19 #include "ui/events/ozone/evdev/gamepad_mapping.h" | |
| 20 #include "ui/events/ozone/evdev/scoped_input_device.h" | |
| 21 | |
| 22 struct input_event; | |
| 23 | |
| 24 namespace ui { | |
| 25 | |
| 26 class DeviceEventDispatcherEvdev; | |
| 27 | |
| 28 class EVENTS_OZONE_EVDEV_EXPORT GamepadEventConverterEvdev | |
| 29 : public EventConverterEvdev { | |
| 30 public: | |
| 31 GamepadEventConverterEvdev(ScopedInputDevice fd, | |
| 32 base::FilePath path, | |
| 33 int id, | |
| 34 const EventDeviceInfo& info, | |
| 35 DeviceEventDispatcherEvdev* dispatcher); | |
| 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 process one input_event from evdev. | |
| 44 void ProcessEvent(const struct input_event& input); | |
| 45 | |
| 46 private: | |
| 47 // This function release all the keys and reset all the axis. | |
| 48 void ResetGamepad(); | |
| 49 void OnButtonChange(unsigned int code, | |
| 50 double value, | |
| 51 const base::TimeTicks& timestamp); | |
| 52 void OnAbsChange(unsigned int code, | |
| 53 double value, | |
| 54 const base::TimeTicks& timestamp); | |
| 55 void OnSync(const base::TimeTicks& timestamp); | |
| 56 | |
| 57 // Sometimes, we want to drop abs values, when we do so, we no longer want to | |
| 58 // send gamepad frame event when we see next sync. This flag is set to false | |
| 59 // when each frame is sent. It is set to true when Btn or Abs event is sent. | |
| 60 bool will_send_frame_; | |
| 61 | |
| 62 // This is the abs_info for this gamepad. It will be used to map abs values. | |
| 63 struct input_absinfo abs_info_[ABS_CNT]; | |
| 64 | |
| 65 // This is the mapping for this gamepad. | |
| 66 const std::vector<GamepadMappingEntry>* gamepad_mapping_; | |
| 67 | |
| 68 // Input device file descriptor. | |
| 69 ScopedInputDevice input_device_fd_; | |
| 70 | |
| 71 // Callbacks for dispatching events. | |
| 72 DeviceEventDispatcherEvdev* dispatcher_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev); | |
| 75 }; | |
| 76 | |
| 77 } // namespace ui | |
| 78 | |
| 79 #endif // UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_ | |
| OLD | NEW |