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

Unified Diff: ui/events/ozone/gamepad/webgamepad_constants.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/gamepad/webgamepad_constants.h
diff --git a/ui/events/ozone/gamepad/webgamepad_constants.h b/ui/events/ozone/gamepad/webgamepad_constants.h
new file mode 100644
index 0000000000000000000000000000000000000000..132ac1ecb1fea72f25247d49e2a07d9f582ca220
--- /dev/null
+++ b/ui/events/ozone/gamepad/webgamepad_constants.h
@@ -0,0 +1,57 @@
+// 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_WEBGAMEPAD_CONSTANTS_H_
+#define UI_EVENTS_OZONE_GAMEPAD_WEBGAMEPAD_CONSTANTS_H_
+
+#include <stdint.h>
+
+namespace ui {
+
+// We care about three type of gamepad events.
+enum class GamepadEventType { BUTTON, AXIS, FRAME };
+
+// This WebGamepadButtonType matches the index of gamepad button defined in w3c
+// standard gamepad.
+enum WebGamepadButtonType {
+ WG_BUTTON_A = 0,
+ WG_BUTTON_B = 1,
+ WG_BUTTON_X = 2,
+ WG_BUTTON_Y = 3,
+ WG_BUTTON_L1 = 4,
+ WG_BUTTON_R1 = 5,
+ WG_BUTTON_L2 = 6,
+ WG_BUTTON_R2 = 7,
+ WG_BUTTON_SELECT = 8,
+ WG_BUTTON_START = 9,
+ WG_BUTTON_THUMBL = 10,
+ WG_BUTTON_THUMBR = 11,
+ WG_BUTTON_DPAD_UP = 12,
+ WG_BUTTON_DPAD_DOWN = 13,
+ WG_BUTTON_DPAD_LEFT = 14,
+ WG_BUTTON_DPAD_RIGHT = 15,
+ WG_BUTTON_MODE = 16
+};
+
+// This WebGamepadAbsType matches the index of gamepad abs defined in w3c
+// standard gamepad.
+enum WebGamepadAbsType {
+ WG_ABS_X = 0,
+ WG_ABS_Y = 1,
+ WG_ABS_Z = 2,
+ WG_ABS_RZ = 3
+};
+
+constexpr uint16_t kWebGamepadBtnCnt = 17;
scottmg 2017/05/01 18:20:53 Can you make these values in their respective enum
jkwang 2017/05/01 22:21:57 Done.
+constexpr uint16_t kWebGamepadAbsCnt = 4;
+
+// Following constants are used to normalize abs values to web gamepad standard.
+constexpr double kWebGamepadTriggerMin = 0.0;
+constexpr double kWebGamepadTriggerMax = 1.0;
+constexpr double kWebGamepadJoystickMin = -1.0;
+constexpr double kWebGamepadJoystickMax = 1.0;
+
+} // namespace ui
+
+#endif // UI_EVENTS_OZONE_EVDEV_WEBGAMEPAD_CONSTANTS_H_

Powered by Google App Engine
This is Rietveld 408576698