/// <summary> /// Aggregates all actions defined for a controller. /// </summary> /// <param name="seed">The object that contains the Action definitions.</param> /// <param name="ignoreCachable">If set to <see langword="true"/>, all actions will be treated equally. The result will then contain the same lists for cachable and uncachable.</param> /// <returns></returns> public static AggregationResult Aggregate( IControllerTemplate seed, bool ignoreCachable = false ) { StringBuilder actions = new StringBuilder(); StringBuilder uncachableActions = new StringBuilder(); // If ignoreCachable is set, we'll aggregate them all into "actions" foreach( Action action in seed.Actions ) { if( action.Uncachable && !ignoreCachable ) { uncachableActions.Append( action.Name + "," ); } else { actions.Append( action.Name + "," ); } } string actionsCachable = actions.ToString(); actionsCachable = ( actionsCachable.Length > 0 ) ? actionsCachable.Substring( 0, actionsCachable.Length - 1 ) : actionsCachable; string actionsUncachable = uncachableActions.ToString(); actionsUncachable = ( actionsUncachable.Length > 0 ) ? actionsUncachable.Substring( 0, actionsUncachable.Length - 1 ) : actionsUncachable; var controllerData = new {controllerName = NameHelper.UpperCamelCase( seed.Name ), actionList = actionsCachable }; var uncachableControllerData = new {controllerName = NameHelper.UpperCamelCase( seed.Name ), actionList = actionsUncachable }; AggregationResult result = new AggregationResult { Cachable = ActionTemplate.FormatSmart( controllerData ), Uncachable = ActionTemplate.FormatSmart( uncachableControllerData ) }; if( ignoreCachable ) { result.Uncachable = result.Cachable; } return result; }
/* Win32 End */ public override string CompileController(int playerIndex, IPlatformInfo platformInfo, IControllerDefinition controllerDefinition, IControllerTemplate controllerTemplate, IControllerProfile controllerProfile, IInputTemplate inputTemplate) { var controllerMappings = controllerProfile.ProfileType == ControllerProfileType.KEYBOARD_PROFILE ? controllerTemplate.KeyboardControllerMappings : controllerTemplate.GamepadControllerMappings; string deviceName = this.CoreInstance.ControllerPortsDatabase.GetDeviceInPort(platformInfo, playerIndex); IList <IInputDevice> devices = new InputManager().GetGamepads(); if (!devices.Select(device => device.DI_ProductName).Contains(deviceName) || !(devices.Where(device => device.XI_IsXInput).Count() == 0)) { //todo fix this if (deviceName == InputDeviceNames.XInputDevice1) { var xinputDevice = devices.Where(device => device.XI_IsXInput).Where(device => device.XI_GamepadIndex == 1).FirstOrDefault(); if (!xinputDevice.Equals(null)) { controllerMappings["default"].KeyMappings["JOYPAD_INDEX"] = xinputDevice.DeviceIndex.ToString(); } } if (deviceName == InputDeviceNames.XInputDevice2) { var xinputDevice = devices.Where(device => device.XI_IsXInput).Where(device => device.XI_GamepadIndex == 1).FirstOrDefault(); if (!xinputDevice.Equals(null)) { controllerMappings["default"].KeyMappings["JOYPAD_INDEX"] = xinputDevice.DeviceIndex.ToString(); } } if (deviceName == InputDeviceNames.XInputDevice3) { var xinputDevice = devices.Where(device => device.XI_IsXInput).Where(device => device.XI_GamepadIndex == 1).FirstOrDefault(); if (!xinputDevice.Equals(null)) { controllerMappings["default"].KeyMappings["JOYPAD_INDEX"] = xinputDevice.DeviceIndex.ToString(); } } if (deviceName == InputDeviceNames.XInputDevice4) { var xinputDevice = devices.Where(device => device.XI_IsXInput).Where(device => device.XI_GamepadIndex == 1).FirstOrDefault(); if (!xinputDevice.Equals(null)) { controllerMappings["default"].KeyMappings["JOYPAD_INDEX"] = xinputDevice.DeviceIndex.ToString(); } } if (devices.Select(device => device.DI_ProductName).Contains(deviceName)) { controllerMappings["default"].KeyMappings["JOYPAD_INDEX"] = devices.Where(device => device.DI_ProductName == deviceName).First().DeviceIndex.ToString(); } } else { controllerProfile = controllerDefinition.ProfileStore[InputDeviceNames.KeyboardDevice]; controllerMappings = controllerTemplate.KeyboardControllerMappings; playerIndex = 1; //Force Keyboard player 1 if no controllers detected } return(base.CompileController(playerIndex, platformInfo, controllerDefinition, controllerTemplate, controllerProfile, inputTemplate, controllerMappings)); }
public CodeService() { this.viewTemplate = new ViewNormal(); this.controllerTemplate = new ControllerTemplate(); }
private void DrawLabel(ControllerUIElement uiElement, InputAction action, ControllerMap controllerMap, IControllerTemplate template, IControllerTemplateElement element) { if (element.source == null) { return; // this element cannot map to a source } ActionElementMap aem; // A Controller Template Element Source contains Targets that each point to // a Controller.Element or part of a Controller.Element (such as one pole of an Axis). // Handle Axis-type Template Element if (element.source.type == ControllerTemplateElementSourceType.Axis) { // Cast the source to an Axis source so we can access the 3 possible Targets IControllerTemplateAxisSource source = (element.source as IControllerTemplateAxisSource); // A Template axis source can be either a full-axis binding or a split-axis binding // Handle split-axis source if (source.splitAxis) { // A split-axis source has a Positive Target and a Negative Target, one for each side of the axis. // Positive Target aem = controllerMap.GetFirstElementMapWithElementTarget(source.positiveTarget, action.id, true); if (aem != null) { uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Positive); } // Negative Target aem = controllerMap.GetFirstElementMapWithElementTarget(source.negativeTarget, action.id, true); if (aem != null) { uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Negative); } // Handle full-axis source } else { // A full-axis sources has just a single full target. // Full Target aem = controllerMap.GetFirstElementMapWithElementTarget(source.fullTarget, action.id, true); if (aem != null) { // a full target was mapped uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Full); } else { // no full mapping was found, look for separate positive/negative mappings // Positive side aem = controllerMap.GetFirstElementMapWithElementTarget( new ControllerElementTarget(source.fullTarget) { axisRange = AxisRange.Positive }, action.id, true ); if (aem != null) { uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Positive); } // Negative side aem = controllerMap.GetFirstElementMapWithElementTarget( new ControllerElementTarget(source.fullTarget) { axisRange = AxisRange.Negative }, action.id, true ); if (aem != null) { uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Negative); } } } // Handle Button-type Template Element } else if (element.source.type == ControllerTemplateElementSourceType.Button) { // Cast the source to an button source IControllerTemplateButtonSource source = (element.source as IControllerTemplateButtonSource); // Target aem = controllerMap.GetFirstElementMapWithElementTarget(source.target, action.id, true); if (aem != null) { uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Full); } } }
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)); }
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()); }
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); }
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(); }
/// <summary> /// Generates the ExtBase controller file name that must be used for the implementation of a controller for a given plugin. /// </summary> /// <param name="extension"></param> /// <param name="plugin"></param> /// <returns></returns> public static string GetExtbaseControllerImplementationFileName( Extension extension, IControllerTemplate plugin ) { return String.Format( "{0}{1}ControllerImplementation.php", UpperCamelCase( extension.Key ), UpperCamelCase( plugin.Name ) ); }
/// <summary> /// Generates the Extbase controller class name for a given plugin. /// </summary> /// <param name="extension"></param> /// <param name="plugin"></param> /// <returns></returns> public static string GetExtbaseControllerFileName( Extension extension, IControllerTemplate plugin ) { return String.Format( "{0}Controller.php", UpperCamelCase( plugin.Name ) ); }
/// <summary> /// Generates the ExtBase controller class name for a given plugin. /// </summary> /// <param name="extension"></param> /// <param name="plugin"></param> /// <returns></returns> public static string GetExtbaseControllerClassName( Extension extension, IControllerTemplate plugin ) { return String.Format( "Tx_{0}_Controller_{1}Controller", UpperCamelCase( extension.Key ), UpperCamelCase( plugin.Name ) ); }
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); }
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(); }