Small improvement to previous commit.
This commit is contained in:
parent
a2aba7e3c2
commit
1096e1bc5a
|
@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
joystick.Acquire();
|
||||
|
||||
GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick);
|
||||
GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick, _devices.Count);
|
||||
_devices.Add(p);
|
||||
}
|
||||
}
|
||||
|
@ -90,11 +90,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
readonly Joystick joystick;
|
||||
JoystickState state = new JoystickState();
|
||||
|
||||
GamePad(string name, Guid guid, Joystick joystick)
|
||||
GamePad(string name, Guid guid, Joystick joystick, int index)
|
||||
{
|
||||
this.name = name;
|
||||
this.guid = guid;
|
||||
this.joystick = joystick;
|
||||
PlayerNumber = index + 1;
|
||||
Update();
|
||||
InitializeCallbacks();
|
||||
}
|
||||
|
@ -134,7 +135,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public string Name { get { return name; } }
|
||||
public Guid Guid { get { return guid; } }
|
||||
|
||||
public int PlayerNumber { get; private set; }
|
||||
|
||||
public string ButtonName(int index)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static readonly object _syncObj = new object();
|
||||
private static readonly List<GamePad360> _devices = new List<GamePad360>();
|
||||
private static readonly bool _isAvailable = IsAvailable();
|
||||
private static readonly bool _isAvailable;
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GetProcAddress")]
|
||||
static extern IntPtr GetProcAddressOrdinal(IntPtr hModule, IntPtr procName);
|
||||
|
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public XINPUT_GAMEPAD Gamepad;
|
||||
}
|
||||
|
||||
private static bool IsAvailable()
|
||||
static GamePad360()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -68,12 +68,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
//don't remove this code. it's important to catch errors on systems with broken xinput installs.
|
||||
//(probably, checking for the library was adequate, but lets not get rid of this anyway)
|
||||
var test = new SlimDX.XInput.Controller(UserIndex.One).IsConnected;
|
||||
return true;
|
||||
_isAvailable = true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
|
|
|
@ -348,7 +348,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
//analyze xinput
|
||||
foreach (var pad in GamePad360.EnumerateDevices())
|
||||
{
|
||||
string xname = "X" + (pad.PlayerNumber) + " ";
|
||||
string xname = "X" + pad.PlayerNumber + " ";
|
||||
for (int b = 0; b < pad.NumButtons; b++)
|
||||
HandleButton(xname + pad.ButtonName(b), pad.Pressed(b));
|
||||
foreach (var sv in pad.GetFloats())
|
||||
|
@ -362,11 +362,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
//analyze joysticks
|
||||
foreach (var item in GamePad.EnumerateDevices().Select((n, i) => new { Device = n, Index = i }))
|
||||
foreach (var pad in GamePad.EnumerateDevices())
|
||||
{
|
||||
var pad = item.Device;
|
||||
string jname = "J" + (item.Index + 1) + " ";
|
||||
|
||||
string jname = "J" + pad.PlayerNumber + " ";
|
||||
for (int b = 0; b < pad.NumButtons; b++)
|
||||
HandleButton(jname + pad.ButtonName(b), pad.Pressed(b));
|
||||
foreach (var sv in pad.GetFloats())
|
||||
|
|
Loading…
Reference in New Issue