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

Unified Diff: ui/events/ozone/evdev/gamepad_mapping.h

Issue 2805793002: ozone: evdev: Add gamepad support (Closed)
Patch Set: 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_mapping.h
diff --git a/ui/events/ozone/evdev/gamepad_mapping.h b/ui/events/ozone/evdev/gamepad_mapping.h
new file mode 100644
index 0000000000000000000000000000000000000000..17357853e7f57e61ab477a8252267e3904f4e502
--- /dev/null
+++ b/ui/events/ozone/evdev/gamepad_mapping.h
@@ -0,0 +1,35 @@
+// Copyright (c) 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_MAPPING_H_
+#define UI_EVENTS_OZONE_GAMEPAD_MAPPING_H_
+
+#include <linux/input.h>
+#include <vector>
+#include "base/logging.h"
+
+namespace ui {
+
+// The following HATX and HATY is not part of web gamepad definition, but we
+// need to specially treat them cause HAT_Y can be mapped to DPAD_UP or
+// DPAD_DOWN, and HAT_X can be mapped to DAPD_LEFT or DPAD_RIGHT.
+constexpr int kHAT_X = 4;
+constexpr int kHAT_Y = 5;
+
+enum class GamepadEventType { BUTTON, AXIS };
+
+// This is the mapping entry to map evdev event to webgamepad event.
+struct GamepadMappingEntry {
+ uint16_t evdev_type;
+ uint16_t evdev_code;
+ GamepadEventType mapped_type;
+ uint16_t mapped_code;
+};
+
+// This function will return the a set of mapping for the vendor_id/product_id.
+std::vector<GamepadMappingEntry>* GetGamepadMapping(uint16_t vendor_id,
+ uint16_t product_id);
+}; // namespace ui
+
+#endif // UI_EVENTS_OZONE_GAMEPAD_MAPPING_H_

Powered by Google App Engine
This is Rietveld 408576698