From b4f56d48fd34b708768e63a6a4791a67d6eeaff7 Mon Sep 17 00:00:00 2001 From: Sandy Noble Date: Thu, 4 Apr 2013 13:28:31 +0100 Subject: [PATCH] Keeps a list of gamepads, and goes through them until it finds one. --- gamepad.pde | 77 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/gamepad.pde b/gamepad.pde index d0b129e..5ccce46 100644 --- a/gamepad.pde +++ b/gamepad.pde @@ -11,9 +11,9 @@ ControllButton buttonStart; ControllCoolieHat dpad; - -String inputDeviceName = "Controller (Xbox 360 Wireless Receiver for Windows)"; - +List devices = new ArrayList( + Arrays.asList("Controller (Xbox 360 Wireless Receiver for Windows)", + "Controller (XBOX 360 For Windows)")); String signalFromGamepad = null; @@ -29,38 +29,55 @@ void gamepad_init() try { - joypad = controllIO.getDevice(inputDeviceName); - joypad.printButtons(); - - buttonA = joypad.getButton("Button 0"); - buttonB = joypad.getButton("Button 1"); - buttonX = joypad.getButton("Button 2"); - buttonY = joypad.getButton("Button 3"); + controllIO.printDevices(); + for (int i = 0; i