Beispiel #1
0
        private void AddGamepadInput(CommonXRInputs gamepadButtonOrAxis, bool isNewBinding)
        {
            Sinput.CheckGamepads();

            if (isNewBinding)
            {
                commonXRMappings.Add(gamepadButtonOrAxis);
            }
            List <DeviceInput> applicableMapInputs = CommonGamepadMappings.GetApplicableMaps(CommonGamepadInputs.NOBUTTON, gamepadButtonOrAxis, Sinput.gamepads);

            for (int i = 0; i < applicableMapInputs.Count; i++)
            {
                applicableMapInputs[i].commonMappingType = CommonGamepadInputs.NOBUTTON;
            }

            AddGamepadInputs(applicableMapInputs);
        }
Beispiel #2
0
        private void AddGamepadInput(CommonGamepadInputs gamepadButtonOrAxis, bool isNewBinding)
        {
            Sinput.CheckGamepads();

            if (isNewBinding)
            {
                commonMappings.Add(gamepadButtonOrAxis);
            }
            List <DeviceInput> applicableMapInputs = CommonGamepadMappings.GetApplicableMaps(gamepadButtonOrAxis, Sinput.gamepads);

            string[] gamepads = Sinput.gamepads;

            //find which common mapped inputs apply here, but already have custom binding loaded, and disregard those common mappings
            for (int ai = 0; ai < applicableMapInputs.Count; ai++)
            {
                bool samePad = false;
                for (int i = 0; i < inputs.Count; i++)
                {
                    if (inputs[i].inputType == InputDeviceType.GamepadAxis || inputs[i].inputType == InputDeviceType.GamepadButton)
                    {
                        if (inputs[i].isCustom)
                        {
                            for (int ais = 0; ais < applicableMapInputs[ai].allowedSlots.Length; ais++)
                            {
                                for (int toomanyints = 0; toomanyints < inputs[i].allowedSlots.Length; toomanyints++)
                                {
                                    if (applicableMapInputs[ai].allowedSlots[ais] == inputs[i].allowedSlots[toomanyints])
                                    {
                                        samePad = true;
                                    }
                                }
                                if (gamepads[applicableMapInputs[ai].allowedSlots[ais]] == inputs[i].deviceName.ToUpper())
                                {
                                    samePad = true;
                                }
                            }
                            if (samePad)
                            {
                                //if I wanna be copying input display names, here's the place to do it
                                //TODO: decide if I wanna do this
                                //pro: it's good if the common mapping is accurate but the user wants to rebind
                                //con: it's bad if the common mapping is bad or has a generic gamepad name and so it mislables different inputs
                                //maybe I should do this, but with an additional check so it's not gonna happen with say, a device labelled "wireless controller"?
                            }
                        }
                    }
                }
                if (samePad)
                {
                    //we already have a custom bound control for this input, we don't need more
                    applicableMapInputs.RemoveAt(ai);
                    ai--;
                }
            }

            //add whichever common mappings still apply
            for (int i = 0; i < applicableMapInputs.Count; i++)
            {
                inputs.Add(applicableMapInputs[i]);
            }
        }