v1.2.1: added support for binding mouse 4 and 5 to game actions
This commit is contained in:
parent
aa2e012fa4
commit
e63b5a208c
|
@ -91,19 +91,29 @@ public class InputHandler extends InputAdapter {
|
|||
public synchronized boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
||||
ControllerHandler.setControllerPointer(false);
|
||||
Gdx.input.setOnscreenKeyboardVisible(false); //in-game events never need keyboard, so hide it
|
||||
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.DOWN, button));
|
||||
|
||||
if (button >= 3 && KeyBindings.isKeyBound( button + 1000 )) {
|
||||
KeyEvent.addKeyEvent( new KeyEvent( button + 1000, true ) );
|
||||
} else if (button < 3) {
|
||||
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.DOWN, button));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
||||
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.UP, button));
|
||||
|
||||
if (button >= 3 && KeyBindings.isKeyBound( button + 1000 )) {
|
||||
KeyEvent.addKeyEvent( new KeyEvent( button + 1000, true ) );
|
||||
} else if (button < 3) {
|
||||
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.UP, button));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean touchDragged(int screenX, int screenY, int pointer) {
|
||||
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.DOWN));
|
||||
PointerEvent.addIfExisting(new PointerEvent(screenX, screenY, pointer, PointerEvent.Type.DOWN));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class KeyBindings {
|
|||
public static boolean bindingKey = false;
|
||||
|
||||
public static boolean isKeyBound(int keyCode){
|
||||
if (keyCode <= 0 || keyCode > 255){
|
||||
if (keyCode < 0 || (keyCode > 255 && keyCode < 1000)){
|
||||
return false;
|
||||
}
|
||||
return bindingKey || bindings.containsKey( keyCode ) || hardBindings.containsKey( keyCode );
|
||||
|
@ -80,6 +80,13 @@ public class KeyBindings {
|
|||
return ControllerHandler.customButtonName(keyCode);
|
||||
}
|
||||
|
||||
//custom codes for mouse buttons
|
||||
if (keyCode == 1003){
|
||||
return "Mouse 4";
|
||||
} else if (keyCode == 1004) {
|
||||
return "Mouse 5";
|
||||
}
|
||||
|
||||
if (keyCode == Input.Keys.UNKNOWN){
|
||||
return "None";
|
||||
} else if (keyCode == Input.Keys.PLUS){
|
||||
|
|
|
@ -125,6 +125,12 @@ public class PointerEvent {
|
|||
public static synchronized void addPointerEvent( PointerEvent event ){
|
||||
pointerEvents.add( event );
|
||||
}
|
||||
|
||||
public static synchronized void addIfExisting( PointerEvent event ){
|
||||
if (activePointers.containsKey(event.id)) {
|
||||
pointerEvents.add(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void processPointerEvents(){
|
||||
//handle any hover events separately first as we may need to add drag events
|
||||
|
|
Loading…
Reference in New Issue
Block a user