示例#1
0
        internal static void RevertRemap()
        {
            ControllerMap map = Utils.localInputPlayer.controllers.maps.GetMap(vrControllers, vrGameplayMap.id);

            int[] originalSkillBindingIDs = new int[]
            {
                (ModConfig.LeftDominantHand.Value ? 9 : 8),
                (ModConfig.LeftDominantHand.Value ? 8 : 9),
                (ModConfig.LeftDominantHand.Value ? 11 : 10),
                (ModConfig.LeftDominantHand.Value ? 10 : 11)
            };

            for (int i = 0; i < 4; i++)
            {
                ActionElementMap elementMap = vrGameplayMap.GetElementMapsWithAction(7 + i)[0];

                if (elementMap.elementIdentifierId == originalSkillBindingIDs[i])
                {
                    continue;
                }

                if (!map.ReplaceElementMap(elementMap.id, elementMap.actionId, elementMap.axisContribution, originalSkillBindingIDs[i], elementMap.elementType, elementMap.axisRange, elementMap.invert))
                {
                    VRMod.StaticLogger.LogError("An error occured while trying to revert skill binding overrides.");
                }
            }
        }
示例#2
0
        internal static void ApplyRemaps(string bodyName)
        {
            if (!skillBindingOverrides.Exists(x => x.bodyName == bodyName))
            {
                VRMod.StaticLogger.LogInfo(String.Format("No binding overrides found for \'{0}\'. Using default binding.", bodyName));
                RevertRemap();
                return;
            }

            VRMod.StaticLogger.LogInfo(String.Format("Binding overrides were found for \'{0}\'. Applying overrides.", bodyName));
            SkillBindingOverride bindingOverride = skillBindingOverrides.FirstOrDefault(x => x.bodyName == bodyName);

            if (bindingOverride.bodyName == bodyName)
            {
                int[] originalSkillBindingIDs = new int[]
                {
                    (ModConfig.LeftDominantHand.Value ? 9 : 8),
                    (ModConfig.LeftDominantHand.Value ? 8 : 9),
                    (ModConfig.LeftDominantHand.Value ? 11 : 10),
                    (ModConfig.LeftDominantHand.Value ? 10 : 11)
                };

                ActionElementMap[] newMapOrder = new ActionElementMap[]
                {
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.dominantTrigger)[0],
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.nonDominantTrigger)[0],
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.nonDominantGrip)[0],
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.dominantGrip)[0]
                };

                ControllerMap controllerMap = Utils.localInputPlayer.controllers.maps.GetMap(vrControllers, vrGameplayMap.id);

                for (int i = 0; i < 4; i++)
                {
                    ActionElementMap elementMap = newMapOrder[i];

                    if (elementMap.elementIdentifierId == originalSkillBindingIDs[i])
                    {
                        continue;
                    }

                    if (!controllerMap.ReplaceElementMap(elementMap.id, elementMap.actionId, elementMap.axisContribution, originalSkillBindingIDs[i], elementMap.elementType, elementMap.axisRange, elementMap.invert))
                    {
                        VRMod.StaticLogger.LogError("An error occured while trying to override skill bindings.");
                    }
                }
            }
        }
    // Polls for Keyboard Input
    private void KeyboardPoll()
    {
        ControllerPollingInfo pollingInfo = new ControllerPollingInfo();

        foreach (ControllerPollingInfo info in ReInput.controllers.Keyboard.PollForAllKeys())
        {
            KeyCode key = info.keyboardKey;

            // If Key is AltGr, Command, Windows or Apple, skip it as these are keys are not supported
            if (key == KeyCode.AltGr)
            {
                continue;
            }

            if (key == KeyCode.LeftCommand || key == KeyCode.LeftWindows || key == KeyCode.LeftApple)
            {
                continue;
            }

            if (key == KeyCode.RightCommand || key == KeyCode.RightWindows || key == KeyCode.RightApple)
            {
                continue;
            }

            if (key != KeyCode.None)
            {
                // If the key is not pressed this frame
                if (!ReInput.controllers.Keyboard.GetKeyDown(key))
                {
                    return;
                }

                pollingInfo = info;
                break;
            }
        }

        // If unsuccessful
        if (!pollingInfo.success)
        {
            return;
        }

        // Stop polling
        bPolling = false;

        // Current Action Map
        ActionElementMap map = bAltMap ? aAltElementMaps[currentUIInputRow.SecondaryActionID] :
                               aElementMaps[currentUIInputRow.PrimaryActionID];

        // Replace Element based on which map is being assigned to
        if (bAltMap)
        {
            altControlMap.ReplaceElementMap(map.id, map.actionId, map.axisContribution, pollingInfo.keyboardKey, ModifierKeyFlags.None);
            currentUIInputRow.secondaryButtonText.text = pollingInfo.elementIdentifierName;
        }
        else
        {
            controlMap.ReplaceElementMap(map.id, map.actionId, map.axisContribution, pollingInfo.keyboardKey, ModifierKeyFlags.None);
            currentUIInputRow.primaryButtonText.text = pollingInfo.elementIdentifierName;
        }

        SettingsManager.bOptionChanged = true;
        CloseAssignmentWindow();
    }