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