SteamVR
This commit is contained in:
Executable
+87
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public struct GazeEventArgs
|
||||
{
|
||||
public float distance;
|
||||
}
|
||||
|
||||
public delegate void GazeEventHandler(object sender, GazeEventArgs e);
|
||||
|
||||
public class SteamVR_GazeTracker : MonoBehaviour
|
||||
{
|
||||
public bool isInGaze = false;
|
||||
public event GazeEventHandler GazeOn;
|
||||
public event GazeEventHandler GazeOff;
|
||||
public float gazeInCutoff = 0.15f;
|
||||
public float gazeOutCutoff = 0.4f;
|
||||
|
||||
// Contains a HMD tracked object that we can use to find the user's gaze
|
||||
Transform hmdTrackedObject = null;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnGazeOn(GazeEventArgs e)
|
||||
{
|
||||
if (GazeOn != null)
|
||||
GazeOn(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnGazeOff(GazeEventArgs e)
|
||||
{
|
||||
if (GazeOff != null)
|
||||
GazeOff(this, e);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
// If we haven't set up hmdTrackedObject find what the user is looking at
|
||||
if (hmdTrackedObject == null)
|
||||
{
|
||||
SteamVR_TrackedObject[] trackedObjects = FindObjectsOfType<SteamVR_TrackedObject>();
|
||||
foreach (SteamVR_TrackedObject tracked in trackedObjects)
|
||||
{
|
||||
if (tracked.index == SteamVR_TrackedObject.EIndex.Hmd)
|
||||
{
|
||||
hmdTrackedObject = tracked.transform;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hmdTrackedObject)
|
||||
{
|
||||
Ray r = new Ray(hmdTrackedObject.position, hmdTrackedObject.forward);
|
||||
Plane p = new Plane(hmdTrackedObject.forward, transform.position);
|
||||
|
||||
float enter = 0.0f;
|
||||
if (p.Raycast(r, out enter))
|
||||
{
|
||||
Vector3 intersect = hmdTrackedObject.position + hmdTrackedObject.forward * enter;
|
||||
float dist = Vector3.Distance(intersect, transform.position);
|
||||
//Debug.Log("Gaze dist = " + dist);
|
||||
if (dist < gazeInCutoff && !isInGaze)
|
||||
{
|
||||
isInGaze = true;
|
||||
GazeEventArgs e;
|
||||
e.distance = dist;
|
||||
OnGazeOn(e);
|
||||
}
|
||||
else if (dist >= gazeOutCutoff && isInGaze)
|
||||
{
|
||||
isInGaze = false;
|
||||
GazeEventArgs e;
|
||||
e.distance = dist;
|
||||
OnGazeOff(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 501eb8b744f73714fbe7dbdd5e3ef66e
|
||||
timeCreated: 1426193800
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public struct PointerEventArgs
|
||||
{
|
||||
public uint controllerIndex;
|
||||
public uint flags;
|
||||
public float distance;
|
||||
public Transform target;
|
||||
}
|
||||
|
||||
public delegate void PointerEventHandler(object sender, PointerEventArgs e);
|
||||
|
||||
|
||||
public class SteamVR_LaserPointer : MonoBehaviour
|
||||
{
|
||||
public bool active = true;
|
||||
public Color color;
|
||||
public float thickness = 0.002f;
|
||||
public GameObject holder;
|
||||
public GameObject pointer;
|
||||
bool isActive = false;
|
||||
public bool addRigidBody = false;
|
||||
public Transform reference;
|
||||
public event PointerEventHandler PointerIn;
|
||||
public event PointerEventHandler PointerOut;
|
||||
|
||||
Transform previousContact = null;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
holder = new GameObject();
|
||||
holder.transform.parent = this.transform;
|
||||
holder.transform.localPosition = Vector3.zero;
|
||||
|
||||
pointer = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
pointer.transform.parent = holder.transform;
|
||||
pointer.transform.localScale = new Vector3(thickness, thickness, 100f);
|
||||
pointer.transform.localPosition = new Vector3(0f, 0f, 50f);
|
||||
BoxCollider collider = pointer.GetComponent<BoxCollider>();
|
||||
if (addRigidBody)
|
||||
{
|
||||
if (collider)
|
||||
{
|
||||
collider.isTrigger = true;
|
||||
}
|
||||
Rigidbody rigidBody = pointer.AddComponent<Rigidbody>();
|
||||
rigidBody.isKinematic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(collider)
|
||||
{
|
||||
Object.Destroy(collider);
|
||||
}
|
||||
}
|
||||
Material newMaterial = new Material(Shader.Find("Unlit/Color"));
|
||||
newMaterial.SetColor("_Color", color);
|
||||
pointer.GetComponent<MeshRenderer>().material = newMaterial;
|
||||
}
|
||||
|
||||
public virtual void OnPointerIn(PointerEventArgs e)
|
||||
{
|
||||
if (PointerIn != null)
|
||||
PointerIn(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPointerOut(PointerEventArgs e)
|
||||
{
|
||||
if (PointerOut != null)
|
||||
PointerOut(this, e);
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (!isActive)
|
||||
{
|
||||
isActive = true;
|
||||
this.transform.GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
float dist = 100f;
|
||||
|
||||
SteamVR_TrackedController controller = GetComponent<SteamVR_TrackedController>();
|
||||
|
||||
Ray raycast = new Ray(transform.position, transform.forward);
|
||||
RaycastHit hit;
|
||||
bool bHit = Physics.Raycast(raycast, out hit);
|
||||
|
||||
if(previousContact && previousContact != hit.transform)
|
||||
{
|
||||
PointerEventArgs args = new PointerEventArgs();
|
||||
if (controller != null)
|
||||
{
|
||||
args.controllerIndex = controller.controllerIndex;
|
||||
}
|
||||
args.distance = 0f;
|
||||
args.flags = 0;
|
||||
args.target = previousContact;
|
||||
OnPointerOut(args);
|
||||
previousContact = null;
|
||||
}
|
||||
if(bHit && previousContact != hit.transform)
|
||||
{
|
||||
PointerEventArgs argsIn = new PointerEventArgs();
|
||||
if (controller != null)
|
||||
{
|
||||
argsIn.controllerIndex = controller.controllerIndex;
|
||||
}
|
||||
argsIn.distance = hit.distance;
|
||||
argsIn.flags = 0;
|
||||
argsIn.target = hit.transform;
|
||||
OnPointerIn(argsIn);
|
||||
previousContact = hit.transform;
|
||||
}
|
||||
if(!bHit)
|
||||
{
|
||||
previousContact = null;
|
||||
}
|
||||
if (bHit && hit.distance < 100f)
|
||||
{
|
||||
dist = hit.distance;
|
||||
}
|
||||
|
||||
if (controller != null && controller.triggerPressed)
|
||||
{
|
||||
pointer.transform.localScale = new Vector3(thickness * 5f, thickness * 5f, dist);
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer.transform.localScale = new Vector3(thickness, thickness, dist);
|
||||
}
|
||||
pointer.transform.localPosition = new Vector3(0f, 0f, dist/2f);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4e8a839a7c5b7e4580c59e305fb5f01
|
||||
timeCreated: 1430337756
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class SteamVR_Teleporter : MonoBehaviour
|
||||
{
|
||||
public enum TeleportType
|
||||
{
|
||||
TeleportTypeUseTerrain,
|
||||
TeleportTypeUseCollider,
|
||||
TeleportTypeUseZeroY
|
||||
}
|
||||
|
||||
public bool teleportOnClick = false;
|
||||
public TeleportType teleportType = TeleportType.TeleportTypeUseZeroY;
|
||||
|
||||
Transform reference
|
||||
{
|
||||
get
|
||||
{
|
||||
var top = SteamVR_Render.Top();
|
||||
return (top != null) ? top.origin : null;
|
||||
}
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
var trackedController = GetComponent<SteamVR_TrackedController>();
|
||||
if (trackedController == null)
|
||||
{
|
||||
trackedController = gameObject.AddComponent<SteamVR_TrackedController>();
|
||||
}
|
||||
|
||||
trackedController.TriggerClicked += new ClickedEventHandler(DoClick);
|
||||
|
||||
if (teleportType == TeleportType.TeleportTypeUseTerrain)
|
||||
{
|
||||
// Start the player at the level of the terrain
|
||||
var t = reference;
|
||||
if (t != null)
|
||||
t.position = new Vector3(t.position.x, Terrain.activeTerrain.SampleHeight(t.position), t.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
void DoClick(object sender, ClickedEventArgs e)
|
||||
{
|
||||
if (teleportOnClick)
|
||||
{
|
||||
var t = reference;
|
||||
if (t == null)
|
||||
return;
|
||||
|
||||
float refY = t.position.y;
|
||||
|
||||
Plane plane = new Plane(Vector3.up, -refY);
|
||||
Ray ray = new Ray(this.transform.position, transform.forward);
|
||||
|
||||
bool hasGroundTarget = false;
|
||||
float dist = 0f;
|
||||
if (teleportType == TeleportType.TeleportTypeUseTerrain)
|
||||
{
|
||||
RaycastHit hitInfo;
|
||||
TerrainCollider tc = Terrain.activeTerrain.GetComponent<TerrainCollider>();
|
||||
hasGroundTarget = tc.Raycast(ray, out hitInfo, 1000f);
|
||||
dist = hitInfo.distance;
|
||||
}
|
||||
else if (teleportType == TeleportType.TeleportTypeUseCollider)
|
||||
{
|
||||
RaycastHit hitInfo;
|
||||
Physics.Raycast(ray, out hitInfo);
|
||||
dist = hitInfo.distance;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasGroundTarget = plane.Raycast(ray, out dist);
|
||||
}
|
||||
|
||||
if (hasGroundTarget)
|
||||
{
|
||||
Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.localPosition.x, 0.0f, SteamVR_Render.Top().head.localPosition.z);
|
||||
t.position = ray.origin + ray.direction * dist - new Vector3(t.GetChild(0).localPosition.x, 0f, t.GetChild(0).localPosition.z) - headPosOnGround;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24c7d7d77dd0d2a4b8e1ad129b170ee3
|
||||
timeCreated: 1430337756
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Executable
+1852
File diff suppressed because it is too large
Load Diff
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b6669fb4e4df9c48926f02b694be9d1
|
||||
timeCreated: 1437433018
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[RequireComponent(typeof(SteamVR_TrackedObject))]
|
||||
public class SteamVR_TestThrow : MonoBehaviour
|
||||
{
|
||||
public GameObject prefab;
|
||||
public Rigidbody attachPoint;
|
||||
|
||||
SteamVR_TrackedObject trackedObj;
|
||||
FixedJoint joint;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
trackedObj = GetComponent<SteamVR_TrackedObject>();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
var device = SteamVR_Controller.Input((int)trackedObj.index);
|
||||
if (joint == null && device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
|
||||
{
|
||||
var go = GameObject.Instantiate(prefab);
|
||||
go.transform.position = attachPoint.transform.position;
|
||||
|
||||
joint = go.AddComponent<FixedJoint>();
|
||||
joint.connectedBody = attachPoint;
|
||||
}
|
||||
else if (joint != null && device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
|
||||
{
|
||||
var go = joint.gameObject;
|
||||
var rigidbody = go.GetComponent<Rigidbody>();
|
||||
Object.DestroyImmediate(joint);
|
||||
joint = null;
|
||||
Object.Destroy(go, 15.0f);
|
||||
|
||||
// We should probably apply the offset between trackedObj.transform.position
|
||||
// and device.transform.pos to insert into the physics sim at the correct
|
||||
// location, however, we would then want to predict ahead the visual representation
|
||||
// by the same amount we are predicting our render poses.
|
||||
|
||||
var origin = trackedObj.origin ? trackedObj.origin : trackedObj.transform.parent;
|
||||
if (origin != null)
|
||||
{
|
||||
rigidbody.velocity = origin.TransformVector(device.velocity);
|
||||
rigidbody.angularVelocity = origin.TransformVector(device.angularVelocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
rigidbody.velocity = device.velocity;
|
||||
rigidbody.angularVelocity = device.angularVelocity;
|
||||
}
|
||||
|
||||
rigidbody.maxAngularVelocity = rigidbody.angularVelocity.magnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff4f36585e15b1942827390ff1a92502
|
||||
timeCreated: 1437513988
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+2791
File diff suppressed because one or more lines are too long
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d936163b5e9a5047b5e4ba5afaf5126
|
||||
timeCreated: 1437513966
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
using UnityEngine;
|
||||
using Valve.VR;
|
||||
|
||||
public struct ClickedEventArgs
|
||||
{
|
||||
public uint controllerIndex;
|
||||
public uint flags;
|
||||
public float padX, padY;
|
||||
}
|
||||
|
||||
public delegate void ClickedEventHandler(object sender, ClickedEventArgs e);
|
||||
|
||||
public class SteamVR_TrackedController : MonoBehaviour
|
||||
{
|
||||
public uint controllerIndex;
|
||||
public VRControllerState_t controllerState;
|
||||
public bool triggerPressed = false;
|
||||
public bool steamPressed = false;
|
||||
public bool menuPressed = false;
|
||||
public bool padPressed = false;
|
||||
public bool padTouched = false;
|
||||
public bool gripped = false;
|
||||
|
||||
public event ClickedEventHandler MenuButtonClicked;
|
||||
public event ClickedEventHandler MenuButtonUnclicked;
|
||||
public event ClickedEventHandler TriggerClicked;
|
||||
public event ClickedEventHandler TriggerUnclicked;
|
||||
public event ClickedEventHandler SteamClicked;
|
||||
public event ClickedEventHandler PadClicked;
|
||||
public event ClickedEventHandler PadUnclicked;
|
||||
public event ClickedEventHandler PadTouched;
|
||||
public event ClickedEventHandler PadUntouched;
|
||||
public event ClickedEventHandler Gripped;
|
||||
public event ClickedEventHandler Ungripped;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
if (this.GetComponent<SteamVR_TrackedObject>() == null)
|
||||
{
|
||||
gameObject.AddComponent<SteamVR_TrackedObject>();
|
||||
}
|
||||
|
||||
if (controllerIndex != 0)
|
||||
{
|
||||
this.GetComponent<SteamVR_TrackedObject>().index = (SteamVR_TrackedObject.EIndex)controllerIndex;
|
||||
if (this.GetComponent<SteamVR_RenderModel>() != null)
|
||||
{
|
||||
this.GetComponent<SteamVR_RenderModel>().index = (SteamVR_TrackedObject.EIndex)controllerIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
controllerIndex = (uint) this.GetComponent<SteamVR_TrackedObject>().index;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDeviceIndex(int index)
|
||||
{
|
||||
this.controllerIndex = (uint) index;
|
||||
}
|
||||
|
||||
public virtual void OnTriggerClicked(ClickedEventArgs e)
|
||||
{
|
||||
if (TriggerClicked != null)
|
||||
TriggerClicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnTriggerUnclicked(ClickedEventArgs e)
|
||||
{
|
||||
if (TriggerUnclicked != null)
|
||||
TriggerUnclicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnMenuClicked(ClickedEventArgs e)
|
||||
{
|
||||
if (MenuButtonClicked != null)
|
||||
MenuButtonClicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnMenuUnclicked(ClickedEventArgs e)
|
||||
{
|
||||
if (MenuButtonUnclicked != null)
|
||||
MenuButtonUnclicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnSteamClicked(ClickedEventArgs e)
|
||||
{
|
||||
if (SteamClicked != null)
|
||||
SteamClicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPadClicked(ClickedEventArgs e)
|
||||
{
|
||||
if (PadClicked != null)
|
||||
PadClicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPadUnclicked(ClickedEventArgs e)
|
||||
{
|
||||
if (PadUnclicked != null)
|
||||
PadUnclicked(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPadTouched(ClickedEventArgs e)
|
||||
{
|
||||
if (PadTouched != null)
|
||||
PadTouched(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPadUntouched(ClickedEventArgs e)
|
||||
{
|
||||
if (PadUntouched != null)
|
||||
PadUntouched(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnGripped(ClickedEventArgs e)
|
||||
{
|
||||
if (Gripped != null)
|
||||
Gripped(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnUngripped(ClickedEventArgs e)
|
||||
{
|
||||
if (Ungripped != null)
|
||||
Ungripped(this, e);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var system = OpenVR.System;
|
||||
if (system != null && system.GetControllerState(controllerIndex, ref controllerState))
|
||||
{
|
||||
ulong trigger = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Trigger));
|
||||
if (trigger > 0L && !triggerPressed)
|
||||
{
|
||||
triggerPressed = true;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnTriggerClicked(e);
|
||||
|
||||
}
|
||||
else if (trigger == 0L && triggerPressed)
|
||||
{
|
||||
triggerPressed = false;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnTriggerUnclicked(e);
|
||||
}
|
||||
|
||||
ulong grip = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_Grip));
|
||||
if (grip > 0L && !gripped)
|
||||
{
|
||||
gripped = true;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnGripped(e);
|
||||
|
||||
}
|
||||
else if (grip == 0L && gripped)
|
||||
{
|
||||
gripped = false;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnUngripped(e);
|
||||
}
|
||||
|
||||
ulong pad = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Touchpad));
|
||||
if (pad > 0L && !padPressed)
|
||||
{
|
||||
padPressed = true;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnPadClicked(e);
|
||||
}
|
||||
else if (pad == 0L && padPressed)
|
||||
{
|
||||
padPressed = false;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnPadUnclicked(e);
|
||||
}
|
||||
|
||||
ulong menu = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_ApplicationMenu));
|
||||
if (menu > 0L && !menuPressed)
|
||||
{
|
||||
menuPressed = true;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnMenuClicked(e);
|
||||
}
|
||||
else if (menu == 0L && menuPressed)
|
||||
{
|
||||
menuPressed = false;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnMenuUnclicked(e);
|
||||
}
|
||||
|
||||
pad = controllerState.ulButtonTouched & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Touchpad));
|
||||
if (pad > 0L && !padTouched)
|
||||
{
|
||||
padTouched = true;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnPadTouched(e);
|
||||
|
||||
}
|
||||
else if (pad == 0L && padTouched)
|
||||
{
|
||||
padTouched = false;
|
||||
ClickedEventArgs e;
|
||||
e.controllerIndex = controllerIndex;
|
||||
e.flags = (uint)controllerState.ulButtonPressed;
|
||||
e.padX = controllerState.rAxis0.x;
|
||||
e.padY = controllerState.rAxis0.y;
|
||||
OnPadUntouched(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7346a42905a29b347b1f492e8ad7b49f
|
||||
timeCreated: 1430337756
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user