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 gvr_vec3f delta; |
| 21 int type; |
| 22 } GestureAngularMove; |
| 23 |
| 24 typedef struct { |
| 25 gvr_vec2f delta; |
| 26 |
| 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 gvr_vec2f initial_touch_pos; |
| 34 } GestureScroll; |
| 35 |
| 36 typedef struct { |
| 37 // zoom size; dz=1 means no zoom, dz < 1 means zoom-out, dz > 1 means zoom-in |
| 38 float dz; |
| 39 } GestureZoom; |
| 40 |
| 41 typedef struct { |
| 42 // If a bit is set in both down and up, client should process down first |
| 43 gvr_vec2f pos; |
| 44 unsigned down; // bit field, use GESTURES_BUTTON_* |
| 45 unsigned up; // bit field, use GESTURES_BUTTON_* |
| 46 } GestureButtonsChange; |
| 47 |
| 48 enum GestureType { |
| 49 kGestureTypeNull, |
| 50 kGestureTypeAngularMove, |
| 51 kGestureTypeScroll, |
| 52 kGestureTypeButtonsChange, |
| 53 kGestureTypeFling, |
| 54 kGestureTypeZoom, |
| 55 }; |
| 56 |
| 57 struct VrGesture { |
| 58 VrGesture() : type(kGestureTypeNull) {} |
| 59 VrGesture(const GestureAngularMove&, |
| 60 int64_t start, |
| 61 int64_t end, |
| 62 gvr::Quatf quat) |
| 63 : start_time(start), |
| 64 end_time(end), |
| 65 type(kGestureTypeAngularMove), |
| 66 quat(quat) {} |
| 67 VrGesture(const GestureScroll&, |
| 68 int64_t start, |
| 69 int64_t end, |
| 70 float dx, |
| 71 float dy, |
| 72 int state, |
| 73 gvr::Quatf quat) |
| 74 : start_time(start), end_time(end), type(kGestureTypeScroll), quat(quat) { |
| 75 details.scroll.delta.x = dx; |
| 76 details.scroll.delta.y = dy; |
| 77 details.scroll.state = state; |
| 78 details.scroll.stop_fling = 0; |
| 79 } |
| 80 VrGesture(const GestureButtonsChange&, |
| 81 int64_t start, |
| 82 int64_t end, |
| 83 unsigned down, |
| 84 unsigned up, |
| 85 gvr::Quatf quat) |
| 86 : start_time(start), |
| 87 end_time(end), |
| 88 type(kGestureTypeButtonsChange), |
| 89 quat(quat) { |
| 90 details.buttons.down = down; |
| 91 details.buttons.up = up; |
| 92 details.buttons.pos.x = 0; |
| 93 details.buttons.pos.y = 0; |
| 94 } |
| 95 VrGesture(const GestureZoom&, |
| 96 int64_t start, |
| 97 int64_t end, |
| 98 float dz, |
| 99 gvr::Quatf quat) |
| 100 : start_time(start), end_time(end), type(kGestureTypeZoom), quat(quat) { |
| 101 details.zoom.dz = dz; |
| 102 } |
| 103 |
| 104 int64_t start_time, end_time; |
| 105 enum GestureType type; |
| 106 union { |
| 107 GestureScroll scroll; |
| 108 GestureButtonsChange buttons; |
| 109 GestureZoom zoom; |
| 110 GestureAngularMove move; |
| 111 } details; |
| 112 gvr::Quatf quat; |
| 113 gvr::Vec2f velocity; |
| 114 gvr::Vec2f displacement; |
| 115 gesture_direction direction; |
| 116 }; |
| 117 |
| 118 const GestureScroll kGestureScroll = {{0, 0}, 0, 0, {0, 0}}; |
| 119 const GestureButtonsChange kGestureButtonsChange = {{0, 0}, 0, 0}; |
| 120 const GestureAngularMove kGestureAngularMove = {{0, 0, 0}, 0}; |
| 121 const GestureZoom kGestureZoom = {0}; |
| 122 |
| 123 } // namespace vr_shell |
| 124 |
| 125 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |
OLD | NEW |