/// <summary> /// Updates all control states. See InputControlState.cs. /// </summary> void UpdateStates() { // Hand zoom gesture stateHandZoom.ApplyState(inputSources.hands.dragControl); // Mouse wheel zoom stateMouseWheelZoom.AddState(false, new Vector2(0, inputSources.editor.mouseSource.ScrollWheelDelta)); stateMouseWheelZoom.AddState(false, new Vector2(0, inputSources.worldCursorMouse.mouseSource.ScrollWheelDelta)); stateMouseWheelZoom.FinalizeState(); // SixDOF zoom gesture stateSixDOFZoom.ApplyDelta(false, new Vector2(0, inputSources.touch6D.dragControl.delta.y)); // Controller input maps to scrolling, zooming, and freecam input stateLeftJoyScroll.ApplyDelta(false, inputSources.gamepad.leftJoyVector); stateLeftJoyTranslate.ApplyDelta(false, inputSources.gamepad.leftJoyVector); stateTrigZoom.ApplyDelta(false, new Vector2(0, -inputSources.gamepad.trigVector.x + inputSources.gamepad.trigVector.y)); stateRightJoyRotate.ApplyDelta(false, inputSources.gamepad.rightJoyVector); statePadTranslate.ApplyDelta(false, inputSources.gamepad.padVector); statePadCardinal.ApplyDelta(false, inputSources.gamepad.padVector); // Joystick cardinal state Vector2 joyPos = Vector2.zero; if (inputSources.gamepadCardinal.IsActiveTargetingSource()) { float mag = 0.7f; if (inputSources.gamepad.leftJoyVector.sqrMagnitude > mag * mag) { joyPos = inputSources.gamepad.leftJoyVector; // Quantize joyPos.x = (float)Mathf.RoundToInt(5f * joyPos.x) / 5f; joyPos.y = (float)Mathf.RoundToInt(5f * joyPos.y) / 5f; } } stateLeftJoyCardinal.ApplyDelta(false, joyPos); // Update drag gesture InputSourceBase curSource = inputSwitchLogic.CurrentTargetingSource as InputSourceBase; if (curSource != null && curSource.IsManipulating()) { stateTargetScroll.ApplyPos(true, curSource.GetManipulationPlaneProjection()); //Debug.Log("scroll state delta: " + stateTargetScroll.delta); } else { stateTargetScroll.ApplyPos(false, Vector2.zero); //Debug.Log("scroll (done) state delta: " + stateTargetScroll.delta); } }
/// <summary> /// Returns true if something is being updated /// </summary> public bool IsAnyManipulating() { bool manipulating = false; InputSourceBase[] sources = InputShellMap.Instance.inputSources.sources; for (int index = 0; index < sources.Length && !manipulating; index++) { InputSourceBase source = sources[index]; manipulating = (source != null && source.IsManipulating()); } return(manipulating); }