public static float GetActionFloat(TouchControllerHand hand, TouchControllerButton button, out bool wasChangedSinceLast, INPUT_DESIRED inputMode, bool fallback = false) { ActionStateGetInfo getfloat = new ActionStateGetInfo() { Action = GetAction(hand, button, inputMode), Type = StructureType.TypeActionStateGetInfo }; ActionStateFloat floatresult = new ActionStateFloat() { Type = StructureType.TypeActionStateFloat }; baseHMD.Xr.GetActionStateFloat(baseHMD.globalSession, in getfloat, ref floatresult); if (floatresult.IsActive == 0) { if (fallback) { // couldn't find an input... wasChangedSinceLast = false; return(0f); } // fallback if couldn't find float return(GetActionBool(hand, button, out wasChangedSinceLast, true) ? 1f : 0f); } wasChangedSinceLast = floatresult.ChangedSinceLastSync == 1; return(floatresult.CurrentState); }
public static Silk.NET.OpenXR.Action GetAction(TouchControllerHand hand, TouchControllerButton button, INPUT_DESIRED wantMode) { switch (button) { case TouchControllerButton.ButtonXA: return(MappedActions[(int)hand, (int)HAND_PATHS.ButtonXA]); case TouchControllerButton.ButtonYB: return(MappedActions[(int)hand, (int)HAND_PATHS.ButtonYB]); case TouchControllerButton.Grip: return(wantMode == INPUT_DESIRED.CLICK ? MappedActions[(int)hand, (int)HAND_PATHS.GripClick] : MappedActions[(int)hand, (int)HAND_PATHS.GripValue]); case TouchControllerButton.Menu: return(MappedActions[(int)hand, (int)HAND_PATHS.Menu]); case TouchControllerButton.System: return(MappedActions[(int)hand, (int)HAND_PATHS.System]); case TouchControllerButton.Trigger: return(wantMode == INPUT_DESIRED.CLICK ? MappedActions[(int)hand, (int)HAND_PATHS.TriggerClick] : MappedActions[(int)hand, (int)HAND_PATHS.TriggerValue]); case TouchControllerButton.Thumbstick: switch (wantMode) { default: case INPUT_DESIRED.CLICK: return(MappedActions[(int)hand, (int)HAND_PATHS.ThumbstickClick]); case INPUT_DESIRED.XAXIS: return(MappedActions[(int)hand, (int)HAND_PATHS.ThumbstickX]); case INPUT_DESIRED.YAXIS: return(MappedActions[(int)hand, (int)HAND_PATHS.ThumbstickY]); } case TouchControllerButton.Touchpad: switch (wantMode) { default: case INPUT_DESIRED.CLICK: return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadClick]); case INPUT_DESIRED.XAXIS: return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadX]); case INPUT_DESIRED.YAXIS: return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadY]); case INPUT_DESIRED.VALUE: return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadForce]); } default: throw new ArgumentException("Don't know button: " + button); } }