Android Open Source - non input






From Project

Back to project page non.

License

The source code is released under:

MIT License

If you think the Android project non listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package non.plugins;
/*from w w w.  j a  va  2s. c o m*/
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;

import non.InputHandle;

public class input extends Plugin {
    public String author()      { return "Thomas Slusny"; }
    public String license()     { return "MIT"; }
    public String description() { return "Plugin for handling input from user."; }

    public class Keyboard {
        public void show() {
            Gdx.input.setOnscreenKeyboardVisible(true);
        }
        
        public void hide() {
            Gdx.input.setOnscreenKeyboardVisible(false);
        }
        
        public boolean isDown(String name) {
            int key = InputHandle.getKey(name);
            return Gdx.input.isKeyPressed(key) && key != 0;
        }
    }
    
    public class Mouse {
        public void show() {
            Gdx.input.setCursorCatched(false);
        }
        
        public void hide() {
            Gdx.input.setCursorCatched(true);
        }
        
        public float getX() {
            return Gdx.input.getX();
        }
        
        public float getY() {
            return Gdx.input.getY();
        }
        
        public Vector2 getPosition() {
            return new Vector2(Gdx.input.getY(), Gdx.input.getY());
        }
        
        public void setPosition(float x, float y) {
            Gdx.input.setCursorPosition((int)x, (int)y);
        }
        
        public boolean isDown() {
            return Gdx.input.isTouched();
        }
        
        public boolean isDown(String name) {
            return Gdx.input.isButtonPressed(InputHandle.getButton(name));
        }
    }
    
    public class Touch {
        public float getX() {
            return Gdx.input.getX();
        }
        
        public float getX(int index) {
            return Gdx.input.getX(index);
        }
        
        public float getY() {
            return Gdx.input.getY();
        }
        
        public float getY(int index) {
            return Gdx.input.getY(index);
        }
        
        public Vector2 getPosition() {
            return new Vector2(Gdx.input.getY(), Gdx.input.getY());
        }
        
        public Vector2 getPosition(int index) {
            return new Vector2(Gdx.input.getY(index), Gdx.input.getY(index));
        }
        
        public boolean isDown() {
            return Gdx.input.isTouched();
        }
        
        public boolean isDown(int index) {
            return Gdx.input.isTouched(index);
        }
    }
    
    public class Accelerometer {
        public float getX() {
            return Gdx.input.getAccelerometerX();
        }
        
        public float getY() {
            return Gdx.input.getAccelerometerY();
        }
        
        public float getZ() {
            return Gdx.input.getAccelerometerZ();
        }
        
        public int getRotation() {
            return Gdx.input.getRotation();
        }
    }
    
    public final Keyboard keyboard = new Keyboard();
    public final Mouse mouse = new Mouse();
    public final Touch touch = new Touch();
    public final Accelerometer accelerometer = new Accelerometer();

    public void vibrate(int duration) { Gdx.input.vibrate(duration); }
}




Java Source Code List

%PACKAGE%.android.AndroidLauncher.java
%PACKAGE%.desktop.DesktopLauncher.java
%PACKAGE%.ios.IOSLauncher.java
launcher.Main.java
non.InputHandle.java
non.Line.java
non.NonBuffer.java
non.Non.java
non.Quad.java
non.languages.Language.java
non.languages.javascript.java
non.languages.lua.java
non.plugins.Plugin.java
non.plugins.audio.java
non.plugins.graphics.java
non.plugins.input.java
non.plugins.lights.java
non.plugins.math.java
non.plugins.network.java
non.plugins.non.java
non.plugins.physics.java