/// <summary> /// Update Generic Controller /// </summary> private void UpdateGenericController() { VRGenericControllerState genericController = new VRGenericControllerState() { IsConnected = true, Role = this.ConvertHandednessToRole(this.currentSpatialState.Handedness), ThumbStick = this.currentSpatialState.Thumbstick, Trigger = this.currentSpatialState.SelectTriggerValue, TriggerButton = this.currentSpatialState.IsSelectTriggerPressed ? Common.Input.ButtonState.Pressed : Common.Input.ButtonState.Released, Grip = this.currentSpatialState.IsGraspPressed ? Common.Input.ButtonState.Pressed : Common.Input.ButtonState.Released, Menu = this.currentSpatialState.IsMenuPressed ? Common.Input.ButtonState.Pressed : Common.Input.ButtonState.Released, ThumbStickButton = this.currentSpatialState.IsThumbstickPressed ? Common.Input.ButtonState.Pressed : Common.Input.ButtonState.Released, Touchpad = this.currentSpatialState.Touchpad, //////Button1 = this.A, ////Button2 = ButtonState.Released, Pose = this.ConvertToVRPose(this.currentSpatialState) }; switch (genericController.Role) { case VRControllerRole.LeftHand: this.genericControllersArray[0] = genericController; break; case VRControllerRole.RightHand: this.genericControllersArray[1] = genericController; break; case VRControllerRole.Undefined: break; default: break; } }
/// <summary> /// Convert Oculus Touch controllers to right generic controllers /// </summary> /// <param name="genericController">The generic controller to fill</param> public void ToRightGenericController(out VRGenericControllerState genericController) { genericController = new VRGenericControllerState() { IsConnected = true, Role = VRControllerRole.RightHand, Button1 = this.A, Button2 = this.B, Grip = (this.RightHandTrigger > 0.5).ToButtonState(), TriggerButton = (this.RightIndexTrigger > 0.5).ToButtonState(), ThumbStickButton = this.RThumb, ThumbStick = this.RightThumbstick, Trigger = this.RightIndexTrigger }; }
/// <summary> /// Convert Oculus Touch controllers to left generic controllers /// </summary> /// <param name="genericController">The generic controller to fill</param> public void ToLeftGenericController(out VRGenericControllerState genericController) { genericController = new VRGenericControllerState() { IsConnected = true, Role = VRControllerRole.LeftHand, Button1 = this.X, Button2 = this.Y, Grip = (this.LeftHandTrigger > 0.5).ToButtonState(), TriggerButton = (this.LeftIndexTrigger > 0.5).ToButtonState(), ThumbStickButton = this.LThumb, ThumbStick = this.LeftThumbstick, Trigger = this.LeftIndexTrigger, }; }
/// <summary> /// Update the state of the controller /// </summary> /// <param name="newState">The new state</param> internal void UpdateState(VRGenericControllerState newState) { this.State = newState; if (this.State.IsConnected) { this.Transform.LocalPosition = this.State.Pose.Position; this.Transform.LocalOrientation = this.State.Pose.Orientation; } if (this.TrackingLostMode == VRTrackingLostMode.DisableEntity && (this.Owner.Enabled != this.State.IsConnected)) { this.Owner.Enabled = this.State.IsConnected; } }
internal void ToGenericController(out VRGenericControllerState genericController) { genericController = new VRGenericControllerState() { IsConnected = true, Role = this.Role, ThumbStick = this.Trackpad, Trigger = this.Trigger, TriggerButton = this.TriggerButton, Grip = this.Grip, Menu = this.ApplicationMenu, ThumbStickButton = this.TrackpadButton, Button1 = this.A, Button2 = ButtonState.Released, Pose = this.Pose }; }