Use RawInputListener for InputManager instead of creating another field.
Set methods to use JoystickState enum instead of event integers.
This commit is contained in:
parent
80adca6dce
commit
682d8c9fd8
@ -49,7 +49,7 @@ import static org.lwjgl.glfw.GLFW.*;
|
|||||||
*/
|
*/
|
||||||
public class GlfwJoystickInput implements JoyInput {
|
public class GlfwJoystickInput implements JoyInput {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(InputManager.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(GlfwJoystickInput.class.getName());
|
||||||
|
|
||||||
private RawInputListener listener;
|
private RawInputListener listener;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class GlfwJoystickInput implements JoyInput {
|
|||||||
|
|
||||||
private final Map<JoystickButton, Boolean> joyButtonPressed = new HashMap<>();
|
private final Map<JoystickButton, Boolean> joyButtonPressed = new HashMap<>();
|
||||||
|
|
||||||
private InputManager inputManager;
|
// private InputManager inputManager;
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
@ -68,24 +68,22 @@ public class GlfwJoystickInput implements JoyInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireJoystickConnectionEvent(int jid, int event) {
|
public void fireJoystickConnectionEvent(int jid, JoystickState state) {
|
||||||
inputManager.fireJoystickConnectionEvent(jid, event);
|
((InputManager)listener).fireJoystickConnectionEvent(jid, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadJoysticks() {
|
public void reloadJoysticks() {
|
||||||
joysticks.clear();
|
joysticks.clear();
|
||||||
|
|
||||||
if (inputManager != null) {
|
InputManager inputManager = (InputManager) listener;
|
||||||
Joystick[] joysticks = loadJoysticks(inputManager);
|
|
||||||
inputManager.setJoysticks(joysticks);
|
Joystick[] joysticks = loadJoysticks(inputManager);
|
||||||
}
|
inputManager.setJoysticks(joysticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Joystick[] loadJoysticks(final InputManager inputManager) {
|
public Joystick[] loadJoysticks(final InputManager inputManager) {
|
||||||
|
|
||||||
this.inputManager = inputManager;
|
|
||||||
|
|
||||||
for (int i = 0; i < GLFW_JOYSTICK_LAST; i++) {
|
for (int i = 0; i < GLFW_JOYSTICK_LAST; i++) {
|
||||||
if (glfwJoystickPresent(i)) {
|
if (glfwJoystickPresent(i)) {
|
||||||
final String name = glfwGetJoystickName(i);
|
final String name = glfwGetJoystickName(i);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user