v1.4.0: mouse and controller cursor positions are now synced
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user