Example #1
0
        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);
        }
Example #2
0
        public static bool GetActionBool(TouchControllerHand hand, TouchControllerButton button, out bool wasChangedSinceLast, bool fallback = false)
        {
            ActionStateGetInfo getbool = new ActionStateGetInfo()
            {
                Action = GetAction(hand, button, INPUT_DESIRED.CLICK),
                Type   = StructureType.TypeActionStateGetInfo
            };

            ActionStateBoolean boolresult = new ActionStateBoolean()
            {
                Type = StructureType.TypeActionStateBoolean
            };

            baseHMD.Xr.GetActionStateBoolean(baseHMD.globalSession, in getbool, ref boolresult);

            if (boolresult.IsActive == 0)
            {
                if (fallback)
                {
                    // couldn't find an input...
                    wasChangedSinceLast = false;
                    return(false);
                }

                // fallback if couldn't find bool
                return(GetActionFloat(hand, button, out wasChangedSinceLast, INPUT_DESIRED.VALUE, true) >= 0.75f);
            }

            wasChangedSinceLast = boolresult.ChangedSinceLastSync == 1;
            return(boolresult.CurrentState == 1);
        }