diff --git a/jme3-core/src/main/java/com/jme3/input/InputManager.java b/jme3-core/src/main/java/com/jme3/input/InputManager.java index f6a34ba6e..1455860f5 100644 --- a/jme3-core/src/main/java/com/jme3/input/InputManager.java +++ b/jme3-core/src/main/java/com/jme3/input/InputManager.java @@ -995,11 +995,11 @@ public class InputManager implements RawInputListener { * Called when a joystick has been added or removed. * This should only be called internally. * @param joystickId the ID of the joystick. - * @param state the state that occured (connected / disconnected). + * @param connected the connection state of the joystick. */ - public void fireJoystickConnectionEvent(int joystickId, JoystickState state) { + public void fireJoystickConnectionEvent(int joystickId, boolean connected) { for (JoystickConnectionListener listener : joystickConnectionListeners) { - listener.connectionChanged(joystickId, state); + listener.connectionChanged(joystickId, connected); } } diff --git a/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java b/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java index b37c6ae1b..93c43d2c1 100644 --- a/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java +++ b/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java @@ -2,6 +2,6 @@ package com.jme3.input; public interface JoystickConnectionListener { - void connectionChanged(int joystickId, JoystickState action); + void connectionChanged(int joystickId, boolean connected); } diff --git a/jme3-core/src/main/java/com/jme3/input/JoystickState.java b/jme3-core/src/main/java/com/jme3/input/JoystickState.java deleted file mode 100644 index 6e603ea83..000000000 --- a/jme3-core/src/main/java/com/jme3/input/JoystickState.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.jme3.input; - -/** - * Response for joystick callback events. - * @author jayfella - */ -public enum JoystickState { - - Connected, - Disconnected, - -} diff --git a/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java b/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java index 02720379f..da5f47eee 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java @@ -68,8 +68,8 @@ public class GlfwJoystickInput implements JoyInput { } } - public void fireJoystickConnectionEvent(int jid, JoystickState state) { - ((InputManager)listener).fireJoystickConnectionEvent(jid, state); + public void fireJoystickConnectionEvent(int jid, boolean connected) { + ((InputManager)listener).fireJoystickConnectionEvent(jid, connected); } public void reloadJoysticks() { diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java index 2606c7fdd..27925f477 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java @@ -38,7 +38,6 @@ import static org.lwjgl.opencl.CL10.CL_CONTEXT_PLATFORM; import static org.lwjgl.opengl.GL.createCapabilities; import static org.lwjgl.opengl.GL11.glGetInteger; -import com.jme3.input.JoystickState; import com.jme3.input.lwjgl.GlfwJoystickInput; import com.jme3.input.lwjgl.GlfwKeyInput; import com.jme3.input.lwjgl.GlfwMouseInput; @@ -239,13 +238,10 @@ public abstract class LwjglContext implements JmeContext { GLFW.glfwSetJoystickCallback(new GLFWJoystickCallback() { @Override public void invoke(int jid, int event) { - joyInput.reloadJoysticks(); - - JoystickState state = event == GLFW.GLFW_CONNECTED - ? JoystickState.Connected - : JoystickState.Disconnected; - joyInput.fireJoystickConnectionEvent(jid, state); + // fire the event after joysticks were reloaded. + joyInput.reloadJoysticks(); + joyInput.fireJoystickConnectionEvent(jid, event == GLFW.GLFW_CONNECTED); } });