v1.2.0: overhauled controller pointer, now has unique sprite and works on linux
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user