Skip to content

Commit

Permalink
fix better device polling in JoystickProxyWin
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjarv committed Apr 6, 2018
1 parent a63c1ed commit fee34e0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 39 deletions.
20 changes: 13 additions & 7 deletions JoystickProxyWin/Joystick Proxy/ControllerDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ControllerDevice : IEquatable<ControllerDevice>
private Joystick _joystick;
private string _usbId;


private bool NotPollable = false;

public ControllerDevice(DirectInput di, DeviceInstance deviceInstance)
{
Expand All @@ -35,13 +35,19 @@ public ControllerDevice(DirectInput di, DeviceInstance deviceInstance)
Joystick.Properties.BufferSize = 32;
}

~ControllerDevice()
{
try { Joystick.Unacquire(); } catch (Exception) {}
}

public void Update() {
Joystick.Poll();
if (NotPollable)
return;

try
{
Joystick.Poll();
}
catch (Exception)
{
NotPollable = true;
return;
}

List<JoystickUpdate> updatedStates = new List<JoystickUpdate>();

Expand Down
60 changes: 30 additions & 30 deletions JoystickProxyWin/Joystick Proxy/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion JoystickProxyWin/Joystick Proxy/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ private void ReadInputTimer_Tick(object sender, EventArgs e)
{
foreach(ControllerDevice device in _devices)
{
try { device.Update(); } catch(Exception) {}
try { device.Update(); } catch(Exception ex) {
Debug("Failure when running device Update()");
Debug(ex.Message);
}
}

ControllerDevice selectedDevice = (ControllerDevice)devicesDataGridView.CurrentRow.DataBoundItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

public class MFGCrosswind : MonoBehaviour
{
public const string USB_ID = "06a3:0764";
public const string USB_ID = "????:????";
//public const string USB_ID = "06a3:0764";

public GameObject Model;

Expand Down

0 comments on commit fee34e0

Please sign in to comment.