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

Side by Side Diff: chrome/browser/android/vr_shell/vr_gesture.h

Issue 2380323003: Refactorings to vr controller code. (Closed)
Patch Set: Fix BUILD.gn Created 4 years, 2 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_
7 7
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 8 #include "third_party/WebKit/public/web/WebInputEvent.h"
9 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" 9 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h"
10 10
11 using blink::WebInputEvent; 11 using blink::WebInputEvent;
12 12
13 namespace vr_shell { 13 namespace vr_shell {
14 14
15 typedef enum {
16 GESTURE_DIRECTION_UP,
17 GESTURE_DIRECTION_DOWN,
18 GESTURE_DIRECTION_LEFT,
19 GESTURE_DIRECTION_RIGHT
20 } gesture_direction;
21
22 typedef struct { 15 typedef struct {
23 gvr_vec3f delta; 16 gvr_vec3f delta;
24 int type; 17 int type;
25 } GestureAngularMove; 18 } GestureAngularMove;
26 19
27 typedef struct { 20 typedef struct {
28 gvr_vec2f delta; 21 gvr_vec2f delta;
29 22
30 // If set, stop_fling means that this scroll should stop flinging, thus 23 // If set, stop_fling means that this scroll should stop flinging, thus
31 // if an interpreter suppresses it for any reason (e.g., rounds the size 24 // if an interpreter suppresses it for any reason (e.g., rounds the size
32 // down to 0, thus making it a noop), it will replace it with a Fling 25 // down to 0, thus making it a noop), it will replace it with a Fling
33 // TAP_DOWN gesture 26 // TAP_DOWN gesture
34 unsigned stop_fling : 1; 27 unsigned stop_fling : 1;
35 gvr_vec2f initial_touch_pos; 28 gvr_vec2f initial_touch_pos;
36 } GestureScroll; 29 } GestureScroll;
37 30
38 typedef struct { 31 typedef struct {
39 // If a bit is set in both down and up, client should process down first 32 // If a bit is set in both down and up, client should process down first
40 gvr_vec2f pos; 33 gvr_vec2f pos;
41 unsigned down; // bit field, use GESTURES_BUTTON_* 34 unsigned down; // bit field, use GESTURES_BUTTON_*
42 unsigned up; // bit field, use GESTURES_BUTTON_* 35 unsigned up; // bit field, use GESTURES_BUTTON_*
43 } GestureButtonsChange; 36 } GestureButtonsChange;
44 37
45 struct VrGesture { 38 struct VrGesture {
46 VrGesture() : type(WebInputEvent::Undefined) {} 39 VrGesture() : start_time(0), end_time(0),
47 VrGesture(const GestureAngularMove&, 40 type(WebInputEvent::Undefined) {}
48 int64_t start,
49 int64_t end,
50 gvr::Quatf quat)
51 : start_time(start),
52 end_time(end),
53 type(WebInputEvent::MouseMove),
54 quat(quat) {}
55 VrGesture(const GestureScroll&,
56 int64_t start,
57 int64_t end,
58 float dx,
59 float dy,
60 WebInputEvent::Type state,
61 gvr::Quatf quat)
62 : start_time(start), end_time(end), type(state), quat(quat) {
63 details.scroll.delta.x = dx;
64 details.scroll.delta.y = dy;
65 details.scroll.stop_fling = 0;
66 }
67 VrGesture(const GestureButtonsChange&,
68 int64_t start,
69 int64_t end,
70 unsigned down,
71 unsigned up,
72 gvr::Quatf quat)
73 : start_time(start),
74 end_time(end),
75 type(WebInputEvent::GestureTap),
76 quat(quat) {
77 details.buttons.down = down;
78 details.buttons.up = up;
79 details.buttons.pos.x = 0;
80 details.buttons.pos.y = 0;
81 }
82
83 int64_t start_time, end_time; 41 int64_t start_time, end_time;
84 enum WebInputEvent::Type type; 42 enum WebInputEvent::Type type;
85 union { 43 union {
86 GestureScroll scroll; 44 GestureScroll scroll;
87 GestureButtonsChange buttons; 45 GestureButtonsChange buttons;
88 GestureAngularMove move; 46 GestureAngularMove move;
89 } details; 47 } details;
90 gvr::Quatf quat;
91 gvr::Vec2f velocity; 48 gvr::Vec2f velocity;
92 gvr::Vec2f displacement; 49 gvr::Vec2f displacement;
93 gesture_direction direction;
94 }; 50 };
95 51
96 } // namespace vr_shell 52 } // namespace vr_shell
97 53
98 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ 54 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_controller_manager.cc ('k') | chrome/browser/android/vr_shell/vr_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698