Aldo Culquicondor | 89d943a | 2018-07-04 16:31:01 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_VR_INPUT_EVENT_H_ |
| 6 | #define CHROME_BROWSER_VR_INPUT_EVENT_H_ |
| 7 | |
| 8 | #include "base/time/time.h" |
Christopher Grant | f47c6e5 | 2019-01-02 20:05:11 | [diff] [blame] | 9 | #include "chrome/browser/vr/vr_base_export.h" |
Aldo Culquicondor | 89d943a | 2018-07-04 16:31:01 | [diff] [blame] | 10 | #include "ui/gfx/geometry/point_f.h" |
| 11 | |
| 12 | namespace vr { |
| 13 | |
Christopher Grant | f47c6e5 | 2019-01-02 20:05:11 | [diff] [blame] | 14 | class VR_BASE_EXPORT InputEvent { |
Aldo Culquicondor | 89d943a | 2018-07-04 16:31:01 | [diff] [blame] | 15 | public: |
| 16 | enum Type { |
| 17 | kTypeUndefined = -1, |
| 18 | |
| 19 | kHoverEnter, |
| 20 | kTypeFirst = kHoverEnter, |
| 21 | kHoverLeave, |
| 22 | kHoverMove, |
| 23 | kButtonDown, |
| 24 | kButtonUp, |
| 25 | kMove, |
| 26 | kFlingCancel, |
| 27 | kScrollBegin, |
| 28 | kScrollTypeFirst = kScrollBegin, |
| 29 | kScrollUpdate, |
| 30 | kScrollEnd, |
| 31 | kScrollTypeLast = kScrollEnd, |
| 32 | |
Aldo Culquicondor | 570c323 | 2018-07-23 16:46:47 | [diff] [blame] | 33 | kMenuButtonClicked, |
| 34 | kMenuButtonTypeFirst = kMenuButtonClicked, |
| 35 | kMenuButtonLongPressStart, |
| 36 | kMenuButtonLongPressEnd, |
| 37 | kMenuButtonTypeLast = kMenuButtonLongPressEnd, |
| 38 | |
Aldo Culquicondor | 89d943a | 2018-07-04 16:31:01 | [diff] [blame] | 39 | kNumVrInputEventTypes |
| 40 | }; |
| 41 | |
| 42 | explicit InputEvent(Type type); |
| 43 | virtual ~InputEvent(); |
| 44 | |
| 45 | Type type() const { return type_; } |
| 46 | |
| 47 | base::TimeTicks time_stamp() const { return time_stamp_; } |
| 48 | |
| 49 | void set_time_stamp(base::TimeTicks time_stamp) { time_stamp_ = time_stamp; } |
| 50 | |
| 51 | gfx::PointF position_in_widget() const { return position_in_widget_; } |
| 52 | |
| 53 | void set_position_in_widget(const gfx::PointF& position) { |
| 54 | position_in_widget_ = position; |
| 55 | } |
| 56 | |
| 57 | void SetPositionInWidget(float x, float y) { |
| 58 | position_in_widget_ = gfx::PointF(x, y); |
| 59 | } |
| 60 | |
| 61 | static bool IsScrollEventType(InputEvent::Type type) { |
| 62 | return kScrollTypeFirst <= type && type <= kScrollTypeLast; |
| 63 | } |
| 64 | |
Aldo Culquicondor | 570c323 | 2018-07-23 16:46:47 | [diff] [blame] | 65 | static bool IsMenuButtonEventType(InputEvent::Type type) { |
| 66 | return kMenuButtonTypeFirst <= type && type <= kMenuButtonTypeLast; |
| 67 | } |
| 68 | |
Aldo Culquicondor | 89d943a | 2018-07-04 16:31:01 | [diff] [blame] | 69 | struct { |
| 70 | float delta_x; |
| 71 | float delta_y; |
| 72 | } scroll_data; |
| 73 | |
| 74 | private: |
| 75 | Type type_; |
| 76 | base::TimeTicks time_stamp_; |
| 77 | gfx::PointF position_in_widget_; |
| 78 | }; |
| 79 | |
| 80 | } // namespace vr |
| 81 | |
| 82 | #endif // CHROME_BROWSER_VR_INPUT_EVENT_H_ |