Improve logging for OpenTK gamepads

This commit is contained in:
YoshiRulz 2021-08-19 13:29:48 +10:00
parent b29516e864
commit ee0848d7d0
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 12 additions and 7 deletions

View File

@ -16,6 +16,8 @@ namespace BizHawk.Bizware.DirectX
private Config? _config;
public string Desc { get; } = "DirectInput+XInput";
public void DeInitAll()
{
KeyInput.Cleanup();

View File

@ -46,7 +46,7 @@ namespace BizHawk.Bizware.OpenTK3
static void DropAt(int knownAsIndex, IList<OTK_GamePad> 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
/// <summary>The object returned by <see cref="Joystick.GetCapabilities"/></summary>
private readonly JoystickCapabilities? _joystickCapabilities;
private readonly string VerboseName;
public readonly IReadOnlyCollection<string> HapticsChannels;
/// <summary>For use in keybind boxes</summary>
@ -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();
}

View File

@ -12,6 +12,8 @@ namespace BizHawk.Bizware.OpenTK3
{
private IReadOnlyDictionary<string, int> _lastHapticsSnapshot = new Dictionary<string, int>();
public string Desc { get; } = "OpenTK 3";
public void DeInitAll() {}
public void FirstInitAll(IntPtr mainFormHandle)

View File

@ -8,6 +8,8 @@ namespace BizHawk.Client.Common
/// <remarks>this was easier than trying to make static classes instantiable...</remarks>
public interface IHostInputAdapter
{
string Desc { get; }
void DeInitAll();
void FirstInitAll(IntPtr mainFormHandle);

View File

@ -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)