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

Unified Diff: ui/events/event.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/event.h
diff --git a/ui/events/event.h b/ui/events/event.h
index 16dce04e3a44e5133e15b5ddc442d38b83d6c56f..f69b416cf4eff159b3b11492c6bc0db4f51daced 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -35,6 +35,7 @@ class Transform;
namespace ui {
class CancelModeEvent;
class EventTarget;
+class GamepadEvent;
class KeyEvent;
class LocatedEvent;
class MouseEvent;
@@ -117,6 +118,12 @@ class EVENTS_EXPORT Event {
return type_ == ET_CANCEL_MODE;
}
+ bool IsGamepadEvent() const {
+ return type_ == ET_GAMEPAD_BTN_PRESSED ||
+ type_ == ET_GAMEPAD_BTN_RELEASED || type_ == ET_GAMEPAD_ABS_MOVED ||
+ type_ == ET_GAMEPAD_FRAME;
+ }
+
bool IsKeyEvent() const {
return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED;
}
@@ -241,6 +248,9 @@ class EVENTS_EXPORT Event {
GestureEvent* AsGestureEvent();
const GestureEvent* AsGestureEvent() const;
+ GamepadEvent* AsGamepadEvent();
+ const GamepadEvent* AsGamepadEvent() const;
+
// Convenience methods to cast |this| to a KeyEvent. IsKeyEvent()
// must be true as a precondition to calling these methods.
KeyEvent* AsKeyEvent();
@@ -760,6 +770,26 @@ class EVENTS_EXPORT PointerEvent : public LocatedEvent {
PointerDetails details_;
};
+// A Gamepad event is very straignt forward. It contains the event type,
+// timestamp, event code and value. The code and vaule should follow w3c
+// "standard" gamepad.
+class EVENTS_EXPORT GamepadEvent : public Event {
+ public:
+ GamepadEvent(EventType type,
+ double value,
+ uint16_t code,
+ base::TimeTicks timestamp);
+
+ GamepadEvent(const GamepadEvent& gamepad_event);
+
+ double get_value() const { return value_; }
+ uint16_t get_code() const { return code_; }
+
+ private:
+ double value_;
+ uint16_t code_;
sadrul 2017/04/12 18:03:58 Can you document what |value_| and |code_| represe
jkwang 2017/04/12 20:51:55 Interface is here. interface Gamepad { readonl
+};
sadrul 2017/04/10 18:14:05 I feel like this should simply be a PointerEvent,
jkwang 2017/04/10 18:19:08 Would it be confusing?
dtapuska 2017/04/10 19:13:35 Game pad logically has no pointer position does it
jkwang 2017/04/10 20:07:47 Mostly, gamepad report EV_ABS and EV_KEY. So mappi
+
// A KeyEvent is really two distinct classes, melded together due to the
// DOM legacy of Windows key events: a keystroke event (is_char_ == false),
// or a character event (is_char_ == true).

Powered by Google App Engine
This is Rietveld 408576698