v1.2.0: overhauled controller pointer, now has unique sprite and works on linux

This commit is contained in:
Evan Debenham
2022-02-27 10:23:19 -05:00
parent 264742d467
commit 3f4a677700
6 changed files with 52 additions and 16 deletions

View File

@@ -31,7 +31,7 @@ import com.watabou.utils.PointF;
public class ControllerHandler implements ControllerListener {
public static enum ControllerType {
public enum ControllerType {
XBOX,
PLAYSTATION,
NINTENDO,
@@ -98,6 +98,7 @@ public class ControllerHandler implements ControllerListener {
private float L2Trigger = 0f;
private float R2Trigger = 0f;
//FIXME these axis mappings seem to be wrong on Android (and iOS?) in some cases
@Override
public boolean axisMoved(Controller controller, int axisCode, float value) {
setControllerType(controller);
@@ -130,6 +131,18 @@ public class ControllerHandler implements ControllerListener {
return true;
}
//we use a separate variable as Gdx.input.isCursorCatched only works on desktop
private static boolean controllerPointerActive = false;
public static void setControllerPointer( boolean active ){
Gdx.input.setCursorCatched(active);
controllerPointerActive = active;
}
public static boolean controllerPointerActive(){
return controllerPointerActive;
}
//converts controller button codes to keyEvent codes
public static int buttonToKey(Controller controller, int btnCode){
ControllerMapping mapping = controller.getMapping();

View File

@@ -108,6 +108,7 @@ public class InputHandler extends InputAdapter {
@Override
public boolean mouseMoved(int screenX, int screenY) {
ControllerHandler.setControllerPointer(false);
PointerEvent.addPointerEvent(new PointerEvent(screenX, screenY, -1, PointerEvent.Type.HOVER));
return true;
}

View File

@@ -33,9 +33,10 @@ public class Cursor {
public enum Type {
//TODO if we ever add more cursors, should cache their pixmaps rather than always remaking
DEFAULT("gdx/cursor.png");
DEFAULT("gdx/cursor_mouse.png"),
CONTROLLER("gdx/cursor_controller.png");
private String file;
public final String file;
Type(String file){
this.file = file;