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 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]); } } }