diff options
author | elias <[email protected]> | 2007-02-25 20:40:02 +0000 |
---|---|---|
committer | elias <[email protected]> | 2007-02-25 20:40:02 +0000 |
commit | 2becb9664d4e434219e4596a817f21349123af16 (patch) | |
tree | d209532417cd39d960997babf6b0e0eedacb558b /plugins/OSX/src | |
parent | aa50955ed08a78db24140cc16bdc10a1ecfc4a9b (diff) |
Mac OS X: Don't fail the entire device enumeration when one device fails to open
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@177 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins/OSX/src')
-rwxr-xr-x | plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java index b2aec33..66813b7 100755 --- a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java +++ b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java @@ -190,24 +190,31 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements try { OSXHIDDeviceIterator it = new OSXHIDDeviceIterator(); try { - OSXHIDDevice device; - while ((device = it.next()) != null) { - boolean device_used = false; + while (true) { + OSXHIDDevice device; try { - int old_size = controllers.size(); - createControllersFromDevice(device, controllers); - device_used = old_size != controllers.size(); + device = it.next(); + if (device == null) + break; + boolean device_used = false; + try { + int old_size = controllers.size(); + createControllersFromDevice(device, controllers); + device_used = old_size != controllers.size(); + } catch (IOException e) { + ControllerEnvironment.logln("Failed to create controllers from device: " + device.getProductName()); + } + if (!device_used) + device.release(); } catch (IOException e) { - ControllerEnvironment.logln("Failed to create controllers from device: " + device.getProductName()); + ControllerEnvironment.logln("Failed to enumerate device: " + e.getMessage()); } - if (!device_used) - device.release(); } } finally { it.close(); } } catch (IOException e) { - ControllerEnvironment.log("Failed to enumerate device: " + e.getMessage()); + ControllerEnvironment.log("Failed to enumerate devices: " + e.getMessage()); return new Controller[]{}; } Controller[] controllers_array = new Controller[controllers.size()]; |