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

项目:cgc-game    文件:ChaseApp.java   
public void preLoad()
{
    input = new InputManager(se);
    Controllers.addListener(input);

    atlas = new TextureAtlas("main.atlas");
    titleScreenAtlas = new TextureAtlas("titlescreen.atlas");
    menuControlsAtlas = new TextureAtlas("menu.atlas");
    menuFont = new BitmapFont(Gdx.files.internal("data/cgcfont.fnt"), atlas.findRegion("cgcfont"), false);
    titleFont = new BitmapFont(Gdx.files.internal("data/cgctitlefont.fnt"), atlas.findRegion("cgctitlefont"), false);
    sBatch = new SpriteBatch(1625);
    shapes = new ShapeRenderer();
    tManager = new TweenManager();

    FileHandle baseFileHandle = Gdx.files.internal("i18n/CGCLang");
    I18NBundle myBundle = I18NBundle.createBundle(baseFileHandle, locale);

    lang = myBundle;
    ChaseApp.alert("lang loaded");
}
项目:nhglib    文件:InputHandlerOld.java   
public InputHandlerOld() {
    tempVec = new Vector2();

    activeContexts = new Array<>();
    activeKeyCodes = new ArrayMap<>();
    activePointers = new ArrayMap<>();
    activeMouseInputs = new ArrayMap<>();

    inputListeners = new Array<>();
    inputContexts = new ArrayMap<>();

    keyInputsMap = new ArrayMap<>();
    pointerInputsMap = new ArrayMap<>();
    stickInputsMap = new ArrayMap<>();
    mouseInputsMap = new ArrayMap<>();

    Controllers.addListener(this);

    inputMultiplexer = new InputMultiplexer(this);
    Gdx.input.setInputProcessor(inputMultiplexer);
}
项目:nhglib    文件:InputHandlerOld.java   
private void dispatchStickInputs() {
    Array<Controller> availableControllers = Controllers.getControllers();

    for (int id = 0; id < availableControllers.size; id++) {
        Controller controller = availableControllers.get(id);

        if (controller != null) {
            Array<NhgInput> stickInputs = stickInputsMap.get(id);

            if (stickInputs != null) {
                for (NhgInput input : stickInputs) {
                    if (input != null && isValidInput(input)) {
                        processStickInput(id, controller, input);
                        dispatchStickInput(input);
                    }
                }
            }
        }
    }
}
项目:libni    文件:GdxReceiverMultiplexer.java   
@Override
protected long unmappedAnalog(int unmappedAnalogNr) {
    Array<com.badlogic.gdx.controllers.Controller> controllers = Controllers.getControllers();
    float axisValue = 0;
    float axisValueAbs = 0;
    float currentAxis;
    float currentAxisAbs;
    for (int i = controllers.size - 1; i >= 0; i--) {
        com.badlogic.gdx.controllers.Controller c = controllers.get(i);
        currentAxis = c.getAxis(unmappedAnalogNr);
        currentAxisAbs = Math.abs(currentAxis);
        //Gdx.app.log("unmappedAnalog","Nr: "+unmappedAnalogNr+" Value: "+currentAxis);
        if (currentAxisAbs > axisValueAbs) { // select biggest absolute value on this axis
            axisValue = currentAxis;
            axisValueAbs = currentAxisAbs;
        }
    }
    if (axisValueAbs >= CONTROLLER_THRESHOLD) {
        return (long) (axisValue * 0x7fffffff);
    }
    return 0; // else
}
项目:neblina-libgdx3d    文件:Invaders.java   
@Override
public void create () {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp (int keycode) {
            if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
                Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目:Aftamath    文件:Game.java   
public void create() {
//      Texture.setEnforcePotImages(false);
        MyInputProcessor iP = new MyInputProcessor();
        Gdx.input.setInputProcessor(iP);
        Controllers.addListener(iP);

        res.loadTextures();
        res.loadMusic();
        res.loadScriptList(Gdx.files.internal("assets/scripts"));
        res.loadLevelNames();
        res.loadEventToTexture();

        cam = new Camera();
        cam.setToOrtho(false, width/scale, height/scale);
        hudCam = new OrthographicCamera();
        hudCam.setToOrtho(false, width/2, height/2);
        b2dCam = new Camera();
        b2dCam.setToOrtho(false, width/scale/PPM, height/scale/PPM);
        sb = new FadingSpriteBatch();
        gsm = new GameStateManager(this);

        if(Controllers.getControllers().size == 0)
            hasControllers = false;
        else hasControllers = true;
    }
项目:teavm-libgdx    文件:Invaders.java   
@Override
public void create () {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp (int keycode) {
            if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
                if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目:sanko-game    文件:CloudsGame.java   
@Override
public void create() {
    Gdx.app.setLogLevel(Application.LOG_DEBUG);
    batch = new SpriteBatch();
    hero = new Hero(screenWidth, screenHeight);
    score = new Score(screenWidth, screenHeight);
    finalScore = new FinalScore(screenWidth, screenHeight);
    bullets = new ArrayList<Bullet>();
    clouds = new ArrayList<Cloud>();
    if (Controllers.getControllers().size > 0) {
        controller = Controllers.getControllers().first();
    }
    websocketHelper = new WebsocketHelper();
    websocketHelper.connectWebSocket();

    camera = new OrthographicCamera();
    camera.setToOrtho(true, screenWidth, screenHeight);

    lastTime = TimeUtils.nanoTime();
    lastTimeSpawnedCloud = lastTime;
}
项目:seventh    文件:InGameScreen.java   
@Override
public void exit() {
    Console console = app.getConsole();

    console.removeCommand("disconnect");        
    console.removeCommand("say");                
    console.removeCommand("team_say");        
    console.removeCommand("change_team");
    console.removeCommand("rcon");
    console.removeCommand("ai");

    Controllers.removeListener(this.controllerInput);

    this.dialog.destroy();
    this.sayTxtBx.destroy();
    this.teamSayTxtBx.destroy();
}
项目:ninja-rabbit    文件:EntityFactory.java   
/**
 * Creates a new instance of {@link NinjaRabbit}, defining its graphical, audio and physical
 * properties.
 *
 * @param world
 *            The Box2D {@link World} onto which to create the {@link Body} and {@link Fixture}
 *            of the {@link Entity}.
 * @param loader
 *            A {@link BodyEditorLoader} to handle creation of the Entity body and fixtures.
 * @param assets
 *            The {@link AssetManager} from where to extract the graphical and audio resources.
 *            Those resources should be loaded in the manager before calling this method and
 *            won't be disposed.
 * @param status
 *            A reference to the global status of the player to be updated from the changes in
 *            the returned entity inner state.
 * @param observers
 *            An array of event receivers. Events will fire when the active player status
 *            changes (such as losing lives, collecting items, etc.).
 * @return A ready to use instance of a new {@link NinjaRabbit}.
 */
public static Entity createNinjaRabbit(final World world, final BodyEditorLoader loader, final AssetManager assets,
        final CurrentPlayerStatus status, final PlayerStatusObserver... observers) {
    PhysicsProcessor physics = new NinjaRabbitPhysicsProcessor();
    CONTACT_LISTENER.add(physics);
    world.setContactListener(CONTACT_LISTENER);
    GraphicsProcessor graphics = new NinjaRabbitGraphicsProcessor(assets);
    BodyProcessor bodyProcessor = new NinjaRabbitBodyProcessor(world, loader);
    AudioProcessor audio = new NinjaRabbitAudioProcessor(assets);
    PlayerStatusProcessor player = new NinjaRabbitPlayerStatusProcessor(status);
    if (observers != null) {
        for (PlayerStatusObserver o : observers) {
            player.addObserver(o);
        }
    }
    NinjaRabbit ninjaRabbit = new NinjaRabbit(player, bodyProcessor, graphics, physics, audio);

    if (Ouya.isRunningOnOuya()) {
        Controllers.clearListeners();
        Controllers.addListener(new NinjaRabbitControllerProcessor(ninjaRabbit));
    } else {
        Gdx.input.setInputProcessor(new NinjaRabbitInputProcessor(ninjaRabbit));
    }
    return ninjaRabbit;
}
项目:libgdx-demo-invaders    文件:Invaders.java   
@Override
public void create () {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp (int keycode) {
            if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
                Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目: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    文件:ControllerHelper.java   
@Override
public void connected(Controller controller) {
    if (controllers.contains(controller, true)) {
        return;
    }

    controller.addListener(this);
    controllers.add(controller);
    if (Controllers.getControllers().contains(controller, true)) {
        controllersAuto.add(controller);
    }

    for (Mapping mapping : mappings) {
        if (mapping.map(controller, this)) {
            break;
        }
    }

    refreshKeymap();
}
项目:buffer_bci    文件:Invaders.java   
@Override
public void create () {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp (int keycode) {
            if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
                if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayModes()[0]);
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目:mini2Dx    文件:UiUAT.java   
@Override
public void initialise(GameContainer gc) {
    uiContainer = new UiContainer(gc, assetManager);
    uiContainer.setKeyboardNavigationEnabled(UATApplication.USE_KEYBOARD_NAVIGATION);
    gc.addResizeListener(this);
    initialiseUi();

    if(Controllers.getControllers().size > 0) {
        try {
            System.out.println(uiContainer.getId());
            controllerInput = UiUtils.setUpControllerInput(Controllers.getControllers().get(0), uiContainer);
            if(controllerInput != null) {
                controllerInput.disable();
            }
        } catch (ControllerPlatformException e) {
            e.printStackTrace();
        }
    }
}
项目:ggvm    文件:KeyboardInputProcessor.java   
private void logControllers() {
    Array<Controller> controllers = Controllers.getControllers();
    Gdx.app.log(getClass().getSimpleName(), "****** Controller Names *********");
    for(Controller controller: controllers) {
        Gdx.app.log(getClass().getSimpleName(), controller.getName());
    }
    Gdx.app.log(getClass().getSimpleName(), "********************************");
}
项目:ggvm    文件:KeyboardInputProcessor.java   
public void autoConfigure() {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        Controller controller = controllers.get(0);
        if (isXbox360Controller(controller.getName())) {
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, XBOX_360_A);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, XBOX_360_X);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, XBOX_360_LEFT_SHOULDER);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, XBOX_360_START);
        } else if (controller.getName().equals(RETRO_USB_NAME)) {
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, RETRO_USB_A);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, RETRO_USB_B);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, RETRO_USB_SELECT);
            buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, RETRO_USB_START);
            actualAxisToAxisCode.put(Axis.X, 1);
            actualAxisToAxisCode.put(Axis.Y, 0);
        }
    }
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.A, Input.Keys.F);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.B, Input.Keys.D);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, Input.Keys.A);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.START, Input.Keys.S);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.UP, Input.Keys.UP);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.RIGHT, Input.Keys.RIGHT);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.DOWN, Input.Keys.DOWN);
    buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.LEFT, Input.Keys.LEFT);
}
项目:ggvm    文件:KeyboardInputProcessor.java   
public String getNameForButton(int button) {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        Controller controller = controllers.get(0);
        if (KeyboardInputProcessor.isXbox360Controller(controller.getName())) {
            switch(button) {
                case XBOX_360_A:
                    return "A";
                case XBOX_360_B:
                    return "B";
                case XBOX_360_X:
                    return "X";
                case XBOX_360_Y:
                    return "Y";
                case XBOX_360_LEFT_SHOULDER:
                    return "LSHLDR";
                case XBOX_360_RIGHT_SHOULDER:
                    return "RSHLDR";
                case XBOX_360_BACK:
                    return "BACK";
                case XBOX_360_START:
                    return "START";
            }
        } else if (controller.getName().equals(RETRO_USB_NAME)) {
            switch(button) {
                case RETRO_USB_A:
                    return "A";
                case RETRO_USB_B:
                    return "B";
                case RETRO_USB_SELECT:
                    return "SELECT";
                case RETRO_USB_START:
                    return "START";
            }
        }
    }
    return Integer.toString(button);
}
项目:drc-sim-client    文件:ControlController.java   
@Override
public void init(StageControl stage) {
    for (Controller controller : Controllers.getControllers()) {
        ConfigController config = new ConfigController(controller.getName());
        config.load();
        configs.put(controller, config);
    }
}
项目:Tower-Defense-Galaxy    文件:TDGalaxy.java   
@Override
public void render() {
    super.render();
    if(TDGalaxy.preferences.isDebugWindow() && debugger != null) {
        debugger.updateValue("Controllers", "Players", controlHandler.getControllers());
        debugger.updateValue("Controllers", "Controllers", Controllers.getControllers());
    }
}
项目:school-game    文件:InputManager.java   
/**
 * Privater Konstruktor.
 *
 * Verhindert, dass von außen eine Instanz erstellt werden kann.
 */
private InputManager() {
    Controllers.addListener(this);

    controllerGameButtonBindingInverse = new HashMap<ButtonKey, Action>();
    controllerGameAxisBindingInverse = new HashMap<AxisKey, Action>();
    controllerGameAxisStateInverse = new HashMap<AxisKey, Boolean>();

    controllerGameButtonBinding = new HashMap<Action, ButtonKey[]>();
    controllerGameAxisBinding = new HashMap<Action, AxisKey[]>();
}
项目:school-game    文件:InputManager.java   
/**
 * Initialisierung.
 *
 * Lädt alle angeschlossenen Controller und legt den InputProcessor fest.
 *
 * @param inputProcessor der InputProcessor an den Controllereingaben gesendet werden sollen
 */
public void init(InputProcessor inputProcessor)
{
    this.feedForwardProcessor = inputProcessor;

    for (Controller controller : Controllers.getControllers())
    {
        loadController(controller);
    }

    buildInverse();
}
项目:school-game    文件:InputManager.java   
/**
 * Prüft, ob ein Button, der zu dieser Aktion gehört, auf einem Controller im Moment gedrückt ist.
 *
 * Dabei werden auch Axenstellungen geprüft.
 *
 * @param action die Aktion
 * @return true, wenn die Aktion auf einem Controller aktiv ist
 */
private static boolean checkController(Action action)
{
    if (Controllers.getControllers().size <= 0) return false;

    boolean result = false;

    if (getInstance().controllerGameButtonBinding.containsKey(action))
    {
        ButtonKey[] buttonKeys = getInstance().controllerGameButtonBinding.get(action);

        for (ButtonKey buttonKey : buttonKeys)
            result |= buttonKey.getController() != null && buttonKey.getController().getButton(buttonKey.getButtonCode());
    }

    if (getInstance().controllerGameAxisBinding.containsKey(action))
    {
        AxisKey[] axisKeys = getInstance().controllerGameAxisBinding.get(action);

        for (AxisKey axisKey : axisKeys)
        {
            if (axisKey.getController() != null)
            {
                float axisValue = axisKey.getController().getAxis(axisKey.getAxisCode());

                result |= axisKey.isHigh() && axisValue >= 0.7f;
                result |= !axisKey.isHigh() && axisValue <= -0.7f;
            }
        }
    }

    return result;
}
项目:project-divine-intervention    文件:GamePadManager.java   
public GamePadManager() {
    Controllers.addListener(this);

    count = Controllers.getControllers().size;
    pads = new Controller[2];
    for(int i = 0; i < count; i++) {
        if(i > 1) break;
        pads[i] = Controllers.getControllers().get(i);
     }
}
项目:drc-sim-client    文件:ControlController.java   
@Override
public void init(StageControl stage) {
    for (Controller controller : Controllers.getControllers()) {
        ConfigController config = new ConfigController(controller.getName());
        config.load();
        configs.put(controller, config);
    }
}
项目:cgc-game    文件:ChaseApp.java   
public void ouyaSetup()
{
    os = "OUYA";

    Gdx.app.log("Controllers:", "My size is " + Controllers.getControllers().size);

    for(int i = 0; i < Controllers.getControllers().size; i++)
    {
        String cName = Controllers.getControllers().get(i).getName().toLowerCase();

        if(cName.contains("xbox") || cName.contains("microsoft") || cName.contains("x-box"))
        {
            se[i] = SupportedControllers.XBOX_ON_OUYA;
        }
        else if(cName.contains("playstation") || cName.contains("sony"))
        {
            se[i] = SupportedControllers.PS3_ON_OUYA;
        }
        else if(cName.contains("ouya"))
        {
            se[i] = SupportedControllers.OUYA_ON_OUYA;
        }
        else
        {   
            se[i] = SupportedControllers.NONE;
        }
    }
}
项目:gdx-controller    文件:LogitechController.java   
public LogitechController(final int controllerNumber,
                          final ButtonMapper<V> buttonMapper,
                          final AxisMapper axisMapper) {
    super.buttonMapper = buttonMapper;
    super.axisMapper = axisMapper;

    if(Controllers.getControllers().size < (controllerNumber + 1)) {
        controller = null;
        return;
    }
    controller = Controllers.getControllers().get(controllerNumber);
}
项目:Space-Bombs    文件:InputHandler.java   
public void setInputSource(Stage stage)
{
    multiInput = new InputMultiplexer();
    keyboardInput = new KeyboardInputProcessor();
    xboxInput = new XboxInputProcessor();

    multiInput.addProcessor(stage);
    multiInput.addProcessor(keyboardInput);
    multiInput.addProcessor(xboxInput);

    Controllers.addListener(xboxInput);
    Gdx.input.setInputProcessor(multiInput);
}
项目:nhglib    文件:InputHandlerOld.java   
private void mapStickInputs() {
    Array<Controller> availableControllers = Controllers.getControllers();

    for (int id = 0; id < availableControllers.size; id++) {
        Array<NhgInput> input = getStickInputsWithControllerId(id);

        if (input.size > 0) {
            stickInputsMap.put(id, input);
        }
    }
}
项目:M-M    文件:ControlsSwitchController.java   
@LmlAction("PAD")
public void setGamePadControls() {
    final Array<Controller> controllers = Controllers.getControllers();
    if (GdxArrays.isEmpty(controllers)) {
        changeControls(new InactiveControl());
    } else {
        changeControls(new GamePadControl(controllers.first()));
    }
}
项目:M-M    文件:ControlsEditController.java   
private void setCurrentControls() {
    if (control.getType() == ControlType.KEYBOARD) {
        final KeyboardControl keyboardControl = (KeyboardControl) control;
        keyUp.setText(Keys.toString(keyboardControl.getUp()));
        keyDown.setText(Keys.toString(keyboardControl.getDown()));
        keyLeft.setText(Keys.toString(keyboardControl.getLeft()));
        keyRight.setText(Keys.toString(keyboardControl.getRight()));
    } else if (control.getType() == ControlType.PAD) {
        final GamePadControl gamePadControl = (GamePadControl) control;
        padUp.setText(String.valueOf(gamePadControl.getUp()));
        padDown.setText(String.valueOf(gamePadControl.getDown()));
        padLeft.setText(String.valueOf(gamePadControl.getLeft()));
        padRight.setText(String.valueOf(gamePadControl.getRight()));
        invertXButton.setChecked(gamePadControl.isInvertX());
        invertYButton.setChecked(gamePadControl.isInvertY());
        invertXYButton.setChecked(gamePadControl.isInvertXY());
        // Allowing the player to choose controller device:
        controllersSelect.getItems().clear();
        controllersSelect.getSelection().setMultiple(false);
        controllersSelect.getSelection().setRequired(true);
        controllers = Controllers.getControllers();
        final String[] items = new String[controllers.size];
        for (int index = 0; index < controllers.size; index++) {
            final Controller controller = controllers.get(index);
            items[index] = controller.getName().replaceAll(Strings.WHITESPACE_SPLITTER_REGEX, " ");
        }
        controllersSelect.setItems(items);
        final int controllerIndex = controllers.indexOf(gamePadControl.getController(), true);
        controllersSelect.setSelectedIndex(controllerIndex < 0 ? 0 : controllerIndex);
    }
}
项目:M-M    文件:GamePadControl.java   
/** @param controller will be used to control the entity. */
public void setController(final Controller controller) {
    if (this.controller != null) {
        this.controller.removeListener(controllerListener);
    }
    this.controller = controller;
    if (controller != null) {
        controllerIndex = Controllers.getControllers().indexOf(controller, true);
    }
}
项目:OpenAW    文件:ScreenControls.java   
@Override
public void create() {
    logger.info("- - - - - - - - - - - - - - - - - - - - - -");
    for (Controller controller : Controllers.getControllers()) {
        logger.info("Controller detected: {}", controller.getName());
    }/**/
}
项目:Protoman-vs-Megaman    文件:GDXGame.java   
/**
 * automatically called when a gamestate gets active within a call to {@link #setGameState(GameStateType, boolean, boolean, Object)}
 * Sets the active inputadapter of the game. Each {@link GameStateLogic} instance is a {@link GameInputAdapter}
 * to listen to keyboard/mouse/touch/controller events.
 *  
 * @param gameInputAdapter active input adapater to listen to keyboard,mouse,touch and controller events
 */
private void setGameInput(GameInputAdapter gameInputAdapter) {
    if (currentInputAdapter != null) {
        // remove the previous inputadapter as Controllerlistener
        Controllers.removeListener(currentInputAdapter);
    }

    // set the active inputadapter as new libgdx inputprocessor to listen to keyboard,mouse and touch events
    Gdx.input.setInputProcessor(gameInputAdapter);
    // add the active inputadapter as Controllerlistener to listen to controller events
    Controllers.addListener(gameInputAdapter);
    // remember the active inputadapter for later to remove it as Controllerlistener if no longer needed
    currentInputAdapter = gameInputAdapter;
}
项目:android-screen-recorder    文件:Invaders.java   
@Override
public void create() {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3",
            FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp(int keycode) {
            if (keycode == Keys.ENTER
                    && Gdx.app.getType() == ApplicationType.WebGL) {
                if (!Gdx.graphics.isFullscreen())
                    Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目:teavm-libgdx    文件:OverlayTransformer.java   
private void transformControllers(final ClassHolder cls, ClassReaderSource classSource) {
    MethodDescriptor desc = new MethodDescriptor("initialize", void.class);
    cls.removeMethod(cls.getMethod(desc));
    ClassReader patchClass = classSource.get(ControllersEmulator.class.getName());
    MethodHolder patch = ModelUtils.copyMethod(patchClass.getMethod(desc));
    ClassRefsRenamer renamer = new ClassRefsRenamer(preimage -> {
        if (preimage.equals(ControllersEmulator.class.getName())) {
            return Controllers.class.getName();
        }
        return preimage;
    });
    cls.addMethod(renamer.rename(patch));
}
项目:NicolasRage    文件:Player.java   
public void addController()
{
    for(Controller c : Controllers.getControllers())
    {
        if(c != null)
        {
            controller = c;

        }
    }
}
项目:gaiasky    文件:SpacecraftCamera.java   
@Override
public void updateMode(CameraMode mode, boolean postEvent) {
    InputMultiplexer im = (InputMultiplexer) Gdx.input.getInputProcessor();
    if (mode == CameraMode.Spacecraft) {
        Gdx.app.postRunnable(() -> {
            // Register input controller
            if (!im.getProcessors().contains(inputController, true))
                im.addProcessor(im.size(), inputController);
            // Register controller listener
            Controllers.clearListeners();
            Controllers.addListener(controllerListener);
            sc.stopAllMovement();
            if (firstTime) {
                // Put spacecraft close to earth
                Vector3d earthpos = GaiaSky.instance.sg.getNode("Earth").getPosition();
                sc.pos.set(earthpos.x + 12000 * Constants.KM_TO_U, earthpos.y, earthpos.z);

                firstTime = false;
            }
        });
    } else {
        Gdx.app.postRunnable(() -> {
            // Unregister input controller
            im.removeProcessor(inputController);
            // Unregister controller listener
            Controllers.removeListener(controllerListener);
            sc.stopAllMovement();
        });
    }
}
项目:gaiasky    文件:NaturalCamera.java   
/**
 * Updates the camera mode
 */
@Override
public void updateMode(CameraMode mode, boolean postEvent) {
    InputMultiplexer im = (InputMultiplexer) Gdx.input.getInputProcessor();
    switch (mode) {
    case Focus:
        diverted = false;
        checkFocus();
    case Free_Camera:
    case Gaia_Scene:
        Gdx.app.postRunnable(() -> {
            // Register input controller
            if (!im.getProcessors().contains(inputController, true))
                im.addProcessor(im.size(), inputController);
            // Register controller listener
            Controllers.clearListeners();
            Controllers.addListener(controllerListener);
        });
        break;
    default:
        Gdx.app.postRunnable(() -> {
            // Unregister input controller
            im.removeProcessor(inputController);
            // Unregister controller listener
            Controllers.removeListener(controllerListener);
        });
        break;
    }
}
项目:snappyfrog    文件:OuyaServices.java   
@Override
public void initGamePadControllers() {
    for(Controller controller: Controllers.getControllers()) {
           controllers.add(controller);
    }   

    Controllers.addListener(this);
}