@Test public void testInvertedAxisMoved () throws IOException { Config.load(new File("../data/junit/controller/controller.cfg")); Vector3 vec = new Vector3(0, 0, 0); ControllerMapper mapper = new ControllerMapper(vec, new File("../data/input/mappings/xbox_controller.ini")); assertEquals(0, vec.x, 0.0001f); assertEquals(0, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_HORIZONTAL_AXIS, 0.01f); assertEquals(-0.01f, vec.x, 0.0001f); assertEquals(0, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_HORIZONTAL_AXIS, -1f); assertEquals(1, vec.x, 0.0001f); assertEquals(0, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_HORIZONTAL_AXIS, 1f); assertEquals(-1, vec.x, 0.0001f); assertEquals(0, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_HORIZONTAL_AXIS, 0.00001f); assertEquals(0, vec.x, 0.000000001f); assertEquals(0, vec.y, 0.000000001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_VERTICAL_AXIS, 0.01f); assertEquals(0, vec.x, 0.0001f); assertEquals(-0.01f, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_VERTICAL_AXIS, -1f); assertEquals(0, vec.x, 0.0001f); assertEquals(1, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_VERTICAL_AXIS, 1f); assertEquals(0, vec.x, 0.0001f); assertEquals(-1, vec.y, 0.0001f); mapper.axisMoved(Mockito.mock(Controller.class), mapper.L_STICK_VERTICAL_AXIS, 0.00001f); assertEquals(0, vec.x, 0.000000001f); assertEquals(0, vec.y, 0.000000001f); mapper.axisMoved(Mockito.mock(Controller.class), 200, 0.00001f); }
@Override public boolean axisMoved (Controller controller, int axisIndex, float value) { value = MathUtils.round3Digits(value); if (axisIndex == L_STICK_VERTICAL_AXIS) { playerMoveDirection.y = value * this.invertLStickVerticalAxis; } else if (axisIndex == L_STICK_HORIZONTAL_AXIS) { playerMoveDirection.x = value * this.invertLStickHorizontalAxis; } return false; }
ControllerMapper extends ControllerAdapter { @Override public boolean axisMoved (Controller controller, int axisIndex, float value) { value = MathUtils.round3Digits(value); if (axisIndex == L_STICK_VERTICAL_AXIS) { playerMoveDirection.y = value * this.invertLStickVerticalAxis; } else if (axisIndex == L_STICK_HORIZONTAL_AXIS) { playerMoveDirection.x = value * this.invertLStickHorizontalAxis; } return false; } }
ControllerMapper extends ControllerAdapter { @Override public boolean axisMoved (Controller controller, int axisIndex, float value) { value = MathUtils.round3Digits(value); if (axisIndex == L_STICK_VERTICAL_AXIS) { playerMoveDirection.y = value * this.invertLStickVerticalAxis; } else if (axisIndex == L_STICK_HORIZONTAL_AXIS) { playerMoveDirection.x = value * this.invertLStickHorizontalAxis; } return false; } ControllerMapper(Vector3 playerMoveDirection, File file); }
ControllerMapper extends ControllerAdapter { @Override public boolean axisMoved (Controller controller, int axisIndex, float value) { value = MathUtils.round3Digits(value); if (axisIndex == L_STICK_VERTICAL_AXIS) { playerMoveDirection.y = value * this.invertLStickVerticalAxis; } else if (axisIndex == L_STICK_HORIZONTAL_AXIS) { playerMoveDirection.x = value * this.invertLStickHorizontalAxis; } return false; } ControllerMapper(Vector3 playerMoveDirection, File file); @Override boolean axisMoved(Controller controller, int axisIndex, float value); void dispose(); }
ControllerMapper extends ControllerAdapter { @Override public boolean axisMoved (Controller controller, int axisIndex, float value) { value = MathUtils.round3Digits(value); if (axisIndex == L_STICK_VERTICAL_AXIS) { playerMoveDirection.y = value * this.invertLStickVerticalAxis; } else if (axisIndex == L_STICK_HORIZONTAL_AXIS) { playerMoveDirection.x = value * this.invertLStickHorizontalAxis; } return false; } ControllerMapper(Vector3 playerMoveDirection, File file); @Override boolean axisMoved(Controller controller, int axisIndex, float value); void dispose();  }