blob: 87698bb3b1a3c4d7bcf072d792711465e4155c70 [file] [log] [blame]
Aldo Culquicondor89d943a2018-07-04 16:31:011// 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 Grantf47c6e52019-01-02 20:05:119#include "chrome/browser/vr/vr_base_export.h"
Aldo Culquicondor89d943a2018-07-04 16:31:0110#include "ui/gfx/geometry/point_f.h"
11
12namespace vr {
13
Christopher Grantf47c6e52019-01-02 20:05:1114class VR_BASE_EXPORT InputEvent {
Aldo Culquicondor89d943a2018-07-04 16:31:0115 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 Culquicondor570c3232018-07-23 16:46:4733 kMenuButtonClicked,
34 kMenuButtonTypeFirst = kMenuButtonClicked,
35 kMenuButtonLongPressStart,
36 kMenuButtonLongPressEnd,
37 kMenuButtonTypeLast = kMenuButtonLongPressEnd,
38
Aldo Culquicondor89d943a2018-07-04 16:31:0139 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 Culquicondor570c3232018-07-23 16:46:4765 static bool IsMenuButtonEventType(InputEvent::Type type) {
66 return kMenuButtonTypeFirst <= type && type <= kMenuButtonTypeLast;
67 }
68
Aldo Culquicondor89d943a2018-07-04 16:31:0169 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_