mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-01-09 19:55:16 +01:00
Merge branch 'webcam' of https://github.com/euphy/polargraphcontroller into webcam
This commit is contained in:
commit
1220b94564
29
gamepad.pde
29
gamepad.pde
@ -11,9 +11,9 @@ ControllButton buttonStart;
|
||||
|
||||
ControllCoolieHat dpad;
|
||||
|
||||
|
||||
String inputDeviceName = "Controller (Xbox 360 Wireless Receiver for Windows)";
|
||||
|
||||
List<String> devices = new ArrayList<String>(
|
||||
Arrays.asList("Controller (Xbox 360 Wireless Receiver for Windows)",
|
||||
"Controller (XBOX 360 For Windows)"));
|
||||
|
||||
String signalFromGamepad = null;
|
||||
|
||||
@ -29,7 +29,24 @@ void gamepad_init()
|
||||
|
||||
try
|
||||
{
|
||||
joypad = controllIO.getDevice(inputDeviceName);
|
||||
controllIO.printDevices();
|
||||
for (int i = 0; i<devices.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
println("trying " + i + ": " + devices.get(i));
|
||||
joypad = controllIO.getDevice(devices.get(i));
|
||||
break;
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
println("Requested device (" + devices.get(i) + ") not found.");
|
||||
joypad = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (joypad != null)
|
||||
{
|
||||
joypad.printButtons();
|
||||
|
||||
buttonA = joypad.getButton("Button 0");
|
||||
@ -56,11 +73,11 @@ void gamepad_init()
|
||||
dpad = joypad.getCoolieHat(10);
|
||||
dpad.setMultiplier(4);
|
||||
dpad.plug(this, "dpadPress", ControllIO.ON_PRESS);
|
||||
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
println("Requested device (" + inputDeviceName + ") not found.");
|
||||
println("Exception occurred while initialising gamepad: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user