v3.0.2: fixed 'none' not being considered a controller key
this created issues when with contrlller controller button binding configurations, where 'none' effectively couldn't be assigned to an action by the user
This commit is contained in:
@@ -246,6 +246,10 @@ public class ControllerHandler implements ControllerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean icControllerKey(int keyCode){
|
public static boolean icControllerKey(int keyCode){
|
||||||
|
if (keyCode == 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (keyCode >= Input.Keys.BUTTON_A
|
if (keyCode >= Input.Keys.BUTTON_A
|
||||||
&& keyCode <= Input.Keys.BUTTON_MODE){
|
&& keyCode <= Input.Keys.BUTTON_MODE){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -82,4 +82,8 @@ public class KeyEvent {
|
|||||||
}
|
}
|
||||||
keyEvents.clear();
|
keyEvents.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isKeyboardKey(int keyCode){
|
||||||
|
return keyCode == 0 || !ControllerHandler.icControllerKey(keyCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.badlogic.gdx.Input;
|
|||||||
import com.watabou.input.ControllerHandler;
|
import com.watabou.input.ControllerHandler;
|
||||||
import com.watabou.input.GameAction;
|
import com.watabou.input.GameAction;
|
||||||
import com.watabou.input.KeyBindings;
|
import com.watabou.input.KeyBindings;
|
||||||
|
import com.watabou.input.KeyEvent;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.FileUtils;
|
import com.watabou.utils.FileUtils;
|
||||||
|
|
||||||
@@ -213,7 +214,7 @@ public class SPDAction extends GameAction {
|
|||||||
LinkedHashMap<Integer, GameAction> merged = new LinkedHashMap<>();
|
LinkedHashMap<Integer, GameAction> merged = new LinkedHashMap<>();
|
||||||
|
|
||||||
for (GameAction a : allActions()) {
|
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){
|
if (firstKeys.getInt(a.name()) == 0){
|
||||||
continue; //we have no keys assigned to this action, move to the next one
|
continue; //we have no keys assigned to this action, move to the next one
|
||||||
} else {
|
} 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){
|
if (secondKeys.getInt(a.name()) == 0){
|
||||||
continue; //we have no more keys assigned to this action, move to the next one
|
continue; //we have no more keys assigned to this action, move to the next one
|
||||||
} else {
|
} 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){
|
if (thirdKeys.getInt(a.name()) == 0){
|
||||||
continue; //we have no more keys assigned to this action, move to the next one
|
continue; //we have no more keys assigned to this action, move to the next one
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -509,7 +509,9 @@ public class WndKeyBindings extends Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//ignore controller buttons on key bindings, and vice-versa
|
//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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user