1
0
forked from Clones/Controlify

rewrite most of joystick mapping

This commit is contained in:
isXander
2023-04-11 11:03:07 +01:00
parent ff7e676eb5
commit d3fc0a946b
19 changed files with 535 additions and 217 deletions

View File

@ -13,17 +13,12 @@ import java.util.Objects;
public class SingleJoystickController extends AbstractController<JoystickState, JoystickConfig> implements JoystickController<JoystickConfig> {
private JoystickState state = JoystickState.EMPTY, prevState = JoystickState.EMPTY;
private final int axisCount, buttonCount, hatCount;
private final JoystickMapping mapping;
public SingleJoystickController(int joystickId, ControllerHIDService.ControllerHIDInfo hidInfo) {
super(joystickId, hidInfo);
this.axisCount = GLFW.glfwGetJoystickAxes(joystickId).capacity();
this.buttonCount = GLFW.glfwGetJoystickButtons(joystickId).capacity();
this.hatCount = GLFW.glfwGetJoystickHats(joystickId).capacity();
this.mapping = Objects.requireNonNull(RPJoystickMapping.fromType(type()));
this.mapping = Objects.requireNonNull(RPJoystickMapping.fromType(this));
this.config = new JoystickConfig(this);
this.defaultConfig = new JoystickConfig(this);
@ -57,17 +52,17 @@ public class SingleJoystickController extends AbstractController<JoystickState,
@Override
public int axisCount() {
return axisCount;
return mapping().axes().length;
}
@Override
public int buttonCount() {
return buttonCount;
return mapping.buttons().length;
}
@Override
public int hatCount() {
return hatCount;
return mapping.hats().length;
}
@Override