Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: content/public/browser/android/vr_gesture.h

Issue 2350253004: Controller support for VrShell (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
bshe 2016/09/21 15:18:41 nit: s/CHROME/CONTENT
asimjour 2016/09/22 14:48:37 Done.
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_
7
8 typedef enum {
9 GESTURE_DIRECTION_UP,
10 GESTURE_DIRECTION_DOWN,
11 GESTURE_DIRECTION_LEFT,
12 GESTURE_DIRECTION_RIGHT
13 } gesture_direction;
14
15 typedef struct quatf {
mthiesse 2016/09/21 17:43:27 I don't think you need this here at all. I don't t
asimjour 2016/09/22 14:48:37 considering that I'm moving this file to chrome/br
16 /// qx, qy, qz are the vector component.
17 float qx;
18 float qy;
19 float qz;
20 /// qw is the linelar component.
mthiesse 2016/09/21 17:43:28 nit: linear?
asimjour 2016/09/22 14:48:37 Done.
21 float qw;
22 } quatf;
23
24 /// A floating point 2D vector.
25 typedef struct vec2f {
mthiesse 2016/09/21 17:43:27 use gfx::Vector2d
asimjour 2016/09/22 14:48:37 Replaced with gvr_vec2f
26 float x;
27 float y;
28 } vec2f;
29
30 typedef struct {
31 float dx, dy, dz;
32 float x, y;
33 float ordinal_dx, ordinal_dy, ordinal_dz;
34 int type;
35 } GestureAngularMove;
36
37 typedef struct {
38 float dx, dy;
39 float ordinal_dx, ordinal_dy;
40 // If set, stop_fling means that this scroll should stop flinging, thus
41 // if an interpreter suppresses it for any reason (e.g., rounds the size
42 // down to 0, thus making it a noop), it will replace it with a Fling
43 // TAP_DOWN gesture
44 int state;
45 unsigned stop_fling : 1;
46 float initial_touch_pos_x;
47 float initial_touch_pos_y;
48 } GestureScroll;
49
50 typedef struct {
51 // fling velocity (valid when fling_state is GESTURES_FLING_START):
52 float vx, vy;
53 float ordinal_vx, ordinal_vy;
54 unsigned fling_state : 1; // GESTURES_FLING_START or GESTURES_FLING_TAP_DOWN
55 } GestureFling;
56
57 typedef struct {
58 // zoom size; dz=1 means no zoom, dz < 1 means zoom-out, dz > 1 means zoom-in
59 float dz;
60 } GestureZoom;
61
62 typedef struct {
63 // If a bit is set in both down and up, client should process down first
64 int x;
65 int y;
66 unsigned down; // bit field, use GESTURES_BUTTON_*
67 unsigned up; // bit field, use GESTURES_BUTTON_*
68 } GestureButtonsChange;
69
70 enum GestureType {
71 kGestureTypeNull,
72 kGestureTypeAngularMove,
73 kGestureTypeScroll,
74 kGestureTypeButtonsChange,
75 kGestureTypeFling,
76 kGestureTypeZoom,
77 };
78
79 enum GestureEventType {
80 GESTURE_EVENT_TYPE_SCROLL_START,
81 GESTURE_EVENT_TYPE_SCROLL_BY,
82 GESTURE_EVENT_TYPE_SCROLL_END,
83 GESTURE_EVENT_TYPE_PINCH_BEGIN,
84 GESTURE_EVENT_TYPE_PINCH_BY,
85 GESTURE_EVENT_TYPE_PINCH_END,
86 };
87
88 struct VrGesture {
mthiesse 2016/09/21 17:43:28 I don't think this should live in the content laye
asimjour 2016/09/22 14:48:37 You are right, it used to be included in vr_conten
89 VrGesture() : type(kGestureTypeNull) {}
90 VrGesture(const GestureAngularMove&, int64_t start, int64_t end, quatf quat)
91 : start_time(start),
92 end_time(end),
93 type(kGestureTypeAngularMove),
94 quat(quat) {}
95 VrGesture(const GestureScroll&,
96 int64_t start,
97 int64_t end,
98 float dx,
99 float dy,
100 int state,
101 quatf quat)
102 : start_time(start), end_time(end), type(kGestureTypeScroll), quat(quat) {
103 details.scroll.ordinal_dx = details.scroll.dx = dx;
104 details.scroll.ordinal_dy = details.scroll.dy = dy;
105 details.scroll.state = state;
106 details.scroll.stop_fling = 0;
107 }
108 VrGesture(const GestureButtonsChange&,
109 int64_t start,
110 int64_t end,
111 unsigned down,
112 unsigned up,
113 quatf quat)
114 : start_time(start),
115 end_time(end),
116 type(kGestureTypeButtonsChange),
117 quat(quat) {
118 details.buttons.down = down;
119 details.buttons.up = up;
120 details.buttons.x = 0;
121 details.buttons.y = 0;
122 }
123 VrGesture(const GestureFling&,
124 int64_t start,
125 int64_t end,
126 float vx,
127 float vy,
128 unsigned state,
129 quatf quat)
130 : start_time(start), end_time(end), type(kGestureTypeFling), quat(quat) {
131 details.fling.ordinal_vx = details.fling.vx = vx;
132 details.fling.ordinal_vy = details.fling.vy = vy;
133 details.fling.fling_state = state;
134 }
135 VrGesture(const GestureZoom&,
136 int64_t start,
137 int64_t end,
138 float dz,
139 quatf quat)
140 : start_time(start), end_time(end), type(kGestureTypeZoom), quat(quat) {
141 details.zoom.dz = dz;
142 }
143
144 int64_t start_time, end_time;
145 enum GestureType type;
146 union {
147 GestureScroll scroll;
148 GestureButtonsChange buttons;
149 GestureFling fling;
150 GestureZoom zoom;
151 GestureAngularMove move;
152 } details;
153 quatf quat;
154 vec2f velocity;
155 vec2f displacement;
156 gesture_direction direction;
157 };
158
159 const GestureScroll kGestureScroll = {0, 0, 0, 0, 0, 0};
160 const GestureButtonsChange kGestureButtonsChange = {0, 0, 0, 0};
161 const GestureAngularMove kGestureAngularMove = {0, 0, 0, 0, 0, 0, 0, 0, 0};
162 const GestureZoom kGestureZoom = {0};
163
164 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698