diff --git a/src/com/limelight/input/gamepad/NativeGamepad.java b/src/com/limelight/input/gamepad/NativeGamepad.java index 5dbe06b..83fa5c2 100644 --- a/src/com/limelight/input/gamepad/NativeGamepad.java +++ b/src/com/limelight/input/gamepad/NativeGamepad.java @@ -9,6 +9,7 @@ public class NativeGamepad { private static ArrayList listenerList = new ArrayList(); private static boolean running = false; + private static boolean initialized = false; private static Thread deviceThread = null; private static Thread eventThread = null; private static int devicePollingIntervalMs = DEFAULT_DEVICE_POLLING_INTERVAL; @@ -16,8 +17,6 @@ public class NativeGamepad { static { System.loadLibrary("gamepad_jni"); - - NativeGamepad.init(); } private static native void init(); @@ -55,6 +54,10 @@ public class NativeGamepad { } public static void start() { + if (!initialized) { + NativeGamepad.init(); + initialized = true; + } if (!running) { startDevicePolling(); startEventPolling(); @@ -75,7 +78,10 @@ public class NativeGamepad { throw new IllegalStateException("Cannot release running NativeGamepad"); } - NativeGamepad.shutdown(); + if (initialized) { + NativeGamepad.shutdown(); + initialized = false; + } } public static int getDeviceCount() {