From 9776884a91258c192606e93765da251eb4b805a8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 1 May 2018 17:04:32 -0400 Subject: [PATCH] Fixed controllers not aiming properly --- core/src/io/anuke/mindustry/core/Control.java | 18 +++++++++++++----- core/src/io/anuke/mindustry/core/Logic.java | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index a41d93b3b1..af9b1f7e2a 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -197,6 +197,11 @@ public class Control extends Module{ }); } + //FIXME figure out what's causing this problem in the first place + public void triggerInputUpdate(){ + Gdx.input = proxy; + } + public void setError(Throwable error){ this.error = error; } @@ -301,9 +306,7 @@ public class Control extends Module{ throw new RuntimeException(error); } - if(Gdx.input != proxy){ - Gdx.input = proxy; - } + Gdx.input = proxy; if(Inputs.keyTap("console")){ console = !console; @@ -327,16 +330,21 @@ public class Control extends Module{ controly -= ya*baseControllerSpeed*scl; controlling = true; + Gdx.input.setCursorCatched(true); + Inputs.getProcessor().touchDragged(Gdx.input.getX(), Gdx.input.getY(), 0); } controlx = Mathf.clamp(controlx, 0, Gdx.graphics.getWidth()); controly = Mathf.clamp(controly, 0, Gdx.graphics.getHeight()); - if(Gdx.input.getDeltaX() > 1 || Gdx.input.getDeltaY() > 1) - controlling = false; + if(Gdx.input.getDeltaX() > 1 || Gdx.input.getDeltaY() > 1) { + controlling = false; + Gdx.input.setCursorCatched(false); + } }else{ controlling = false; + Gdx.input.setCursorCatched(false); } if(!controlling){ diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index ef703fd940..e66845828f 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -111,6 +111,8 @@ public class Logic extends Module { if(!state.is(State.menu)){ + if(control != null) control.triggerInputUpdate(); + if(!state.is(State.paused) || Net.active()){ Timers.update(); }