/// <summary> /// Parses a GamePad configuration string. /// This string must follow the rules for SDL2 /// GameController outlined here: /// http://wiki.libsdl.org/SDL_GameControllerAddMapping /// </summary> /// <param name="configuration"></param> private void ParseConfiguration(string configuration) { if (String.IsNullOrEmpty(configuration)) { throw new ArgumentNullException(); } // The mapping string has the format "GUID,name,config" // - GUID is a unigue identifier returned by Joystick.GetGuid() // - name is a human-readable name for the controller // - config is a comma-separated list of configurations as follows: // - [gamepad axis or button name]:[joystick axis, button or hat number] string[] items = configuration.Split(ConfigurationSeparator, StringSplitOptions.RemoveEmptyEntries); if (items.Length < 3) { throw new ArgumentException(); } GamePadConfiguration map = this; map.Guid = new Guid(items[0]); map.Name = items[1]; for (int i = 2; i < items.Length; i++) { string[] config = items[i].Split(':'); GamePadConfigurationTarget target = ParseTarget(config[0]); GamePadConfigurationSource source = ParseSource(config[1]); configuration_items.Add(new GamePadConfigurationItem(source, target)); } }
public GamePadConfigurationItem(GamePadConfigurationSource source, GamePadConfigurationTarget target) { Source = source; Target = target; }
bool IsMapped(GamePadConfigurationSource item) { return item.Type != ConfigurationType.Unmapped; }