OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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_ANDROID_VR_SHELL_VR_GESTURE_H_ | |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ | |
7 | |
8 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" | |
9 | |
10 namespace vr_shell { | |
11 | |
12 typedef enum { | |
13 GESTURE_DIRECTION_UP, | |
14 GESTURE_DIRECTION_DOWN, | |
15 GESTURE_DIRECTION_LEFT, | |
16 GESTURE_DIRECTION_RIGHT | |
17 } gesture_direction; | |
18 | |
19 typedef struct { | |
20 float dx, dy, dz; | |
21 float x, y; | |
22 float ordinal_dx, ordinal_dy, ordinal_dz; | |
23 int type; | |
24 } GestureAngularMove; | |
tdresser
2016/09/23 17:45:17
Throughout this file, it looks like we should be u
asimjour
2016/09/23 19:56:31
Done.
| |
25 | |
26 typedef struct { | |
27 float dx, dy; | |
28 float ordinal_dx, ordinal_dy; | |
29 // If set, stop_fling means that this scroll should stop flinging, thus | |
30 // if an interpreter suppresses it for any reason (e.g., rounds the size | |
31 // down to 0, thus making it a noop), it will replace it with a Fling | |
32 // TAP_DOWN gesture | |
33 int state; | |
34 unsigned stop_fling : 1; | |
35 float initial_touch_pos_x; | |
36 float initial_touch_pos_y; | |
37 } GestureScroll; | |
38 | |
39 typedef struct { | |
40 // fling velocity (valid when fling_state is GESTURES_FLING_START): | |
41 float vx, vy; | |
42 float ordinal_vx, ordinal_vy; | |
43 unsigned fling_state : 1; // GESTURES_FLING_START or GESTURES_FLING_TAP_DOWN | |
44 } GestureFling; | |
45 | |
46 typedef struct { | |
47 // zoom size; dz=1 means no zoom, dz < 1 means zoom-out, dz > 1 means zoom-in | |
48 float dz; | |
49 } GestureZoom; | |
50 | |
51 typedef struct { | |
52 // If a bit is set in both down and up, client should process down first | |
53 int x; | |
54 int y; | |
55 unsigned down; // bit field, use GESTURES_BUTTON_* | |
56 unsigned up; // bit field, use GESTURES_BUTTON_* | |
57 } GestureButtonsChange; | |
58 | |
59 enum GestureType { | |
60 kGestureTypeNull, | |
61 kGestureTypeAngularMove, | |
62 kGestureTypeScroll, | |
63 kGestureTypeButtonsChange, | |
64 kGestureTypeFling, | |
65 kGestureTypeZoom, | |
66 }; | |
67 | |
68 struct VrGesture { | |
69 VrGesture() : type(kGestureTypeNull) {} | |
70 VrGesture(const GestureAngularMove&, | |
71 int64_t start, | |
72 int64_t end, | |
73 gvr::Quatf quat) | |
74 : start_time(start), | |
75 end_time(end), | |
76 type(kGestureTypeAngularMove), | |
77 quat(quat) {} | |
78 VrGesture(const GestureScroll&, | |
79 int64_t start, | |
80 int64_t end, | |
81 float dx, | |
82 float dy, | |
83 int state, | |
84 gvr::Quatf quat) | |
85 : start_time(start), end_time(end), type(kGestureTypeScroll), quat(quat) { | |
86 details.scroll.ordinal_dx = details.scroll.dx = dx; | |
87 details.scroll.ordinal_dy = details.scroll.dy = dy; | |
88 details.scroll.state = state; | |
89 details.scroll.stop_fling = 0; | |
90 } | |
91 VrGesture(const GestureButtonsChange&, | |
92 int64_t start, | |
93 int64_t end, | |
94 unsigned down, | |
95 unsigned up, | |
96 gvr::Quatf quat) | |
97 : start_time(start), | |
98 end_time(end), | |
99 type(kGestureTypeButtonsChange), | |
100 quat(quat) { | |
101 details.buttons.down = down; | |
102 details.buttons.up = up; | |
103 details.buttons.x = 0; | |
104 details.buttons.y = 0; | |
105 } | |
106 VrGesture(const GestureFling&, | |
107 int64_t start, | |
108 int64_t end, | |
109 float vx, | |
110 float vy, | |
111 unsigned state, | |
112 gvr::Quatf quat) | |
113 : start_time(start), end_time(end), type(kGestureTypeFling), quat(quat) { | |
114 details.fling.ordinal_vx = details.fling.vx = vx; | |
115 details.fling.ordinal_vy = details.fling.vy = vy; | |
116 details.fling.fling_state = state; | |
117 } | |
118 VrGesture(const GestureZoom&, | |
119 int64_t start, | |
120 int64_t end, | |
121 float dz, | |
122 gvr::Quatf quat) | |
123 : start_time(start), end_time(end), type(kGestureTypeZoom), quat(quat) { | |
124 details.zoom.dz = dz; | |
125 } | |
126 | |
127 int64_t start_time, end_time; | |
128 enum GestureType type; | |
129 union { | |
130 GestureScroll scroll; | |
131 GestureButtonsChange buttons; | |
132 GestureFling fling; | |
133 GestureZoom zoom; | |
134 GestureAngularMove move; | |
135 } details; | |
136 gvr::Quatf quat; | |
137 gvr::Vec2f velocity; | |
138 gvr::Vec2f displacement; | |
139 gesture_direction direction; | |
140 }; | |
141 | |
142 const GestureScroll kGestureScroll = {0, 0, 0, 0, 0, 0}; | |
143 const GestureButtonsChange kGestureButtonsChange = {0, 0, 0, 0}; | |
144 const GestureAngularMove kGestureAngularMove = {0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
145 const GestureZoom kGestureZoom = {0}; | |
146 | |
147 } // namespace vr_shell | |
148 | |
149 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ | |
OLD | NEW |