コード例 #1
0
        public override string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IGamepadAbstraction gamepadAbstraction, IInputTemplate inputTemplate, IGameInfo gameInfo)
        {
            var controllerMappings = gamepadAbstraction.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ?
                                     controllerTemplate.KeyboardControllerMappings : controllerTemplate.GamepadControllerMappings;

            string deviceName            = gamepadAbstraction.DeviceName;
            IList <IInputDevice> devices = new InputManager().GetGamepads();

            if (deviceName == null)
            {
                deviceName = String.Empty;
            }

            int realWiimoteAmount = devices.Count(device => device.DI_ProductName.Contains("RVL-CNT"));

            if (controllerDefinition.ControllerID == "WII_COMBINED_CONTROLLER")
            {
                //All wiimotes have the same attachment
                int wiimote_extension = this.ConfigurationFlagStore.GetValue(gameInfo, "wiimote_extension", ConfigurationFlagTypes.SELECT_FLAG);
                controllerMappings["default"].KeyMappings["EXTENSION"] = this.ConfigurationFlags["wiimote_extension"].SelectValues[wiimote_extension].Value;

                if (playerIndex <= realWiimoteAmount)
                {
                    controllerMappings["default"].KeyMappings["SOURCE"] = "2"; //Real Wiimotes take precedence
                }
                else
                {
                    controllerMappings["default"].KeyMappings["SOURCE"] = "1"; //Emulated Wiimote
                }
            }

            if (deviceName.Equals(InputDeviceNames.KeyboardDevice, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] = "DInput/0/Keyboard Mouse";
                return(this.CompileController(playerIndex, platformInfo, controllerDefinition, controllerTemplate,
                                              gamepadAbstraction, inputTemplate, controllerMappings, gameInfo));
            }
            string xinputDevice = "XInput/{0}/Gamepad";
            string dintpuDevice = "DInput/{0}/{1}";

            if (deviceName.Equals(InputDeviceNames.XInputDevice1, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 0);
            }
            else if (deviceName.Equals(InputDeviceNames.XInputDevice2, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 1);
            }
            else if (deviceName.Equals(InputDeviceNames.XInputDevice3, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 2);
            }
            else if (deviceName.Equals(InputDeviceNames.XInputDevice4, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 3);
            }
            else if (devices.Select(device => device.DI_ProductName).Contains(deviceName))
            {
                var device = devices.First(d => d.DI_ProductName == deviceName);
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(dintpuDevice, device.DI_ProductName, device.DeviceIndex);
            }
            return(this.CompileController(playerIndex, platformInfo, controllerDefinition, controllerTemplate, gamepadAbstraction, inputTemplate, controllerMappings, gameInfo));
        }
コード例 #2
0
        public override string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IGamepadAbstraction gamepadAbstraction, IInputTemplate inputTemplate, IReadOnlyDictionary <string, IControllerMapping> controllerMappings, IGameInfo gameInfo)
        {
            if (gamepadAbstraction.ProfileType == ControllerProfileType.NULL_PROFILE)
            {
                return(string.Empty);
            }
            var template = new StringBuilder(inputTemplate.StringTemplate);

            foreach (IControllerInput input in controllerDefinition.ControllerInputs.Values)
            {
                string templateKey   = controllerMappings["default"].InputMappings[input.InputName];
                string inputSetting  = gamepadAbstraction[input.GamepadAbstraction];
                string emulatorValue = gamepadAbstraction.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ?
                                       inputTemplate.KeyboardMappings.First().Value[inputSetting] : inputTemplate.GamepadMappings.First().Value[inputSetting];
                template.Replace($"{{{templateKey}}}", emulatorValue);
            }

            if (platformInfo.PlatformID == StonePlatforms.NINTENDO_WII && controllerDefinition.ControllerID == "GCN_CONTROLLER")
            {
                template.Replace("{N}", (playerIndex - 4).ToString()); //Account for GCPad being in controller positions 5-8.
            }
            else
            {
                template.Replace("{N}", playerIndex.ToString()); //Player Index
            }

            foreach (string key in inputTemplate.TemplateKeys)
            {
                template.Replace($"{{{key}}}",
                                 controllerMappings["default"].KeyMappings.ContainsKey(key)
                        ? controllerMappings["default"].KeyMappings[key]
                        : inputTemplate.NoBind);
            }
            return(template.ToString());
        }
コード例 #3
0
ファイル: EmulatorBridge.cs プロジェクト: faint32/snowflake-1
 public virtual string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IGamepadAbstraction gamepadAbstraction, IInputTemplate inputTemplate, IGameInfo gameInfo)
 {
     if (gamepadAbstraction.ProfileType == ControllerProfileType.NULL_PROFILE) return string.Empty;
     var controllerMappings = gamepadAbstraction.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ?
         controllerTemplate.KeyboardControllerMappings : controllerTemplate.GamepadControllerMappings;
     return this.CompileController(playerIndex, platformInfo, controllerDefinition, controllerTemplate, gamepadAbstraction, inputTemplate, controllerMappings, gameInfo);
 }
コード例 #4
0
ファイル: EmulatorBridge.cs プロジェクト: faint32/snowflake-1
        public virtual string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IGamepadAbstraction gamepadAbstraction, IInputTemplate inputTemplate, IReadOnlyDictionary<string, IControllerMapping> controllerMappings, IGameInfo gameInfo)
        {
            if (gamepadAbstraction.ProfileType == ControllerProfileType.NULL_PROFILE) return string.Empty;
            var template = new StringBuilder(inputTemplate.StringTemplate);
            foreach (IControllerInput input in controllerDefinition.ControllerInputs.Values)
            {
                string templateKey = controllerMappings["default"].InputMappings[input.InputName];
                string inputSetting = gamepadAbstraction[input.GamepadAbstraction];
                string emulatorValue = gamepadAbstraction.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ?
                    inputTemplate.KeyboardMappings.First().Value[inputSetting] : inputTemplate.GamepadMappings.First().Value[inputSetting];
                template.Replace($"{{{templateKey}}}", emulatorValue);
            }

            foreach (var key in inputTemplate.TemplateKeys)
            {
                template.Replace("{N}", playerIndex.ToString()); //Player Index
                if (controllerMappings["default"].KeyMappings.ContainsKey(key))
                {
                    template.Replace($"{{{key}}}", controllerMappings["default"].KeyMappings[key]); //Non-input keys
                }
                else
                {
                    template.Replace($"{{{key}}}", inputTemplate.NoBind); //Non-input keys
                }
            }
            return template.ToString();
        }
コード例 #5
0
 public ModifyControllerProfileEventArgs(ICoreService eventCoreInstance, IGamepadAbstraction previousProfile, IGamepadAbstraction modifiedProfile)
     : base(eventCoreInstance)
 {
     this.PreviousProfile = previousProfile;
     this.ModifiedProfile = modifiedProfile;
 }
コード例 #6
0
        private void SetGamepadAbstraction(string deviceName, IGamepadAbstraction gamepadAbstraction, bool overwrite)
        {
            SQLiteConnection dbConnection = this.GetConnection();
            dbConnection.Open();
            string command;
            if (overwrite)
            {
                command = "INSERT OR REPLACE";
            }
            else
            {
                command = "INSERT OR IGNORE";
            }

            using (var sqlCommand = new SQLiteCommand($@"{command} INTO gamepadabstraction VALUES(
                                                               @DeviceName,
                                                               @ProfileType,
                                                               @L1,
                                                               @L2,
                                                               @L3,
                                                               @R1,
                                                               @R2,
                                                               @R3,
                                                               @DpadUp,
                                                               @DpadDown,
                                                               @DpadLeft,
                                                               @DpadRight,
                                                               @RightAnalogXLeft,
                                                               @RightAnalogXRight,
                                                               @RightAnalogYUp,
                                                               @RightAnalogYDown,
                                                               @LeftAnalogXLeft,
                                                               @LeftAnalogXRight,
                                                               @LeftAnalogYUp,
                                                               @LeftAnalogYDown,
                                                               @btnStart,
                                                               @btnSelect,
                                                               @btnA,
                                                               @btnB,
                                                               @btnX,
                                                               @btnY)", dbConnection))
            {
                sqlCommand.Parameters.AddWithValue("@DeviceName", deviceName);
                sqlCommand.Parameters.AddWithValue("@ProfileType", (int)gamepadAbstraction.ProfileType);
                sqlCommand.Parameters.AddWithValue("@L1", gamepadAbstraction.L1);
                sqlCommand.Parameters.AddWithValue("@L2", gamepadAbstraction.L2);
                sqlCommand.Parameters.AddWithValue("@L3", gamepadAbstraction.L3);
                sqlCommand.Parameters.AddWithValue("@R1", gamepadAbstraction.R1);
                sqlCommand.Parameters.AddWithValue("@R2", gamepadAbstraction.R2);
                sqlCommand.Parameters.AddWithValue("@R3", gamepadAbstraction.R3);
                sqlCommand.Parameters.AddWithValue("@DpadUp", gamepadAbstraction.DpadUp);
                sqlCommand.Parameters.AddWithValue("@DpadDown", gamepadAbstraction.DpadDown);
                sqlCommand.Parameters.AddWithValue("@DpadLeft", gamepadAbstraction.DpadLeft);
                sqlCommand.Parameters.AddWithValue("@DpadRight", gamepadAbstraction.DpadRight);
                sqlCommand.Parameters.AddWithValue("@RightAnalogXLeft", gamepadAbstraction.RightAnalogXLeft);
                sqlCommand.Parameters.AddWithValue("@RightAnalogXRight", gamepadAbstraction.RightAnalogXRight);
                sqlCommand.Parameters.AddWithValue("@RightAnalogYUp", gamepadAbstraction.RightAnalogYUp);
                sqlCommand.Parameters.AddWithValue("@RightAnalogYDown", gamepadAbstraction.RightAnalogYDown);
                sqlCommand.Parameters.AddWithValue("@LeftAnalogXLeft", gamepadAbstraction.LeftAnalogXLeft);
                sqlCommand.Parameters.AddWithValue("@LeftAnalogXRight", gamepadAbstraction.LeftAnalogXRight);
                sqlCommand.Parameters.AddWithValue("@LeftAnalogYUp", gamepadAbstraction.LeftAnalogYUp);
                sqlCommand.Parameters.AddWithValue("@LeftAnalogYDown", gamepadAbstraction.LeftAnalogYDown);
                sqlCommand.Parameters.AddWithValue("@btnStart", gamepadAbstraction.Start);
                sqlCommand.Parameters.AddWithValue("@btnSelect", gamepadAbstraction.Select);
                sqlCommand.Parameters.AddWithValue("@btnA", gamepadAbstraction.A);
                sqlCommand.Parameters.AddWithValue("@btnB", gamepadAbstraction.B);
                sqlCommand.Parameters.AddWithValue("@btnX", gamepadAbstraction.X);
                sqlCommand.Parameters.AddWithValue("@btnY", gamepadAbstraction.Y);
                sqlCommand.ExecuteNonQuery();
            }
            dbConnection.Close();
        }
コード例 #7
0
 public void SetGamepadAbstraction(string deviceName, IGamepadAbstraction gamepadAbstraction)
 {
     this.SetGamepadAbstraction(deviceName, gamepadAbstraction, true);
 }
コード例 #8
0
        public override string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IGamepadAbstraction gamepadAbstraction, IInputTemplate inputTemplate, IGameInfo gameInfo)
        {
            var controllerMappings = gamepadAbstraction.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ?
               controllerTemplate.KeyboardControllerMappings : controllerTemplate.GamepadControllerMappings;

            string deviceName = gamepadAbstraction.DeviceName;
            IList<IInputDevice> devices = new InputManager().GetGamepads();
            if (deviceName == null) deviceName = String.Empty;

            int realWiimoteAmount = devices.Count(device => device.DI_ProductName.Contains("RVL-CNT"));

            if(controllerDefinition.ControllerID == "WII_COMBINED_CONTROLLER")
            {
                //All wiimotes have the same attachment
                int wiimote_extension = this.ConfigurationFlagStore.GetValue(gameInfo, "wiimote_extension", ConfigurationFlagTypes.SELECT_FLAG);
                controllerMappings["default"].KeyMappings["EXTENSION"] = this.ConfigurationFlags["wiimote_extension"].SelectValues[wiimote_extension].Value;

                if (playerIndex <= realWiimoteAmount)
                {
                    controllerMappings["default"].KeyMappings["SOURCE"] = "2"; //Real Wiimotes take precedence
                }
                else
                {
                    controllerMappings["default"].KeyMappings["SOURCE"] = "1"; //Emulated Wiimote
                }
            }

            if (deviceName.Equals(InputDeviceNames.KeyboardDevice, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] = "DInput/0/Keyboard Mouse";
                return this.CompileController(playerIndex, platformInfo, controllerDefinition, controllerTemplate,
                    gamepadAbstraction, inputTemplate, controllerMappings, gameInfo);
            }
            string xinputDevice = "XInput/{0}/Gamepad";
            string dintpuDevice = "DInput/{0}/{1}";
            if (deviceName.Equals(InputDeviceNames.XInputDevice1, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 0);
            }
            else if (deviceName.Equals(InputDeviceNames.XInputDevice2, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 1);
            }
            else if (deviceName.Equals(InputDeviceNames.XInputDevice3, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 2);
            }
            else if (deviceName.Equals(InputDeviceNames.XInputDevice4, StringComparison.InvariantCultureIgnoreCase))
            {
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(xinputDevice, 3);
            }
            else if (devices.Select(device => device.DI_ProductName).Contains(deviceName))
            {
                var device = devices.First(d => d.DI_ProductName == deviceName);
                controllerMappings["default"].KeyMappings["DEVICE"] =
                    String.Format(dintpuDevice, device.DI_ProductName, device.DeviceIndex);
            }
            return this.CompileController(playerIndex, platformInfo, controllerDefinition, controllerTemplate, gamepadAbstraction, inputTemplate, controllerMappings, gameInfo);
        }
コード例 #9
0
        public override string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IGamepadAbstraction gamepadAbstraction, IInputTemplate inputTemplate, IReadOnlyDictionary<string, IControllerMapping> controllerMappings, IGameInfo gameInfo)
        {
            if (gamepadAbstraction.ProfileType == ControllerProfileType.NULL_PROFILE) return string.Empty;
            var template = new StringBuilder(inputTemplate.StringTemplate);
            foreach (IControllerInput input in controllerDefinition.ControllerInputs.Values)
            {
                string templateKey = controllerMappings["default"].InputMappings[input.InputName];
                string inputSetting = gamepadAbstraction[input.GamepadAbstraction];
                string emulatorValue = gamepadAbstraction.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ?
                    inputTemplate.KeyboardMappings.First().Value[inputSetting] : inputTemplate.GamepadMappings.First().Value[inputSetting];
                template.Replace($"{{{templateKey}}}", emulatorValue);
            }

            if (platformInfo.PlatformID == StonePlatforms.NINTENDO_WII && controllerDefinition.ControllerID == "GCN_CONTROLLER")
            {
                template.Replace("{N}", (playerIndex - 4).ToString()); //Account for GCPad being in controller positions 5-8.
            }
            else
            {
                template.Replace("{N}", playerIndex.ToString()); //Player Index
            }

            foreach (string key in inputTemplate.TemplateKeys)
            {
                template.Replace($"{{{key}}}",
                    controllerMappings["default"].KeyMappings.ContainsKey(key)
                        ? controllerMappings["default"].KeyMappings[key]
                        : inputTemplate.NoBind);
            }
            return template.ToString();
        }