| 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..723570c63bd9aeb2c8efee37a236b15002e3b9d6
|
| --- /dev/null
|
| +++ b/chrome/browser/android/vr_shell/vr_gesture.h
|
| @@ -0,0 +1,125 @@
|
| +// 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"
|
| +
|
| +namespace vr_shell {
|
| +
|
| +typedef enum {
|
| + GESTURE_DIRECTION_UP,
|
| + GESTURE_DIRECTION_DOWN,
|
| + GESTURE_DIRECTION_LEFT,
|
| + GESTURE_DIRECTION_RIGHT
|
| +} gesture_direction;
|
| +
|
| +typedef struct {
|
| + gvr_vec3f delta;
|
| + int type;
|
| +} GestureAngularMove;
|
| +
|
| +typedef struct {
|
| + gvr_vec2f delta;
|
| +
|
| + // 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;
|
| + gvr_vec2f initial_touch_pos;
|
| +} GestureScroll;
|
| +
|
| +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
|
| + gvr_vec2f pos;
|
| + 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)
|
| + : 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.delta.x = dx;
|
| + details.scroll.delta.y = 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.pos.x = 0;
|
| + details.buttons.pos.y = 0;
|
| + }
|
| + 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;
|
| + 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};
|
| +const GestureZoom kGestureZoom = {0};
|
| +
|
| +} // namespace vr_shell
|
| +
|
| +#endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_
|
|
|