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); hardBindings.put(keyCode, action);
} }
public static boolean acceptUnbound = false; public static boolean bindingKey = false;
public static boolean isKeyBound(int keyCode){ public static boolean isKeyBound(int keyCode){
if (keyCode <= 0 || keyCode > 255){ if (keyCode <= 0 || keyCode > 255){
return false; return false;
} }
return acceptUnbound || bindings.containsKey( keyCode ) || hardBindings.containsKey( keyCode ); return bindingKey || bindings.containsKey( keyCode ) || hardBindings.containsKey( keyCode );
} }
public static GameAction getActionForKey(KeyEvent event){ public static GameAction getActionForKey(KeyEvent event){

View File

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

View File

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