Java 类com.badlogic.gdx.controllers.PovDirection 实例源码

项目:drc-sim-client    文件:StageConfigInput.java   
public static String getInputDisplayName(int type, ConfigKeymap config, String key) {
    ConfigKeymap.Input input = config.getInput(key, -1, -1, -1);
    if (input.getInput() < 0)
        return "NONE";
    if (type == KEYBOARD && input.getInput() <= 255)
        return Input.Keys.toString(input.getInput());
    else if (type == CONTROLLER) {
        if (input.getType() == ConfigKeymap.Input.TYPE_AXIS)
            return String.format(Locale.US, "Axis %d %s", input.getInput(),
                    input.getExtra() == 0 ? "negative" : "positive");
        else if (input.getType() == ConfigKeymap.Input.TYPE_POV) {
            String pov = String.valueOf(input.getExtra());
            for (PovDirection dir : PovDirection.values())
                if (dir.ordinal() == input.getExtra())
                    pov = dir.name();
            return String.format(Locale.US, "D-pad %d %s", input.getInput(), pov);
        }
        else if (input.getType() == ConfigKeymap.Input.TYPE_BUTTON)
            return String.format(Locale.US, "Button %d", input.getInput());
    }
    return String.format(Locale.US, "%d", input.getInput());
}
项目:drc-sim-client    文件:StageConfigInput.java   
public static String getInputDisplayName(int type, ConfigKeymap config, String key) {
    ConfigKeymap.Input input = config.getInput(key, -1, -1, -1);
    if (input.getInput() < 0)
        return "NONE";
    if (type == KEYBOARD && input.getInput() <= 255)
        return Input.Keys.toString(input.getInput());
    else if (type == CONTROLLER) {
        if (input.getType() == ConfigKeymap.Input.TYPE_AXIS)
            return String.format(Locale.US, "Axis %d %s", input.getInput(),
                    input.getExtra() == 0 ? "negative" : "positive");
        else if (input.getType() == ConfigKeymap.Input.TYPE_POV) {
            String pov = String.valueOf(input.getExtra());
            for (PovDirection dir : PovDirection.values())
                if (dir.ordinal() == input.getExtra())
                    pov = dir.name();
            return String.format(Locale.US, "D-pad %d %s", input.getInput(), pov);
        }
        else if (input.getType() == ConfigKeymap.Input.TYPE_BUTTON)
            return String.format(Locale.US, "Button %d", input.getInput());
    }
    return String.format(Locale.US, "%d", input.getInput());
}
项目:Protoman-vs-Megaman    文件:GSGameLogic.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    switch (value) {
        case north:
        case northEast:
        case northWest: {
            keyDown(Keys.UP);
            break;
        }
        case south:
        case southEast:
        case southWest: {
            keyDown(Keys.DOWN);
            break;
        }
        case center: {
            keyUp(Keys.DOWN);
            break;
        }
        default: {
            break;
        }
    }

    return true;
}
项目:libgdxcn    文件:OisControllers.java   
public PovDirection getPov (int povIndex) {
    OisPov pov = joystick.getPov(povIndex);
    switch (pov) {
    case Centered:
        return PovDirection.center;
    case East:
        return PovDirection.east;
    case North:
        return PovDirection.north;
    case NorthEast:
        return PovDirection.northEast;
    case NorthWest:
        return PovDirection.northWest;
    case South:
        return PovDirection.south;
    case SouthEast:
        return PovDirection.southEast;
    case SouthWest:
        return PovDirection.southWest;
    case West:
        return PovDirection.west;
    }
    return null; // Impossible.
}
项目:Blob-Game    文件:MenuView.java   
private Controller testForBindingController() {
    for (Controller c : Controllers.getControllers()) {
        for (int i = 0; i < 10; i++) {
            if (c.getButton(i)) {
                return c;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (Math.abs(c.getAxis(i)) > 0.75f) {
                return c;
            }
        }
        if (c.getPov(0) != PovDirection.center)
            return c;
    }
    return null;
}
项目:shadow-engine    文件:OisControllers.java   
public PovDirection getPov (int povIndex) {
    OisJoystick.OisPov pov = joystick.getPov(povIndex);
    switch (pov) {
        case Centered:
            return PovDirection.center;
        case East:
            return PovDirection.east;
        case North:
            return PovDirection.north;
        case NorthEast:
            return PovDirection.northEast;
        case NorthWest:
            return PovDirection.northWest;
        case South:
            return PovDirection.south;
        case SouthEast:
            return PovDirection.southEast;
        case SouthWest:
            return PovDirection.southWest;
        case West:
            return PovDirection.west;
    }
    return null; // Impossible.
}
项目:ggvm    文件:PCMenu.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    switch(value) {
        case north:
            cursorUp();
            break;
        case south:
            cursorDown();
            break;
    }
    return false;
}
项目:ggvm    文件:PCMenu.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    Gdx.app.log(getClass().getSimpleName(), "povMoved(" + controller + ", " + povCode + ", " + value + ")");
    //User decided to use a d-pad---clear out any axis configurations since these can conflict.
    inputProcessor.getActualAxisToAxisCode().clear();
    menu = topLevelMenu;
    menu.activate();
    return false;
}
项目:project-divine-intervention    文件:GamePadManager.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    if(controller == pads[0]) {

    }else if(controller == pads[1]) {

    }
    return true;
}
项目:cgc-game    文件:InputManager.java   
public boolean povMoved(Controller arg0, int arg1, PovDirection arg2)
{
    //Gdx.app.log("CONTROLLER POV", ""+arg1);
    //Gdx.app.log("CONTROLLER POV", ""+arg2);

    if (arg2 == PovDirection.center)
    {
        for (int i = 0; i < mapA.size; i++)
        {
            if (mapA.get(i).controller.equals(arg0))
            {
                controlList[i].getCurrent().releasePov();
            }
        }
    }
    else
    {
        for (int i = 0; i < mapA.size; i++)
        {
            if (mapA.get(i).controller.equals(arg0))
            {
                controlList[i].getCurrent().pressPov(arg2);
            }
        }
    }

    return false;
}
项目:libni    文件:GdxMergedInput.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    // TODO: Handle multiple pov-codes
    //Gdx.app.log("povMoved","LibniReceiver: "+controller.getName()
    //        + " povCode: " + povCode
    //        + " PovDirection: " + value + " ordinal: " + value.ordinal());
    //if(value == PovDirection.center) { // this resets all pov-directions
    // allways update all
        for(int i=0; i<8; i++)
            gdxControllerMultiplexer.registerButtonEvent(i);
    //} else gdxControllerMultiplexer.registerButtonEvent(value.ordinal()-1);
    return false;
}
项目:M-M    文件:GamePadControl.java   
@Override
public boolean povMoved(final Controller controller, final int povIndex, final PovDirection direction) {
    if (isAssignedTo(controller)) {
        if (direction != null) {
            if (direction == PovDirection.center) {
                stop();
            } else {
                movement.x = getX(direction);
                movement.y = getY(direction);
            }
        }
        return true;
    }
    return false;
}
项目:M-M    文件:GamePadControl.java   
protected float getX(final PovDirection direction) {
    final float x;
    if (invertXY) { // Checking Y axis (north=east, south=west):
        x = getAbsoluteY(direction);
    } else { // Checking X axis:
        x = getAbsoluteX(direction);
    }
    if (invertX) {
        return -x;
    }
    return x;
}
项目:M-M    文件:GamePadControl.java   
protected float getY(final PovDirection direction) {
    final float y;
    if (invertXY) { // Checking X axis (north=east, south=west):
        y = getAbsoluteX(direction);
    } else { // Checking Y axis:
        y = getAbsoluteY(direction);
    }
    if (invertY) {
        return -y;
    }
    return y;
}
项目:M-M    文件:GamePadControl.java   
protected float getAbsoluteX(final PovDirection direction) {
    if (direction == PovDirection.east) {
        return 1f;
    } else if (direction == PovDirection.northEast || direction == PovDirection.southEast) {
        return COS;
    } else if (direction == PovDirection.west) {
        return -1f;
    } else if (direction == PovDirection.northWest || direction == PovDirection.southWest) {
        return -COS;
    }
    return 0f;
}
项目:M-M    文件:GamePadControl.java   
protected float getAbsoluteY(final PovDirection direction) {
    if (direction == PovDirection.north) {
        return 1f;
    } else if (direction == PovDirection.northEast || direction == PovDirection.northWest) {
        return SIN;
    } else if (direction == PovDirection.south) {
        return -1f;
    } else if (direction == PovDirection.southWest || direction == PovDirection.southEast) {
        return -SIN;
    } else {
        return 0f;
    }
}
项目:Aftamath    文件:MenuObj.java   
public void setRotation(PovDirection dir){
    switch(dir){
    case east:  rot = -90; break;
    case south: rot = 180; break;
    case west: rot = 90; break;
    default: rot = 0; break;
    }
}
项目:Protoman-vs-Megaman    文件:MenuLogic.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    switch (value) {
        case north:
        case northEast:
        case northWest: {
            keyDown(Keys.UP);
            break;
        }
        case south:
        case southEast:
        case southWest: {
            keyDown(Keys.DOWN);
            break;
        }
        case east: {
            keyDown(Keys.RIGHT);
            break;
        }
        case west: {
            keyDown(Keys.LEFT);
            break;
        }
        case center: {
            keyUp(Keys.LEFT);
            keyUp(Keys.RIGHT);
            keyUp(Keys.DOWN);
            keyUp(Keys.UP);
            break;
        }
        default: {
            break;
        }
    }

    return true;
}
项目:seventh    文件:ControllerInput.java   
/**
 */
public ControllerInput() {
    this.povDirections = new boolean[PovDirection.values().length];
    this.buttons = new boolean[64];
    this.isConnected = Controllers.getControllers().size > 0;
    this.triggerSensitivity = 0.3f;
    this.leftJoystickSensitivity = 0.2f;
    this.rightJoystickSensitivity = 0.3f;

    this.movements = new float[4];
}
项目:seventh    文件:ControllerInput.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection dir) {
    for(int i = 0; i<this.povDirections.length; i++) {
        this.povDirections[i] = false;
    }
    this.povDirections[dir.ordinal()] = true;                
    return false;
}
项目:seventh    文件:InputMap.java   
/**
 * 
 */
public InputMap(ControllerInput controllerInput) {
    this.controllerInput = controllerInput;

    this.actions = new HashMap<String, InputMap.Action>();
    this.keymap = new IntMap<String>();
    this.buttonmap = new IntMap<String>();
    this.controllermap = new IntMap<String>();
    this.povButtons = new String[PovDirection.values().length];

    this.scroller = new String[2];
}
项目:seventh    文件:JoystickGameController.java   
private int handleDPad(int inputKeys) {
    if (isPovDirectionDown(PovDirection.north)) {
        inputKeys |= Actions.UP.getMask();
    }
    else if (isPovDirectionDown(PovDirection.northEast)) {
        inputKeys |= Actions.UP.getMask();
        inputKeys |= Actions.RIGHT.getMask();
    }

    else if (isPovDirectionDown(PovDirection.northWest)) {
        inputKeys |= Actions.UP.getMask();
        inputKeys |= Actions.LEFT.getMask();
    }

    else if (isPovDirectionDown(PovDirection.south)) {
        inputKeys |= Actions.DOWN.getMask();
    }
    else if (isPovDirectionDown(PovDirection.southEast)) {
        inputKeys |= Actions.DOWN.getMask();
        inputKeys |= Actions.RIGHT.getMask();
    }
    else if (isPovDirectionDown(PovDirection.southWest)) {
        inputKeys |= Actions.DOWN.getMask();
        inputKeys |= Actions.LEFT.getMask();
    }
    else if (isPovDirectionDown(PovDirection.east)) {
        inputKeys |= Actions.RIGHT.getMask();
    }
    else if (isPovDirectionDown(PovDirection.west)) {
        inputKeys |= Actions.LEFT.getMask();
    }

    return inputKeys;
}
项目:Blob-Game    文件:Blob.java   
@Override
public void dpad(int id, PovDirection dir) {
    /*
     * if (getLevel().getAssetKey() != null) { if (Game.get().getState() ==
     * Game.PLAY || Game.get().getState() == Game.MENU) { boolean up = dir
     * == PovDirection.north; boolean down = dir == PovDirection.south; if
     * (up && mState == SOLID_STATE) { transform(); } else if (down) {
     * transform(); } } }
     */
}
项目:Blob-Game    文件:MenuView.java   
private int testForPov(Controller c) {
    if (c == null) {
        System.out.println("NULL CONTROLLER");
        return -1;
    }
    if (c.getPov(0) != PovDirection.center)
        return 1;
    // DebugOutput.info(this, c.getPov(0)+ " ");
    return -1;
}
项目:Blob-Game    文件:PlayerListener.java   
@Override
public boolean povMoved(Controller c, int id, PovDirection value) {

    //DebugOutput.finest(this, "Controller #" + indexOf(c) + ", pov " + id + ": " + value);
    // TODO:DPAD

    Player p = getPlayer(c);
    if (p == null || p.mActor == null)
        return false;
    p.mActor.dpad(id, value);

    return false;
}
项目:shadow-engine    文件:ControllerHelper.java   
@Override
public boolean povMoved(Controller controller, int povCode,
        PovDirection value) {
    //TODO Implement
    //System.out.println("Moved pov "+povCode+" with current value "+value+" on controller "+controller);
    return false;
}
项目:ggvm    文件:Menu.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    return false;
}
项目:ggvm    文件:KeyboardInputProcessor.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    //Only use d-pad if axes are not configured
    if (actualAxisToAxisCode.isEmpty()) {
        switch (value) {
            case center:
                ggvm.setUpButtonState(false);
                ggvm.setRightButtonState(false);
                ggvm.setDownButtonState(false);
                ggvm.setLeftButtonState(false);
                break;
            case north:
                ggvm.setUpButtonState(true);
                ggvm.setRightButtonState(false);
                ggvm.setDownButtonState(false);
                ggvm.setLeftButtonState(false);
                break;
            case northEast:
                ggvm.setUpButtonState(true);
                ggvm.setRightButtonState(true);
                ggvm.setDownButtonState(false);
                ggvm.setLeftButtonState(false);
                break;
            case east:
                ggvm.setUpButtonState(false);
                ggvm.setRightButtonState(true);
                ggvm.setDownButtonState(false);
                ggvm.setLeftButtonState(false);
                break;
            case southEast:
                ggvm.setUpButtonState(false);
                ggvm.setRightButtonState(true);
                ggvm.setDownButtonState(true);
                ggvm.setLeftButtonState(false);
                break;
            case south:
                ggvm.setUpButtonState(false);
                ggvm.setRightButtonState(false);
                ggvm.setDownButtonState(true);
                ggvm.setLeftButtonState(false);
                break;
            case southWest:
                ggvm.setUpButtonState(false);
                ggvm.setRightButtonState(false);
                ggvm.setDownButtonState(true);
                ggvm.setLeftButtonState(true);
                break;
            case west:
                ggvm.setUpButtonState(false);
                ggvm.setRightButtonState(false);
                ggvm.setDownButtonState(false);
                ggvm.setLeftButtonState(true);
                break;
            case northWest:
                ggvm.setUpButtonState(true);
                ggvm.setRightButtonState(false);
                ggvm.setDownButtonState(false);
                ggvm.setLeftButtonState(true);
                break;
        }
    }
    return false;
}
项目:ggvm    文件:InputProcessorBase.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    return false;
}
项目:drc-sim-client    文件:StageConfigInput.java   
private void pollInputController() {
    int input = -1;
    int input_extra = -1;
    int input_type = -1;
    main:
    for (Controller controller : Controllers.getControllers()) {
        if (!controller.getName().equals(this.controllerName))
            continue;
        // Check axes
        for (int axis = 0; axis < 1000; axis++) {
            float ax = controller.getAxis(axis);
            if (ax > .5) {
                input_type = ConfigKeymap.Input.TYPE_AXIS;
                input = axis;
                input_extra = 1; // positive
                break main;
            }
            else if (ax < -.5) {
                input_type = ConfigKeymap.Input.TYPE_AXIS;
                input = axis;
                input_extra = 0; // negative
                break main;
            }
        }
        // Only allow an axis to be set for joystick input.
        // TODO Map all 4(8) axes to allow any input to control the joystick(s). 4 directions per joystick
        if (key.contains("JOYSTICK"))
            break;
        // Check dpad/pov
        for (int pov = 0; pov < 1000; pov++) {
            PovDirection povDirection = controller.getPov(pov);
            if (!povDirection.equals(PovDirection.center)) {
                input_type = ConfigKeymap.Input.TYPE_POV;
                input = pov;
                input_extra = povDirection.ordinal();
                break main;
            }
        }
        // Check buttons
        for (int button = 0; button < 1000; button++) {
            if (controller.getButton(button)) {
                input_type = ConfigKeymap.Input.TYPE_BUTTON;
                input = button;
                break main;
            }
        }
        return;
    }
    if (input < 0)
        return;
    // Save input
    config.putInput(this.key, input_type, input, input_extra);
    config.load();
    config.flush();
    Client.setStage(new StageConfigInput(type, config, key, displayName, controllerName));
}
项目:Tower-Defense-Galaxy    文件:ControlHandler.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    return false;
}
项目:gdx-controllerutils    文件:MappedControllerAdapter.java   
@Override
public boolean povMoved(Controller controller, int povIndex, PovDirection value) {
    ControllerMappings.MappedInputs mapping = mappings.getControllerMapping(controller);

    if (mapping == null)
        return false;

    ConfiguredInput configuredInputV = mapping.getConfiguredFromPov(povIndex, true);
    ConfiguredInput configuredInputH = mapping.getConfiguredFromPov(povIndex, false);

    float valueH = 0;
    float valueV = 0;
    boolean handledH = false;
    boolean handledV = false;

    switch (value) {
        case east:
            valueH = 1f;
            break;
        case northEast:
            valueH = 1f;
        case north:
            valueV = -1f;
            break;
        case northWest:
            valueV = -1f;
        case west:
            valueH = -1f;
            break;
        case southEast:
            valueH = 1f;
        case south:
            valueV = 1f;
            break;
        case southWest:
            valueV = 1f;
            valueH = -1f;
            break;
    }

    if (configuredInputH != null)
        handledH = configuredAxisMoved(controller, configuredInputH.inputId, valueH);

    if (configuredInputV != null)
        handledV = configuredAxisMoved(controller, configuredInputV.inputId, valueV);

    return handledH || handledV;

}
项目:gdx-controllerutils    文件:ControllerMappingsTest.java   
@Test
public void testAxisToAxisMapping() {
    ControllerMappings mappings = new ControllerMappings();

    // We test 3 axis
    ConfiguredInput axis1 = new ConfiguredInput(ConfiguredInput.Type.axis, 5);
    ConfiguredInput axis2 = new ConfiguredInput(ConfiguredInput.Type.axisAnalog, 6);
    ConfiguredInput axis3 = new ConfiguredInput(ConfiguredInput.Type.axisDigital, 7);

    mappings.addConfiguredInput(axis1);
    mappings.addConfiguredInput(axis2);
    mappings.addConfiguredInput(axis3);

    // ok, configuration done...
    mappings.commitConfig();

    // now we connect a Controller... and map
    MockedController controller = new MockedController();
    controller.axisValues = new float[3];
    controller.povDirection = PovDirection.center;
    controller.axisValues[0] = .2f;
    controller.axisValues[1] = .6f;
    controller.axisValues[2] = -.2f;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 5));
    //next call too fast
    assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 6));

    controller.axisValues[0] = .2f;
    controller.axisValues[1] = .1f;
    controller.axisValues[2] = 0;
    assertEquals(ControllerMappings.RecordResult.nothing_done, mappings.recordMapping(controller, 6));

    controller.axisValues[0] = .6f;
    controller.axisValues[1] = .5f;
    controller.axisValues[2] = 0;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 6));

    controller.axisValues[0] = .6f;
    controller.axisValues[1] = .5f;
    controller.axisValues[2] = -1;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 7));

    assertTrue(mappings.getControllerMapping(controller).checkCompleted());

    System.out.println(mappings.toJson().toJson(JsonWriter.OutputType.json));

    // now check
    TestControllerAdapter controllerAdapter = new TestControllerAdapter(mappings);

    // the digital
    assertTrue(controllerAdapter.axisMoved(controller, 2, .8f));
    assertEquals(7, controllerAdapter.lastEventId);
    assertTrue(controllerAdapter.axisMoved(controller, 2, -.8f));
    assertEquals(7, controllerAdapter.lastEventId);
    assertTrue(controllerAdapter.axisMoved(controller, 2, -.2f));
    assertEquals(7, controllerAdapter.lastEventId);

    assertTrue(controllerAdapter.axisMoved(controller, 1, .8f));
    assertEquals(5, controllerAdapter.lastEventId);

    assertTrue(controllerAdapter.axisMoved(controller, 0, -.9f));
    assertEquals(6, controllerAdapter.lastEventId);

    MappedController mappedController = new MappedController(controller, mappings);
    controller.axisValues[0] = .6f;
    controller.axisValues[1] = .5f;
    controller.axisValues[2] = -.7f;
    assertEquals(.6f, mappedController.getConfiguredAxisValue(6), .01f);
    assertEquals(.5f, mappedController.getConfiguredAxisValue(5), .01f);
    assertEquals(-1f, mappedController.getConfiguredAxisValue(7), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(3), .01f);
}
项目:gdx-controllerutils    文件:ControllerMappingsTest.java   
@Test
public void testPovToAxisMapping() {
    ControllerMappings mappings = new ControllerMappings();

    // We test 3 axis
    ConfiguredInput axis1 = new ConfiguredInput(ConfiguredInput.Type.axis, 5);
    ConfiguredInput axis2 = new ConfiguredInput(ConfiguredInput.Type.axisAnalog, 6);
    ConfiguredInput axis3 = new ConfiguredInput(ConfiguredInput.Type.axisDigital, 7);

    mappings.addConfiguredInput(axis1);
    mappings.addConfiguredInput(axis2);
    mappings.addConfiguredInput(axis3);

    // ok, configuration done...
    mappings.commitConfig();

    // now we connect a Controller... and map
    MockedController controller = new MockedController();
    controller.axisValues = new float[3];
    controller.povDirection = PovDirection.east;

    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 5));
    //next call too fast
    assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 7));
    //not two directions
    controller.povDirection = PovDirection.northWest;
    assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 7));

    //not same direction on different configurations
    controller.povDirection = PovDirection.west;
    assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 7));

    //not for analog axis
    controller.povDirection = PovDirection.north;
    assertEquals(ControllerMappings.RecordResult.nothing_done, mappings.recordMapping(controller, 6));

    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 7));

    assertFalse(mappings.getControllerMapping(controller).checkCompleted());

    System.out.println(mappings.toJson().toJson(JsonWriter.OutputType.json));

    // now check
    TestControllerAdapter controllerAdapter = new TestControllerAdapter(mappings);

    assertFalse(controllerAdapter.povMoved(controller, 1, PovDirection.center));

    // the digital
    assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.center));
    assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);

    assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.east));
    assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);

    assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.southEast));
    assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);

    assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.west));
    assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);

    MappedController mappedController = new MappedController(controller, mappings);
    controller.povDirection = PovDirection.center;
    assertEquals(0, mappedController.getConfiguredAxisValue(5), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(7), .01f);

    controller.povDirection = PovDirection.north;
    assertEquals(0, mappedController.getConfiguredAxisValue(5), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
    assertEquals(-1, mappedController.getConfiguredAxisValue(7), .01f);

    controller.povDirection = PovDirection.east;
    assertEquals(1, mappedController.getConfiguredAxisValue(5), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(7), .01f);

    controller.povDirection = PovDirection.southWest;
    assertEquals(-1, mappedController.getConfiguredAxisValue(5), .01f);
    assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
    assertEquals(1, mappedController.getConfiguredAxisValue(7), .01f);
}
项目:gdx-controllerutils    文件:ControllerMappingsTest.java   
@Test
public void testJsonSaveLoad() {
    ControllerMappings mappings = new ControllerMappings();

    mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.button, 1));
    mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.axis, 2));
    mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.axis, 3));
    mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.axis, 4));

    mappings.commitConfig();

    // now we connect a Controller... and map
    MockedController controller = new MockedController();
    controller.axisValues = new float[3];
    controller.povDirection = PovDirection.center;
    controller.axisValues[0] = 1f;
    controller.pressedButton = -1;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 2));
    controller.pressedButton = 2;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 1));
    controller.pressedButton = 1;
    assertEquals(ControllerMappings.RecordResult.need_second_button, mappings.recordMapping(controller, 3));
    controller.pressedButton = 0;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 3));
    controller.pressedButton = -1;
    controller.povDirection = PovDirection.east;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 4));

    JsonValue json = mappings.toJson();
    System.out.println(json.toJson(JsonWriter.OutputType.json));
    MappedController mappedController = new MappedController(controller, mappings);
    mappings.resetMappings(controller);

    mappedController.refreshMappingCache();
    assertEquals(0, mappedController.getConfiguredAxisValue(4), 0.1f);

    mappings.fillFromJson(json);
    mappedController.refreshMappingCache();

    assertEquals(1, mappedController.getConfiguredAxisValue(4), 0.1f);
    controller.pressedButton = 2;
    assertTrue(mappedController.isButtonPressed(1));
    controller.pressedButton = 1;
    assertEquals(1, mappedController.getConfiguredAxisValue(3), 0.1f);
}
项目:gdx-controllerutils    文件:ControllerMappingsTest.java   
@Override
public PovDirection getPov(int povCode) {
    return (povCode != 0 ? PovDirection.center : povDirection);
}
项目:drc-sim-client    文件:StageConfigInput.java   
private void pollInputController() {
    int input = -1;
    int input_extra = -1;
    int input_type = -1;
    main:
    for (Controller controller : Controllers.getControllers()) {
        if (!controller.getName().equals(this.controllerName))
            continue;
        // Check axes
        for (int axis = 0; axis < 1000; axis++) {
            float ax = controller.getAxis(axis);
            if (ax > .5) {
                input_type = ConfigKeymap.Input.TYPE_AXIS;
                input = axis;
                input_extra = 1; // positive
                break main;
            }
            else if (ax < -.5) {
                input_type = ConfigKeymap.Input.TYPE_AXIS;
                input = axis;
                input_extra = 0; // negative
                break main;
            }
        }
        // Only allow an axis to be set for joystick input.
        // TODO Map all 4(8) axes to allow any input to control the joystick(s). 4 directions per joystick
        if (key.contains("JOYSTICK"))
            break;
        // Check dpad/pov
        for (int pov = 0; pov < 1000; pov++) {
            PovDirection povDirection = controller.getPov(pov);
            if (!povDirection.equals(PovDirection.center)) {
                input_type = ConfigKeymap.Input.TYPE_POV;
                input = pov;
                input_extra = povDirection.ordinal();
                break main;
            }
        }
        // Check buttons
        for (int button = 0; button < 1000; button++) {
            if (controller.getButton(button)) {
                input_type = ConfigKeymap.Input.TYPE_BUTTON;
                input = button;
                break main;
            }
        }
        return;
    }
    if (input < 0)
        return;
    // Save input
    config.putInput(this.key, input_type, input, input_extra);
    config.load();
    config.flush();
    Client.setStage(new StageConfigInput(type, config, key, displayName, controllerName));
}
项目:cgc-game    文件:ControlData.java   
public void pressPov(PovDirection dir)
{   
    if (owner.isController() && owner.isLeft())
    {
        rightFace = false;
        leftFace = false;
        upFace = false;
        downFace = false;

        switch (dir)
        {
            case center:
                break;
            case east:
                rightFace = true;
                back = true;
                break;
            case north:
                upFace = true;
                secSort = true;
                break;
            case northEast:
                upFace = true;
                rightFace = true;
                secSort = false;
                back = false;
                break;
            case northWest:
                upFace = true;
                leftFace = true;
                secSort = false;
                primSort = false;
                break;
            case south:
                downFace = true;
                select = true;
                break;
            case southEast:
                rightFace = true;
                downFace = true;
                select = false;
                back = false;
                break;
            case southWest:
                leftFace = true;
                downFace = true;
                select = false;
                primSort = false;
                break;
            case west:
                leftFace = true;
                primSort = true;
                break;
            default:
                break;
        }
    }
}
项目:base-template    文件:InputHandler.java   
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    return false;
}
项目:Space-Bombs    文件:XboxInputProcessor.java   
@Override
public boolean povMoved(Controller cntrlr, int i, PovDirection pd) 
{
    return false;
}