Move cycle controllers code to InputViewModel

This commit is contained in:
Barış Hamil 2024-08-18 21:16:29 +03:00
parent 6a555ee9f7
commit e911876f76
2 changed files with 11 additions and 9 deletions

View File

@ -1210,15 +1210,9 @@ namespace Ryujinx.Ava
case KeyboardHotkeyState.CycleControllersPlayer6:
case KeyboardHotkeyState.CycleControllersPlayer7:
case KeyboardHotkeyState.CycleControllersPlayer8:
Dispatcher.UIThread.Invoke(() => {
var player = currentHotkeyState - KeyboardHotkeyState.CycleControllersPlayer1;
var ivm = new UI.ViewModels.Input.InputViewModel();
ivm.LoadDevices();
ivm.PlayerId = (Ryujinx.Common.Configuration.Hid.PlayerIndex) player;
ivm.Device = (ivm.Device + 1) % ivm.Devices.Count;
ivm.Save();
Console.WriteLine($"Cycling controller for player {ivm.PlayerId} to {ivm.Devices[ivm.Device].Name}");
});
var player = currentHotkeyState - KeyboardHotkeyState.CycleControllersPlayer1;
var ivm = new UI.ViewModels.Input.InputViewModel();
Dispatcher.UIThread.Invoke(() => ivm.CyclePlayerDevice(player));
break;
case KeyboardHotkeyState.None:
(_keyboardInterface as AvaloniaKeyboard).Clear();

View File

@ -885,5 +885,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
AvaloniaKeyboardDriver.Dispose();
}
public void CyclePlayerDevice(int player)
{
LoadDevices();
PlayerId = (PlayerIndex)player;
Device = (Device + 1) % Devices.Count;
Save();
}
}
}