public void InputTemplateToAbstractConfigurationNodeXmlSerializer_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); IDeviceInputMapping mapping = new TestInputMapping(); var input = new InputTemplate <IRetroArchInput>(mapcol).Template; var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/")); var context = new ConfigurationTraversalContext(); var list = context.TraverseInputTemplate(input, mapping, 0); var xmlSerializer = new SimpleXmlConfigurationSerializer("Config"); string outputXml = xmlSerializer.Transform(list); XDocument doc = XDocument.Parse(outputXml); Assert.NotEmpty(doc.Nodes()); }
public async Task DeleteMappingsAsync_Test() { var stoneProvider = new StoneProvider(); foreach (var testmappings in stoneProvider.Controllers.Values) { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>(); optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}"); var elementStore = new ControllerElementMappingProfileStore(optionsBuilder); await elementStore.AddMappingsAsync(mapcol, "default"); var retStore = await elementStore.GetMappingsAsync(mapcol.ProfileGuid); Assert.NotNull(retStore); await elementStore.DeleteMappingsAsync(mapcol.ProfileGuid); var deletedRetStore = elementStore.GetMappings(mapcol.ProfileGuid); Assert.Null(deletedRetStore); } }
public async Task AddGamepadAsyncMappings_Test() { var stoneProvider = new StoneProvider(); foreach (var testmappings in stoneProvider.Controllers.Values) { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>(); optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}"); var elementStore = new ControllerElementMappingProfileStore(optionsBuilder); await elementStore.AddMappingsAsync(mapcol, "default"); var retStore = await elementStore.GetMappingsAsync(mapcol.ProfileGuid); foreach (var element in retStore) { Assert.Contains(element.LayoutElement, mapcol.Select(x => x.LayoutElement)); Assert.Equal(element.DeviceCapability, mapcol.First(x => x.LayoutElement == element.LayoutElement).DeviceCapability); } } }
public void GetMultipleMappings_Test() { var stoneProvider = new StoneProvider(); foreach (var testmappings in stoneProvider.Controllers.Values) { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var mapcol2 = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>(); optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}"); var elementStore = new ControllerElementMappingProfileStore(optionsBuilder); elementStore.AddMappings(mapcol, "default"); elementStore.AddMappings(mapcol2, "default2"); Assert.Equal(2, elementStore.GetProfileNames(mapcol.ControllerID, InputDriver.Keyboard, mapcol.DeviceName, IDeviceEnumerator.VirtualVendorID) .Count()); elementStore.DeleteMappings(mapcol.ProfileGuid); Assert.Single(elementStore.GetProfileNames(mapcol.ControllerID, InputDriver.Keyboard, mapcol.DeviceName, IDeviceEnumerator.VirtualVendorID)); elementStore.DeleteMappings(mapcol.ControllerID, mapcol.DeviceName, IDeviceEnumerator.VirtualVendorID); Assert.Empty(elementStore.GetProfileNames(mapcol.ControllerID, InputDriver.Keyboard, mapcol.DeviceName, IDeviceEnumerator.VirtualVendorID)); } }
public void InputTemplateToAbstractConfigurationNodeCfgSerializer_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); IDeviceInputMapping mapping = new TestInputMapping(); var input = new InputConfiguration <IRetroArchInput>(mapcol); var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/")); var context = new ConfigurationTraversalContext(); var list = context.TraverseInputTemplate(input, mapping, 0); var cfgSerializer = new SimpleCfgConfigurationSerializer(); string outputCfg = cfgSerializer.Visit(list); Assert.NotEqual(string.Empty, outputCfg); // todo: test cfg parse }
public void NestedSetter_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var x = new InputTemplate <IRetroArchInput>(mapcol); x[ControllerElement.ButtonA] = DeviceCapability.Hat0S; Assert.Equal(DeviceCapability.Hat0S, x.Template.Configuration.InputPlayerABtn); }
public void ControllerElementMappingActualLayout_Test() { var stone = new StoneProvider(); var nes = stone.Controllers["NES_CONTROLLER"]; var mapcol = new ControllerElementMappingProfile("Keyboard", nes, InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new KeyboardDeviceInstance().DefaultLayout); Assert.Equal(DeviceCapability.None, mapcol[ControllerElement.Button0]); Assert.Equal(nes.Layout.Count(), mapcol.Count()); }
public void GetProfileNames_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>(); optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}"); var elementStore = new ControllerElementMappingProfileStore(optionsBuilder); elementStore.AddMappings(mapcol, "default"); }
public static IControllerElementMappingProfile AsControllerElementMappings(this ControllerElementMappingCollectionModel @this) { var mappings = new ControllerElementMappingProfile(@this.DeviceName, @this.ControllerID, @this.DriverType, @this.VendorID, @this.ProfileID); foreach (var mapping in @this.MappedElements) { mappings.Add(new ControllerElementMapping(mapping.LayoutElement, mapping.DeviceCapability)); } return(mappings); }
public void InputTemplateGetterSetter_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var template = new InputTemplate <IRetroArchInput>(mapcol, 0); Assert.Equal(DeviceCapability.Button0, template.Template.InputPlayerABtn); template[ControllerElement.ButtonA] = DeviceCapability.Button1; template[ControllerElement.ButtonA] = DeviceCapability.Key2; template[ControllerElement.ButtonA] = DeviceCapability.Axis0Negative; Assert.Equal(DeviceCapability.Button1, template.Template.InputPlayerABtn); Assert.Equal(DeviceCapability.Key2, template.Template.InputPlayerA); Assert.Equal(DeviceCapability.Axis0Negative, template.Template.InputPlayerAAxis); }
public void InputTemplateToAbstractConfigurationNode_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); IDeviceInputMapping mapping = new TestInputMapping(); var input = new InputTemplate <IRetroArchInput>(mapcol).Template; var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/")); var context = new ConfigurationTraversalContext(("game", dir)); var node = context.TraverseInputTemplate(input, mapping, 0); }
public async Task UpdateMappedInputCollectionGamepadAsync_Test() { var stoneProvider = new StoneProvider(); foreach (var testmappings in stoneProvider.Controllers.Values) { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>(); optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}"); var elementStore = new ControllerElementMappingProfileStore(optionsBuilder); await elementStore.AddMappingsAsync(mapcol, "default"); // map buttonA to buttonB. mapcol[ControllerElement.ButtonA] = DeviceCapability.Button1; elementStore.UpdateMappings(mapcol); mapcol[ControllerElement.ButtonB] = DeviceCapability.Axis0Positive; elementStore.UpdateMappings(mapcol); var retStore = await elementStore.GetMappingsAsync(mapcol.ProfileGuid); foreach (var element in retStore) { Assert.Contains(element.LayoutElement, mapcol.Select(x => x.LayoutElement)); Assert.Equal(element.DeviceCapability, mapcol.First(x => x.LayoutElement == element.LayoutElement).DeviceCapability); } // Switch left joycon has no A button if (testmappings.Layout[ControllerElement.ButtonA] != null) { Assert.Equal(DeviceCapability.Button1, retStore[ControllerElement.ButtonA]); } } }