Java Code Examples for com.badlogic.gdx.Gdx#input()

The following examples show how to use com.badlogic.gdx.Gdx#input() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 6 votes vote down vote up
protected void onResume() {
    Gdx.app = this;
    Gdx.input = this.getInput();
    Gdx.audio = this.getAudio();
    Gdx.files = this.getFiles();
    Gdx.graphics = this.getGraphics();
    Gdx.net = this.getNet();
    this.input.onResume();
    if (this.graphics != null) {
        this.graphics.onResumeGLSurfaceView();
    }

    if (!this.firstResume) {
        this.graphics.resume();
    } else {
        this.firstResume = false;
    }

    this.isWaitingForAudio = true;
    if (this.wasFocusChanged == 1 || this.wasFocusChanged == -1) {
        this.audio.resume();
        this.isWaitingForAudio = false;
    }

    super.onResume();
}
 
Example 2
Source File: InputProxy.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Goes down the hierarchy of InputProxies, starting at Gdx.input and
 * removes the given InputProxy, if it exists. Returns if the given
 * {@link InputProxy} was found and removed.
 *
 * @param proxy the proxy to be found and removed
 * @return true if the specified proxy was removed, false otherwise
 */
public static boolean removeProxyFromGdx(InputProxy proxy) {
    if (Gdx.input == null) {
        return false;
    }
    if (Gdx.input.equals(proxy)) {
        synchronized (Gdx.input) {
            Gdx.input = proxy.getProxiedInput();
        }
        return true;
    }
    Input current = Gdx.input;
    InputProxy asProxy;
    while (current != null && current instanceof InputProxy) {
        asProxy = (InputProxy) current;
        if (asProxy.getProxiedInput() == proxy) {
            asProxy.setProxiedInput(proxy.getProxiedInput());
            return true;
        }
        current = asProxy.getProxiedInput();
    }
    return false;
}
 
Example 3
Source File: OverlayGame.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
@Override
/**
 * creates OverlayGame and sets Screen
 */
public void create () {
    // Give an int, n, to Sprites if you want an nxn matrix
    this.sprites = new Sprites();
    this.cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    this.renderer = new Renderer(cam, sprites);

    InputReplacer ir = new InputReplacer(); // Create instance of input proxy
    ir.setProxiedInput(Gdx.input); // Give InputProxy current Gdx.input
    Gdx.input = ir; // Replace Gdx.input with input proxy

    // Connect server keys with the keys that would be normally pressed
    // Add all keys that are needed and give them a different server key:
    ControlModeFacade.commandsBuffer.addKeyCommand(1, Input.Keys.LEFT);
    ControlModeFacade.commandsBuffer.addKeyCommand(0, Input.Keys.UP);
    ControlModeFacade.commandsBuffer.addKeyCommand(2, Input.Keys.DOWN);
    ControlModeFacade.commandsBuffer.addKeyCommand(3, Input.Keys.RIGHT);

    // Set screen to ExampleUseCase Menu
    setScreen(new MainMenuScreen(this));
}
 
Example 4
Source File: Game.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void create() {
	density = Gdx.graphics.getDensity();
	dispHeight = Gdx.graphics.getDisplayMode().height;
	dispWidth = Gdx.graphics.getDisplayMode().width;
	
	inputHandler = new InputHandler( Gdx.input );
	
	//refreshes texture and vertex data stored on the gpu
	versionContextRef = Gdx.graphics.getGLVersion();
	Blending.useDefault();
	TextureCache.reload();
	Vertexbuffer.refreshAllBuffers();
}
 
Example 5
Source File: Lwjgl3Mini2DxWindow.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
void makeCurrent() {
	Gdx.graphics = graphics;
	Gdx.gl30 = graphics.getGL30();
	Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
	Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
	Gdx.input = input;

	GLFW.glfwMakeContextCurrent(windowHandle);
}
 
Example 6
Source File: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 4 votes vote down vote up
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) {
    if (this.getVersion() < 8) {
        throw new GdxRuntimeException("LibGDX requires Android API Level 8 or later.");
    } else {
        this.setApplicationLogger(new AndroidApplicationLogger());
        this.graphics = new AndroidGraphics(this, config, (ResolutionStrategy) (config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy));
        this.input = AndroidInputFactory.newAndroidInput(this, this, this.graphics.view, config);
        this.audio = new AndroidAudio(this, config);
        this.getFilesDir();
        this.files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath());
        this.net = new AndroidNet(this);
        this.listener = listener;
        this.handler = new Handler();
        this.useImmersiveMode = config.useImmersiveMode;
        this.hideStatusBar = config.hideStatusBar;
        this.clipboard = new AndroidClipboard(this);
        this.addLifecycleListener(new LifecycleListener() {
            public void resume() {
            }

            public void pause() {
                audio.pause();
            }

            public void dispose() {
                audio.dispose();
            }
        });
        Gdx.app = this;
        Gdx.input = this.getInput();
        Gdx.audio = this.getAudio();
        Gdx.files = this.getFiles();
        Gdx.graphics = this.getGraphics();
        Gdx.net = this.getNet();
        if (!isForView) {
            try {
                this.requestWindowFeature(1);
            } catch (Exception var8) {
                this.log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", var8);
            }

            this.getWindow().setFlags(1024, 1024);
            this.getWindow().clearFlags(2048);
            this.setContentView(this.graphics.getView(), this.createLayoutParams());
        }

        this.createWakeLock(config.useWakelock);
        this.hideStatusBar(this.hideStatusBar);
        this.useImmersiveMode(this.useImmersiveMode);
        if (this.useImmersiveMode && this.getVersion() >= 19) {
            try {
                Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener");
                Object o = vlistener.newInstance();
                Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class);
                method.invoke(o, this);
            } catch (Exception var7) {
                this.log("AndroidApplication", "Failed to create AndroidVisibilityListener", var7);
            }
        }

    }
}