From ee0848d7d049c0fec16e81a58a7bb4b357f648ea Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 19 Aug 2021 13:29:48 +1000 Subject: [PATCH] Improve logging for OpenTK gamepads --- src/BizHawk.Bizware.DirectX/DirectInputAdapter.cs | 2 ++ src/BizHawk.Bizware.OpenTK3/OTK_Gamepad.cs | 12 +++++------- src/BizHawk.Bizware.OpenTK3/OpenTKInputAdapter.cs | 2 ++ src/BizHawk.Client.Common/input/HostInputAdapter.cs | 2 ++ src/BizHawk.Client.EmuHawk/Input/Input.cs | 1 + 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/BizHawk.Bizware.DirectX/DirectInputAdapter.cs b/src/BizHawk.Bizware.DirectX/DirectInputAdapter.cs index 4fc4cb40cf..7921d8e164 100644 --- a/src/BizHawk.Bizware.DirectX/DirectInputAdapter.cs +++ b/src/BizHawk.Bizware.DirectX/DirectInputAdapter.cs @@ -16,6 +16,8 @@ namespace BizHawk.Bizware.DirectX private Config? _config; + public string Desc { get; } = "DirectInput+XInput"; + public void DeInitAll() { KeyInput.Cleanup(); diff --git a/src/BizHawk.Bizware.OpenTK3/OTK_Gamepad.cs b/src/BizHawk.Bizware.OpenTK3/OTK_Gamepad.cs index 92ca0afe40..a666ddef47 100644 --- a/src/BizHawk.Bizware.OpenTK3/OTK_Gamepad.cs +++ b/src/BizHawk.Bizware.OpenTK3/OTK_Gamepad.cs @@ -46,7 +46,7 @@ namespace BizHawk.Bizware.OpenTK3 static void DropAt(int knownAsIndex, IList devices) { var known = devices[knownAsIndex]; - Console.WriteLine($"Dropped gamepad #{knownAsIndex}, was port#{known._deviceIndex} ({known._name}) via OpenTK"); + Console.WriteLine($"Dropped gamepad #{knownAsIndex}: was {known.VerboseName}"); devices.RemoveAt(knownAsIndex); } if (!initialized) return; @@ -69,7 +69,7 @@ namespace BizHawk.Bizware.OpenTK3 { var newConn = new OTK_GamePad(tryIndex, Devices.Count); Devices.Insert(tryIndex, newConn); // try and keep our indices in line with the OpenTK ones - Console.WriteLine($"Connected new gamepad #{tryIndex}, port#{newConn._deviceIndex} ({newConn._name}) via OpenTK"); + Console.WriteLine($"Connected new gamepad as #{tryIndex}: {newConn.VerboseName}"); } // else was and remains disconnected, move along } @@ -112,6 +112,8 @@ namespace BizHawk.Bizware.OpenTK3 /// The object returned by private readonly JoystickCapabilities? _joystickCapabilities; + private readonly string VerboseName; + public readonly IReadOnlyCollection HapticsChannels; /// For use in keybind boxes @@ -156,12 +158,8 @@ namespace BizHawk.Bizware.OpenTK3 ? new[] { "Left", "Right" } // two haptic motors : new[] { "Mono" }; // one or zero haptic motors -- in the latter case, pretend it's mono anyway as that doesn't seem to cause problems InputNamePrefix = $"{(MappedGamePad ? "X" : "J")}{_playerIndex} "; - + VerboseName = $"port #{_deviceIndex} {(MappedGamePad ? "mapped" : "unmapped")} {Guid} {_name}"; Update(); - - Console.WriteLine($"Initialising OpenTK GamePad: {Guid}"); - Console.WriteLine($"OpenTK Mapping: {_name}"); - InitializeMappings(); } diff --git a/src/BizHawk.Bizware.OpenTK3/OpenTKInputAdapter.cs b/src/BizHawk.Bizware.OpenTK3/OpenTKInputAdapter.cs index 14a1a78283..61d63e4df7 100644 --- a/src/BizHawk.Bizware.OpenTK3/OpenTKInputAdapter.cs +++ b/src/BizHawk.Bizware.OpenTK3/OpenTKInputAdapter.cs @@ -12,6 +12,8 @@ namespace BizHawk.Bizware.OpenTK3 { private IReadOnlyDictionary _lastHapticsSnapshot = new Dictionary(); + public string Desc { get; } = "OpenTK 3"; + public void DeInitAll() {} public void FirstInitAll(IntPtr mainFormHandle) diff --git a/src/BizHawk.Client.Common/input/HostInputAdapter.cs b/src/BizHawk.Client.Common/input/HostInputAdapter.cs index de9d3dbec9..f58e21b288 100644 --- a/src/BizHawk.Client.Common/input/HostInputAdapter.cs +++ b/src/BizHawk.Client.Common/input/HostInputAdapter.cs @@ -8,6 +8,8 @@ namespace BizHawk.Client.Common /// this was easier than trying to make static classes instantiable... public interface IHostInputAdapter { + string Desc { get; } + void DeInitAll(); void FirstInitAll(IntPtr mainFormHandle); diff --git a/src/BizHawk.Client.EmuHawk/Input/Input.cs b/src/BizHawk.Client.EmuHawk/Input/Input.cs index eac60d8b5b..7e8ba9e9f0 100644 --- a/src/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/src/BizHawk.Client.EmuHawk/Input/Input.cs @@ -48,6 +48,7 @@ namespace BizHawk.Client.EmuHawk EHostInputMethod.DirectInput => new DirectInputAdapter(), _ => throw new Exception() }; + Console.WriteLine($"Using {Adapter.Desc} for host input (keyboard + gamepads)"); Adapter.UpdateConfig(config); Adapter.FirstInitAll(mainFormHandle); _updateThread = new Thread(UpdateThreadProc)