Chromium Code Reviews| Index: chrome/browser/android/vr_shell/vr_gesture.h |
| diff --git a/chrome/browser/android/vr_shell/vr_gesture.h b/chrome/browser/android/vr_shell/vr_gesture.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f616ad216e72f827f6cb6061f08493aa25eb5f64 |
| --- /dev/null |
| +++ b/chrome/browser/android/vr_shell/vr_gesture.h |
| @@ -0,0 +1,145 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |
| +#define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |
| + |
| +#include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/gvr_types.h" |
| + |
| +typedef enum { |
| + GESTURE_DIRECTION_UP, |
| + GESTURE_DIRECTION_DOWN, |
| + GESTURE_DIRECTION_LEFT, |
| + GESTURE_DIRECTION_RIGHT |
| +} gesture_direction; |
| + |
| +typedef struct { |
| + float dx, dy, dz; |
| + float x, y; |
| + float ordinal_dx, ordinal_dy, ordinal_dz; |
| + int type; |
| +} GestureAngularMove; |
| + |
| +typedef struct { |
| + float dx, dy; |
| + float ordinal_dx, ordinal_dy; |
| + // If set, stop_fling means that this scroll should stop flinging, thus |
| + // if an interpreter suppresses it for any reason (e.g., rounds the size |
| + // down to 0, thus making it a noop), it will replace it with a Fling |
| + // TAP_DOWN gesture |
| + int state; |
| + unsigned stop_fling : 1; |
| + float initial_touch_pos_x; |
| + float initial_touch_pos_y; |
| +} GestureScroll; |
| + |
| +typedef struct { |
| + // fling velocity (valid when fling_state is GESTURES_FLING_START): |
| + float vx, vy; |
| + float ordinal_vx, ordinal_vy; |
| + unsigned fling_state : 1; // GESTURES_FLING_START or GESTURES_FLING_TAP_DOWN |
| +} GestureFling; |
| + |
| +typedef struct { |
| + // zoom size; dz=1 means no zoom, dz < 1 means zoom-out, dz > 1 means zoom-in |
| + float dz; |
| +} GestureZoom; |
| + |
| +typedef struct { |
| + // If a bit is set in both down and up, client should process down first |
| + int x; |
| + int y; |
| + unsigned down; // bit field, use GESTURES_BUTTON_* |
| + unsigned up; // bit field, use GESTURES_BUTTON_* |
| +} GestureButtonsChange; |
| + |
| +enum GestureType { |
| + kGestureTypeNull, |
| + kGestureTypeAngularMove, |
| + kGestureTypeScroll, |
| + kGestureTypeButtonsChange, |
| + kGestureTypeFling, |
| + kGestureTypeZoom, |
| +}; |
| + |
| +struct VrGesture { |
| + VrGesture() : type(kGestureTypeNull) {} |
| + VrGesture(const GestureAngularMove&, |
| + int64_t start, |
| + int64_t end, |
| + gvr_quatf quat) |
|
mthiesse
2016/09/22 16:20:11
gvr:: types throughout
asimjour
2016/09/22 22:55:16
Done.
|
| + : start_time(start), |
| + end_time(end), |
| + type(kGestureTypeAngularMove), |
| + quat(quat) {} |
| + VrGesture(const GestureScroll&, |
| + int64_t start, |
| + int64_t end, |
| + float dx, |
| + float dy, |
| + int state, |
| + gvr_quatf quat) |
| + : start_time(start), end_time(end), type(kGestureTypeScroll), quat(quat) { |
| + details.scroll.ordinal_dx = details.scroll.dx = dx; |
| + details.scroll.ordinal_dy = details.scroll.dy = dy; |
| + details.scroll.state = state; |
| + details.scroll.stop_fling = 0; |
| + } |
| + VrGesture(const GestureButtonsChange&, |
| + int64_t start, |
| + int64_t end, |
| + unsigned down, |
| + unsigned up, |
| + gvr_quatf quat) |
| + : start_time(start), |
| + end_time(end), |
| + type(kGestureTypeButtonsChange), |
| + quat(quat) { |
| + details.buttons.down = down; |
| + details.buttons.up = up; |
| + details.buttons.x = 0; |
| + details.buttons.y = 0; |
| + } |
| + VrGesture(const GestureFling&, |
| + int64_t start, |
| + int64_t end, |
| + float vx, |
| + float vy, |
| + unsigned state, |
| + gvr_quatf quat) |
| + : start_time(start), end_time(end), type(kGestureTypeFling), quat(quat) { |
| + details.fling.ordinal_vx = details.fling.vx = vx; |
| + details.fling.ordinal_vy = details.fling.vy = vy; |
| + details.fling.fling_state = state; |
| + } |
| + VrGesture(const GestureZoom&, |
| + int64_t start, |
| + int64_t end, |
| + float dz, |
| + gvr_quatf quat) |
| + : start_time(start), end_time(end), type(kGestureTypeZoom), quat(quat) { |
| + details.zoom.dz = dz; |
| + } |
| + |
| + int64_t start_time, end_time; |
| + enum GestureType type; |
| + union { |
| + GestureScroll scroll; |
| + GestureButtonsChange buttons; |
| + GestureFling fling; |
| + GestureZoom zoom; |
| + GestureAngularMove move; |
| + } details; |
| + gvr_quatf quat; |
| + gvr_vec2f velocity; |
| + gvr_vec2f displacement; |
| + gesture_direction direction; |
| +}; |
| + |
| +const GestureScroll kGestureScroll = {0, 0, 0, 0, 0, 0}; |
| +const GestureButtonsChange kGestureButtonsChange = {0, 0, 0, 0}; |
| +const GestureAngularMove kGestureAngularMove = {0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| +const GestureZoom kGestureZoom = {0}; |
| + |
| +#endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |