Move cycle controllers code to InputViewModel
This commit is contained in:
parent
6a555ee9f7
commit
e911876f76
2 changed files with 11 additions and 9 deletions
|
@ -1210,15 +1210,9 @@ namespace Ryujinx.Ava
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer6:
|
case KeyboardHotkeyState.CycleControllersPlayer6:
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer7:
|
case KeyboardHotkeyState.CycleControllersPlayer7:
|
||||||
case KeyboardHotkeyState.CycleControllersPlayer8:
|
case KeyboardHotkeyState.CycleControllersPlayer8:
|
||||||
Dispatcher.UIThread.Invoke(() => {
|
|
||||||
var player = currentHotkeyState - KeyboardHotkeyState.CycleControllersPlayer1;
|
var player = currentHotkeyState - KeyboardHotkeyState.CycleControllersPlayer1;
|
||||||
var ivm = new UI.ViewModels.Input.InputViewModel();
|
var ivm = new UI.ViewModels.Input.InputViewModel();
|
||||||
ivm.LoadDevices();
|
Dispatcher.UIThread.Invoke(() => ivm.CyclePlayerDevice(player));
|
||||||
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}");
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case KeyboardHotkeyState.None:
|
case KeyboardHotkeyState.None:
|
||||||
(_keyboardInterface as AvaloniaKeyboard).Clear();
|
(_keyboardInterface as AvaloniaKeyboard).Clear();
|
||||||
|
|
|
@ -885,5 +885,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
|
|
||||||
AvaloniaKeyboardDriver.Dispose();
|
AvaloniaKeyboardDriver.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CyclePlayerDevice(int player)
|
||||||
|
{
|
||||||
|
LoadDevices();
|
||||||
|
PlayerId = (PlayerIndex)player;
|
||||||
|
Device = (Device + 1) % Devices.Count;
|
||||||
|
Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue