diff --git a/SPD-classes/src/main/java/com/watabou/input/ControllerHandler.java b/SPD-classes/src/main/java/com/watabou/input/ControllerHandler.java index e8d312e51..ab7d67aeb 100644 --- a/SPD-classes/src/main/java/com/watabou/input/ControllerHandler.java +++ b/SPD-classes/src/main/java/com/watabou/input/ControllerHandler.java @@ -246,6 +246,10 @@ public class ControllerHandler implements ControllerListener { } public static boolean icControllerKey(int keyCode){ + if (keyCode == 0){ + return true; + } + if (keyCode >= Input.Keys.BUTTON_A && keyCode <= Input.Keys.BUTTON_MODE){ return true; diff --git a/SPD-classes/src/main/java/com/watabou/input/KeyEvent.java b/SPD-classes/src/main/java/com/watabou/input/KeyEvent.java index 4335c8ac4..49adb1980 100644 --- a/SPD-classes/src/main/java/com/watabou/input/KeyEvent.java +++ b/SPD-classes/src/main/java/com/watabou/input/KeyEvent.java @@ -82,4 +82,8 @@ public class KeyEvent { } keyEvents.clear(); } + + public static boolean isKeyboardKey(int keyCode){ + return keyCode == 0 || !ControllerHandler.icControllerKey(keyCode); + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java index f85cb5068..6b13ce769 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDAction.java @@ -25,6 +25,7 @@ import com.badlogic.gdx.Input; import com.watabou.input.ControllerHandler; import com.watabou.input.GameAction; import com.watabou.input.KeyBindings; +import com.watabou.input.KeyEvent; import com.watabou.utils.Bundle; import com.watabou.utils.FileUtils; @@ -213,7 +214,7 @@ public class SPDAction extends GameAction { LinkedHashMap merged = new LinkedHashMap<>(); for (GameAction a : allActions()) { - if (firstKeys.contains(a.name()) && !ControllerHandler.icControllerKey(firstKeys.getInt(a.name()))) { + if (firstKeys.contains(a.name()) && KeyEvent.isKeyboardKey(firstKeys.getInt(a.name()))) { if (firstKeys.getInt(a.name()) == 0){ continue; //we have no keys assigned to this action, move to the next one } else { @@ -236,7 +237,7 @@ public class SPDAction extends GameAction { } } - if (secondKeys.contains(a.name()) && !ControllerHandler.icControllerKey(secondKeys.getInt(a.name()))) { + if (secondKeys.contains(a.name()) && KeyEvent.isKeyboardKey(secondKeys.getInt(a.name()))) { if (secondKeys.getInt(a.name()) == 0){ continue; //we have no more keys assigned to this action, move to the next one } else { @@ -259,7 +260,7 @@ public class SPDAction extends GameAction { } } - if (thirdKeys.contains(a.name()) && !ControllerHandler.icControllerKey(thirdKeys.getInt(a.name()))) { + if (thirdKeys.contains(a.name()) && KeyEvent.isKeyboardKey(thirdKeys.getInt(a.name()))) { if (thirdKeys.getInt(a.name()) == 0){ continue; //we have no more keys assigned to this action, move to the next one } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndKeyBindings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndKeyBindings.java index 81f188a9d..a81a0ca0a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndKeyBindings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndKeyBindings.java @@ -509,7 +509,9 @@ public class WndKeyBindings extends Window { } //ignore controller buttons on key bindings, and vice-versa - if (ControllerHandler.icControllerKey(event.code) != controller){ + if (controller && !ControllerHandler.icControllerKey(event.code)){ + return true; + } else if (!controller && !KeyEvent.isKeyboardKey(event.code)){ return true; }