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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/evdev/gamepad_event_converter_evdev.h
diff --git a/ui/events/ozone/evdev/gamepad_event_converter_evdev.h b/ui/events/ozone/evdev/gamepad_event_converter_evdev.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8269014c0cdb1a28f057c4f5b8c9eeabc849f34
--- /dev/null
+++ b/ui/events/ozone/evdev/gamepad_event_converter_evdev.h
@@ -0,0 +1,82 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
+#define UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
+
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "ui/events/devices/input_device.h"
+#include "ui/events/event.h"
+#include "ui/events/ozone/evdev/event_converter_evdev.h"
+#include "ui/events/ozone/evdev/event_device_info.h"
+#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
+#include "ui/events/ozone/evdev/scoped_input_device.h"
+#include "ui/events/ozone/gamepad/gamepad_mapping.h"
+
+struct input_event;
+
+namespace ui {
+
+class DeviceEventDispatcherEvdev;
+
+class EVENTS_OZONE_EVDEV_EXPORT GamepadEventConverterEvdev
+ : public EventConverterEvdev {
+ public:
+ GamepadEventConverterEvdev(ScopedInputDevice fd,
+ base::FilePath path,
+ int id,
+ const EventDeviceInfo& info,
+ DeviceEventDispatcherEvdev* dispatcher);
+
+ ~GamepadEventConverterEvdev() override;
+
+ // EventConverterEvdev:
+ void OnFileCanReadWithoutBlocking(int fd) override;
+ bool HasGamepad() const override;
+ void OnDisabled() override;
+
+ // 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.
+ void ProcessEvent(const struct input_event& input);
+
+ private:
+ // 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.
+ void ResetGamepad();
+
+ // 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.
+ void ResyncGamepad();
+
+ void OnButtonChange(unsigned int code,
+ double value,
+ const base::TimeTicks& timestamp);
+ void OnAbsChange(unsigned int code,
+ double value,
+ const base::TimeTicks& timestamp);
+ void OnSync(const base::TimeTicks& timestamp);
+
+ // Sometimes, we want to drop abs values, when we do so, we no longer want to
+ // send gamepad frame event when we see next sync. This flag is set to false
+ // when each frame is sent. It is set to true when Btn or Abs event is sent.
+ bool will_send_frame_;
+
+ // This is the abs_info for this gamepad. It will be used to map abs values.
+ struct input_absinfo abs_info_[ABS_CNT];
+
+ // 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.
+ GamepadMapper mapper_;
+
+ // Input device file descriptor.
+ ScopedInputDevice input_device_fd_;
+
+ // Callbacks for dispatching events.
+ DeviceEventDispatcherEvdev* dispatcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_

Powered by Google App Engine
This is Rietveld 408576698