Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_EVENTS_EVENT_H_ | 5 #ifndef UI_EVENTS_EVENT_H_ |
| 6 #define UI_EVENTS_EVENT_H_ | 6 #define UI_EVENTS_EVENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "ui/gfx/geometry/point_conversions.h" | 28 #include "ui/gfx/geometry/point_conversions.h" |
| 29 #include "ui/latency/latency_info.h" | 29 #include "ui/latency/latency_info.h" |
| 30 | 30 |
| 31 namespace gfx { | 31 namespace gfx { |
| 32 class Transform; | 32 class Transform; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace ui { | 35 namespace ui { |
| 36 class CancelModeEvent; | 36 class CancelModeEvent; |
| 37 class EventTarget; | 37 class EventTarget; |
| 38 class GamepadEvent; | |
| 38 class KeyEvent; | 39 class KeyEvent; |
| 39 class LocatedEvent; | 40 class LocatedEvent; |
| 40 class MouseEvent; | 41 class MouseEvent; |
| 41 class MouseWheelEvent; | 42 class MouseWheelEvent; |
| 42 class PointerEvent; | 43 class PointerEvent; |
| 43 class ScrollEvent; | 44 class ScrollEvent; |
| 44 class TouchEvent; | 45 class TouchEvent; |
| 45 enum class DomCode; | 46 enum class DomCode; |
| 46 class Event; | 47 class Event; |
| 47 class MouseWheelEvent; | 48 class MouseWheelEvent; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } | 111 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } |
| 111 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } | 112 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } |
| 112 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; } | 113 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; } |
| 113 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; } | 114 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; } |
| 114 bool IsCapsLockOn() const { return (flags_ & EF_CAPS_LOCK_ON) != 0; } | 115 bool IsCapsLockOn() const { return (flags_ & EF_CAPS_LOCK_ON) != 0; } |
| 115 | 116 |
| 116 bool IsCancelModeEvent() const { | 117 bool IsCancelModeEvent() const { |
| 117 return type_ == ET_CANCEL_MODE; | 118 return type_ == ET_CANCEL_MODE; |
| 118 } | 119 } |
| 119 | 120 |
| 121 bool IsGamepadEvent() const { | |
| 122 return type_ == ET_GAMEPAD_BTN_PRESSED || | |
| 123 type_ == ET_GAMEPAD_BTN_RELEASED || type_ == ET_GAMEPAD_ABS_MOVED || | |
| 124 type_ == ET_GAMEPAD_FRAME; | |
| 125 } | |
| 126 | |
| 120 bool IsKeyEvent() const { | 127 bool IsKeyEvent() const { |
| 121 return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED; | 128 return type_ == ET_KEY_PRESSED || type_ == ET_KEY_RELEASED; |
| 122 } | 129 } |
| 123 | 130 |
| 124 bool IsMouseEvent() const { | 131 bool IsMouseEvent() const { |
| 125 return type_ == ET_MOUSE_PRESSED || | 132 return type_ == ET_MOUSE_PRESSED || |
| 126 type_ == ET_MOUSE_DRAGGED || | 133 type_ == ET_MOUSE_DRAGGED || |
| 127 type_ == ET_MOUSE_RELEASED || | 134 type_ == ET_MOUSE_RELEASED || |
| 128 type_ == ET_MOUSE_MOVED || | 135 type_ == ET_MOUSE_MOVED || |
| 129 type_ == ET_MOUSE_ENTERED || | 136 type_ == ET_MOUSE_ENTERED || |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // IsCancelModeEvent() must be true as a precondition to calling these | 241 // IsCancelModeEvent() must be true as a precondition to calling these |
| 235 // methods. | 242 // methods. |
| 236 CancelModeEvent* AsCancelModeEvent(); | 243 CancelModeEvent* AsCancelModeEvent(); |
| 237 const CancelModeEvent* AsCancelModeEvent() const; | 244 const CancelModeEvent* AsCancelModeEvent() const; |
| 238 | 245 |
| 239 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() | 246 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() |
| 240 // must be true as a precondition to calling these methods. | 247 // must be true as a precondition to calling these methods. |
| 241 GestureEvent* AsGestureEvent(); | 248 GestureEvent* AsGestureEvent(); |
| 242 const GestureEvent* AsGestureEvent() const; | 249 const GestureEvent* AsGestureEvent() const; |
| 243 | 250 |
| 251 GamepadEvent* AsGamepadEvent(); | |
| 252 const GamepadEvent* AsGamepadEvent() const; | |
| 253 | |
| 244 // Convenience methods to cast |this| to a KeyEvent. IsKeyEvent() | 254 // Convenience methods to cast |this| to a KeyEvent. IsKeyEvent() |
| 245 // must be true as a precondition to calling these methods. | 255 // must be true as a precondition to calling these methods. |
| 246 KeyEvent* AsKeyEvent(); | 256 KeyEvent* AsKeyEvent(); |
| 247 const KeyEvent* AsKeyEvent() const; | 257 const KeyEvent* AsKeyEvent() const; |
| 248 | 258 |
| 249 // Convenience methods to cast |this| to a LocatedEvent. IsLocatedEvent() | 259 // Convenience methods to cast |this| to a LocatedEvent. IsLocatedEvent() |
| 250 // must be true as a precondition to calling these methods. | 260 // must be true as a precondition to calling these methods. |
| 251 LocatedEvent* AsLocatedEvent(); | 261 LocatedEvent* AsLocatedEvent(); |
| 252 const LocatedEvent* AsLocatedEvent() const; | 262 const LocatedEvent* AsLocatedEvent() const; |
| 253 | 263 |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 | 763 |
| 754 int changed_button_flags() const { return changed_button_flags_; } | 764 int changed_button_flags() const { return changed_button_flags_; } |
| 755 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } | 765 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } |
| 756 const PointerDetails& pointer_details() const { return details_; } | 766 const PointerDetails& pointer_details() const { return details_; } |
| 757 | 767 |
| 758 private: | 768 private: |
| 759 int changed_button_flags_; | 769 int changed_button_flags_; |
| 760 PointerDetails details_; | 770 PointerDetails details_; |
| 761 }; | 771 }; |
| 762 | 772 |
| 773 // A Gamepad event is very straignt forward. It contains the event type, | |
| 774 // timestamp, event code and value. The code and vaule should follow w3c | |
| 775 // "standard" gamepad. | |
| 776 class EVENTS_EXPORT GamepadEvent : public Event { | |
| 777 public: | |
| 778 GamepadEvent(EventType type, | |
| 779 double value, | |
| 780 uint16_t code, | |
| 781 base::TimeTicks timestamp); | |
| 782 | |
| 783 GamepadEvent(const GamepadEvent& gamepad_event); | |
| 784 | |
| 785 double get_value() const { return value_; } | |
| 786 uint16_t get_code() const { return code_; } | |
| 787 | |
| 788 private: | |
| 789 double value_; | |
| 790 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
| |
| 791 }; | |
|
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
| |
| 792 | |
| 763 // A KeyEvent is really two distinct classes, melded together due to the | 793 // A KeyEvent is really two distinct classes, melded together due to the |
| 764 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), | 794 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), |
| 765 // or a character event (is_char_ == true). | 795 // or a character event (is_char_ == true). |
| 766 // | 796 // |
| 767 // For a keystroke event, | 797 // For a keystroke event, |
| 768 // -- |bool is_char_| is false. | 798 // -- |bool is_char_| is false. |
| 769 // -- |EventType Event::type()| can be ET_KEY_PRESSED or ET_KEY_RELEASED. | 799 // -- |EventType Event::type()| can be ET_KEY_PRESSED or ET_KEY_RELEASED. |
| 770 // -- |DomCode code_| and |int Event::flags()| represent the physical key event. | 800 // -- |DomCode code_| and |int Event::flags()| represent the physical key event. |
| 771 // - code_ is a platform-independent representation of the physical key, | 801 // - code_ is a platform-independent representation of the physical key, |
| 772 // based on DOM UI Events KeyboardEvent |code| values. It does not | 802 // based on DOM UI Events KeyboardEvent |code| values. It does not |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1048 // dispatched. This field gets a non-zero value only for gestures that are | 1078 // dispatched. This field gets a non-zero value only for gestures that are |
| 1049 // released through TouchDispositionGestureFilter::SendGesture. The gesture | 1079 // released through TouchDispositionGestureFilter::SendGesture. The gesture |
| 1050 // events that aren't fired directly in response to processing a touch-event | 1080 // events that aren't fired directly in response to processing a touch-event |
| 1051 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. | 1081 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. |
| 1052 uint32_t unique_touch_event_id_; | 1082 uint32_t unique_touch_event_id_; |
| 1053 }; | 1083 }; |
| 1054 | 1084 |
| 1055 } // namespace ui | 1085 } // namespace ui |
| 1056 | 1086 |
| 1057 #endif // UI_EVENTS_EVENT_H_ | 1087 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |