v1.4.0: mouse and controller cursor positions are now synced

This commit is contained in:
Evan Debenham
2022-07-29 15:33:03 -04:00
parent 3c4420e8a0
commit 90a1d3ce2b
2 changed files with 9 additions and 2 deletions

View File

@@ -156,9 +156,10 @@ public class ControllerHandler implements ControllerListener {
controllerPointerActive = active;
if (active){
Gdx.input.setCursorCatched(true);
controllerPointerPos = new PointF(Game.width/2, Game.height/2);
controllerPointerPos = new PointF(PointerEvent.currentHoverPos());
} else if (!Cursor.isCursorCaptured()) {
Gdx.input.setCursorCatched(false);
Gdx.input.setCursorPosition((int)controllerPointerPos.x, (int)controllerPointerPos.y);
}
}

View File

@@ -28,6 +28,7 @@ import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.watabou.noosa.Game;
import com.watabou.noosa.ui.Cursor;
import com.watabou.utils.PointF;
public class InputHandler extends InputAdapter {
@@ -121,7 +122,12 @@ public class InputHandler extends InputAdapter {
@Override
public boolean mouseMoved(int screenX, int screenY) {
ControllerHandler.setControllerPointer(false);
if (ControllerHandler.controllerPointerActive()) {
ControllerHandler.setControllerPointer(false);
PointF hover = ControllerHandler.getControllerPointerPos();
screenX = (int)hover.x;
screenY = (int)hover.y;
}
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, -1, PointerEvent.Type.HOVER));
return true;
}