Improvements to input and input configuration in the GUI. (#849)

* Improvements to input and input configuration in the GUI

* Requested changes

* nits

* more nits
This commit is contained in:
Xpl0itR 2020-05-03 03:00:53 +01:00 committed by GitHub
parent 5f3558fd51
commit 538fba826b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 5883 additions and 2511 deletions

View file

@ -13,6 +13,7 @@ using Ryujinx.HLE.HOS.Services.Hid;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
@ -28,7 +29,7 @@ namespace Ryujinx.Ui
private static HLE.Switch _emulationContext;
private static GLRenderer _gLWidget;
private static GlRenderer _glWidget;
private static AutoResetEvent _deviceExitStatus = new AutoResetEvent(false);
@ -37,40 +38,38 @@ namespace Ryujinx.Ui
private static bool _updatingGameTable;
private static bool _gameLoaded;
private static bool _ending;
#pragma warning disable CS0169
private static bool _debuggerOpened;
#pragma warning restore CS0169
#pragma warning disable CS0169
private static Ryujinx.Debugger.Debugger _debugger;
private static bool _debuggerOpened;
private static Debugger.Debugger _debugger;
#pragma warning restore CS0169
#pragma warning disable CS0169, CS0649, IDE0044
[GUI] Window _mainWin;
[GUI] MenuBar _menuBar;
[GUI] Box _footerBox;
[GUI] MenuItem _fullScreen;
[GUI] Box _statusBar;
[GUI] MenuItem _stopEmulation;
[GUI] MenuItem _fullScreen;
[GUI] CheckMenuItem _favToggle;
[GUI] MenuItem _firmwareInstallFile;
[GUI] MenuItem _firmwareInstallDirectory;
[GUI] MenuItem _firmwareInstallFile;
[GUI] Label _hostStatus;
[GUI] MenuItem _openDebugger;
[GUI] CheckMenuItem _iconToggle;
[GUI] CheckMenuItem _appToggle;
[GUI] CheckMenuItem _developerToggle;
[GUI] CheckMenuItem _versionToggle;
[GUI] CheckMenuItem _appToggle;
[GUI] CheckMenuItem _timePlayedToggle;
[GUI] CheckMenuItem _versionToggle;
[GUI] CheckMenuItem _lastPlayedToggle;
[GUI] CheckMenuItem _fileExtToggle;
[GUI] CheckMenuItem _fileSizeToggle;
[GUI] CheckMenuItem _pathToggle;
[GUI] CheckMenuItem _fileSizeToggle;
[GUI] Label _gameStatus;
[GUI] TreeView _gameTable;
[GUI] ScrolledWindow _gameTableWindow;
[GUI] TreeSelection _gameTableSelection;
[GUI] ScrolledWindow _gameTableWindow;
[GUI] Label _gpuName;
[GUI] Label _progressLabel;
[GUI] Label _firmwareVersionLabel;
@ -96,9 +95,12 @@ namespace Ryujinx.Ui
this.DeleteEvent += Window_Close;
_fullScreen.Activated += FullScreen_Toggled;
this.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
this.Title = $"Ryujinx {Program.Version}";
ApplicationLibrary.ApplicationAdded += Application_Added;
ApplicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
GLRenderer.StatusUpdatedEvent += Update_StatusBar;
GlRenderer.StatusUpdatedEvent += Update_StatusBar;
_gameTable.ButtonReleaseEvent += Row_Clicked;
@ -127,8 +129,6 @@ namespace Ryujinx.Ui
ApplyTheme();
_mainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
_mainWin.Title = $"Ryujinx {Program.Version}";
_stopEmulation.Sensitive = false;
if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn) _favToggle.Active = true;
@ -302,7 +302,7 @@ namespace Ryujinx.Ui
{
if (_gameLoaded)
{
GtkDialog.CreateDialog("Ryujinx", "A game has already been loaded", "Please close it first and try again.");
GtkDialog.CreateInfoDialog("Ryujinx", "A game has already been loaded", "Please close it first and try again.");
}
else
{
@ -415,7 +415,7 @@ namespace Ryujinx.Ui
#if MACOS_BUILD
CreateGameWindow(device);
#else
var windowThread = new Thread(() =>
Thread windowThread = new Thread(() =>
{
CreateGameWindow(device);
})
@ -443,35 +443,29 @@ namespace Ryujinx.Ui
private void CreateGameWindow(HLE.Switch device)
{
ControllerType type = (Ryujinx.Configuration.Hid.ControllerType)ConfigurationState.Instance.Hid.ControllerType switch {
Ryujinx.Configuration.Hid.ControllerType.ProController => ControllerType.ProController,
Ryujinx.Configuration.Hid.ControllerType.Handheld => ControllerType.Handheld,
Ryujinx.Configuration.Hid.ControllerType.NpadPair => ControllerType.JoyconPair,
Ryujinx.Configuration.Hid.ControllerType.NpadLeft => ControllerType.JoyconLeft,
Ryujinx.Configuration.Hid.ControllerType.NpadRight => ControllerType.JoyconRight,
_ => ControllerType.Handheld
};
device.Hid.Npads.AddControllers(new ControllerConfig {
Player = PlayerIndex.Player1,
Type = type
});
device.Hid.Npads.AddControllers(ConfigurationState.Instance.Hid.InputConfig.Value.Select(inputConfig =>
new HLE.HOS.Services.Hid.ControllerConfig
{
Player = (PlayerIndex)inputConfig.PlayerIndex,
Type = (ControllerType)inputConfig.ControllerType
}
).ToArray());
_gLWidget = new GLRenderer(_emulationContext);
_glWidget = new GlRenderer(_emulationContext);
Application.Invoke(delegate
{
_viewBox.Remove(_gameTableWindow);
_gLWidget.Expand = true;
_viewBox.Child = _gLWidget;
_glWidget.Expand = true;
_viewBox.Child = _glWidget;
_gLWidget.ShowAll();
_glWidget.ShowAll();
EditFooterForGameRender();
});
_gLWidget.WaitEvent.WaitOne();
_glWidget.WaitEvent.WaitOne();
_gLWidget.Start();
_glWidget.Start();
device.Dispose();
_deviceExitStatus.Set();
@ -479,15 +473,15 @@ namespace Ryujinx.Ui
// NOTE: Everything that is here will not be executed when you close the UI.
Application.Invoke(delegate
{
_viewBox.Remove(_gLWidget);
_gLWidget.Exit();
_viewBox.Remove(_glWidget);
_glWidget.Exit();
if(_gLWidget.Window != this.Window && _gLWidget.Window != null)
if(_glWidget.Window != this.Window && _glWidget.Window != null)
{
_gLWidget.Window.Dispose();
_glWidget.Window.Dispose();
}
_gLWidget.Dispose();
_glWidget.Dispose();
_viewBox.Add(_gameTableWindow);
@ -497,7 +491,7 @@ namespace Ryujinx.Ui
_emulationContext = null;
_gameLoaded = false;
_gLWidget = null;
_glWidget = null;
DiscordIntegrationModule.SwitchToMainMenu();
@ -528,7 +522,7 @@ namespace Ryujinx.Ui
public void ToggleExtraWidgets(bool show)
{
if (_gLWidget != null)
if (_glWidget != null)
{
if (show)
{
@ -562,6 +556,11 @@ namespace Ryujinx.Ui
}
}
public static void SaveConfig()
{
ConfigurationState.Instance.ToFileFormat().SaveConfig(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void End(HLE.Switch device)
{
@ -580,10 +579,10 @@ namespace Ryujinx.Ui
{
UpdateGameMetadata(device.System.TitleIdText);
if (_gLWidget != null)
if (_glWidget != null)
{
// We tell the widget that we are exiting
_gLWidget.Exit();
_glWidget.Exit();
// Wait for the other thread to dispose the HLE context before exiting.
_deviceExitStatus.WaitOne();
@ -773,7 +772,7 @@ namespace Ryujinx.Ui
private void StopEmulation_Pressed(object sender, EventArgs args)
{
_gLWidget?.Exit();
_glWidget?.Exit();
}
private void Installer_File_Pressed(object o, EventArgs args)
@ -808,7 +807,7 @@ namespace Ryujinx.Ui
private void RefreshFirmwareLabel()
{
var currentFirmware = _contentManager.GetCurrentFirmwareVersion();
SystemVersion currentFirmware = _contentManager.GetCurrentFirmwareVersion();
GLib.Idle.Add(new GLib.IdleHandler(() =>
{
@ -830,7 +829,7 @@ namespace Ryujinx.Ui
fileChooser.Dispose();
var firmwareVersion = _contentManager.VerifyFirmwarePackage(filename);
SystemVersion firmwareVersion = _contentManager.VerifyFirmwarePackage(filename);
if (firmwareVersion == null)
{
@ -849,7 +848,7 @@ namespace Ryujinx.Ui
return;
}
var currentVersion = _contentManager.GetCurrentFirmwareVersion();
SystemVersion currentVersion = _contentManager.GetCurrentFirmwareVersion();
string dialogMessage = $"System version {firmwareVersion.VersionString} will be installed.";
@ -989,7 +988,7 @@ namespace Ryujinx.Ui
private void Settings_Pressed(object sender, EventArgs args)
{
SwitchSettings settingsWin = new SwitchSettings(_virtualFileSystem, _contentManager);
SettingsWindow settingsWin = new SettingsWindow(_virtualFileSystem, _contentManager);
settingsWin.Show();
}
@ -1205,10 +1204,5 @@ namespace Ryujinx.Ui
return 0;
}
}
public static void SaveConfig()
{
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
}