Index: ui/events/ozone/gamepad/gamepad_mapping.h |
diff --git a/ui/events/ozone/gamepad/gamepad_mapping.h b/ui/events/ozone/gamepad/gamepad_mapping.h |
index e864e977e7ae4ff3ece2242e9d9a7749b21a6de3..14d508b48709f6cdcd6f4e78c3883065c175a9a4 100644 |
--- a/ui/events/ozone/gamepad/gamepad_mapping.h |
+++ b/ui/events/ozone/gamepad/gamepad_mapping.h |
@@ -9,19 +9,47 @@ |
namespace ui { |
+class EventDeviceInfo; |
+ |
// 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; |
-typedef bool (*GamepadMapper)(uint16_t key, |
- uint16_t code, |
- GamepadEventType* mapped_type, |
- uint16_t* mapped_code); |
+// KeyMap maps evdev key code to web gamepad code. |
+struct KeyMapEntry { |
+ uint16_t evdev_code; |
+ uint16_t mapped_code; |
+}; |
+ |
+// AbsMap maps evdev abs code to web gamepad (type, code). |
+struct AbsMapEntry { |
+ uint16_t evdev_code; |
+ GamepadEventType mapped_type; |
+ uint16_t mapped_code; |
+}; |
+ |
+using KeyMapType = const KeyMapEntry[]; |
+using AbsMapType = const AbsMapEntry[]; |
+ |
+#define TO_BTN(code, mapped_code) \ |
+ { code, GamepadEventType::BUTTON, mapped_code } |
+ |
+#define TO_ABS(code, mapped_code) \ |
+ { code, GamepadEventType::AXIS, mapped_code } |
+ |
+class GamepadMapper { |
+ public: |
+ virtual bool operator()(uint16_t key, |
+ uint16_t code, |
spang
2017/06/01 05:08:12
overloading operator() is going to cause syntactic
jkwang
2017/06/02 22:03:51
Done.
|
+ GamepadEventType* mapped_type, |
+ uint16_t* mapped_code) = 0; |
+ virtual ~GamepadMapper() {} |
+}; |
// This function gets the best mapper for the gamepad vendor_id and product_id. |
-GamepadMapper GetGamepadMapper(uint16_t vendor_id, uint16_t product_id); |
+GamepadMapper* GetGamepadMapper(const EventDeviceInfo& devinfo); |
} // namespace ui |