/// <summary> /// Gives the r-theta parameterization of the point on the touchpad that /// the user is touching. /// </summary> /// <param name="deviceIndex">The index of the controller</param> /// <param name="r">the radius [0,1]</param> /// <param name="theta">the angle made with the x-axis</param> protected void getViveTouchpadPoint(uint deviceIndex, out float r, out float theta) { VRControllerState_t controllerState = new VRControllerState_t(); VRControllerAxis_t axis = new VRControllerAxis_t(); unsafe { mScene.mHMD.GetControllerState(deviceIndex, ref controllerState, (uint)sizeof(VRControllerState_t)); } axis = controllerState.rAxis0; r = (float)Math.Sqrt(axis.x * axis.x + axis.y * axis.y); if (r > 0) { theta = (float)Math.Atan2(axis.y / r, axis.x / r); // TODO: Remove divisions? } else { theta = 0; } }
public static void ToVector2(ref VRControllerAxis_t axis, out Vector2 result) { result.X = axis.x; result.Y = axis.y; }
public static Vector2 AsVector(this VRControllerAxis_t axis) { return(new Vector2(axis.x, axis.y)); }
private Vector2 ControllerAxisToVector2(VRControllerAxis_t axis) { return(new Vector2(axis.x, axis.y)); }