v1.2.0: fixed errors with emulated mouse input when setting bindings

This commit is contained in:
Evan Debenham 2022-02-18 15:54:14 -05:00
parent 0d3d8d9c34
commit de2eb5b653
3 changed files with 7 additions and 4 deletions

View File

@ -47,13 +47,13 @@ public class KeyBindings {
hardBindings.put(keyCode, action);
}
public static boolean acceptUnbound = false;
public static boolean bindingKey = false;
public static boolean isKeyBound(int keyCode){
if (keyCode <= 0 || keyCode > 255){
return false;
}
return acceptUnbound || bindings.containsKey( keyCode ) || hardBindings.containsKey( keyCode );
return bindingKey || bindings.containsKey( keyCode ) || hardBindings.containsKey( keyCode );
}
public static GameAction getActionForKey(KeyEvent event){

View File

@ -64,10 +64,13 @@ public class KeyEvent {
for (KeyEvent k : keyEvents){
if (KeyBindings.getActionForKey(k) == GameAction.LEFT_CLICK){
PointerEvent.emulateMouseButton(PointerEvent.LEFT, k.pressed);
if (KeyBindings.bindingKey) keySignal.dispatch(k);
} else if (KeyBindings.getActionForKey(k) == GameAction.RIGHT_CLICK){
PointerEvent.emulateMouseButton(PointerEvent.RIGHT, k.pressed);
if (KeyBindings.bindingKey) keySignal.dispatch(k);
} else if (KeyBindings.getActionForKey(k) == GameAction.MIDDLE_CLICK){
PointerEvent.emulateMouseButton(PointerEvent.MIDDLE, k.pressed);
if (KeyBindings.bindingKey) keySignal.dispatch(k);
} else {
keySignal.dispatch(k);
}

View File

@ -443,7 +443,7 @@ public class WndKeyBindings extends Window {
add(btnCancel);
resize(WIDTH, (int)btnCancel.bottom());
KeyBindings.acceptUnbound = true;
KeyBindings.bindingKey = true;
}
@ -484,7 +484,7 @@ public class WndKeyBindings extends Window {
@Override
public void destroy() {
super.destroy();
KeyBindings.acceptUnbound = false;
KeyBindings.bindingKey = false;
}
}