Java 类com.badlogic.gdx.Input.Peripheral 实例源码
项目:Point-and-Hit
文件:OneShotGame.java
@Override
public void create() {
// Preferences
preferences = Gdx.app.getPreferences("prefs");
scale = findScale();
// Loading global textures
buttons = new Texture(Gdx.files
.internal("buttons/buttons.png"));
if (!Gdx.input.isPeripheralAvailable(Peripheral.Compass)) {
this.setScreen(new NoCompassScreen(scale));
} else {
mainMenu = new MainMenuScreen(this);
this.setScreen(mainMenu);
}
}
项目:gdx.automation
文件:InputProperty.java
/**
* Copies the {@link StaticProperties} from the current {@link Gdx libGdx}
* environment.
*
* @return the {@link StaticProperties} of the current environment
*/
public static StaticProperties getCurrentStaticValues() {
StaticProperties result = new StaticProperties();
result.accelerometerAvailable = Gdx.input
.isPeripheralAvailable(Peripheral.Accelerometer);
result.compassAvailable = Gdx.input
.isPeripheralAvailable(Peripheral.Compass);
result.keyboardAvailable = Gdx.input
.isPeripheralAvailable(Peripheral.HardwareKeyboard);
result.onscreenKeyboard = Gdx.input
.isPeripheralAvailable(Peripheral.OnscreenKeyboard);
result.vibrator = Gdx.input.isPeripheralAvailable(Peripheral.Vibrator);
result.hasMultitouch = Gdx.input
.isPeripheralAvailable(Peripheral.MultitouchScreen);
result.nativeOrientation = Gdx.input.getNativeOrientation();
return result;
}
项目:Secludedness
文件:LevelScreen.java
@Override
public void show() {
super.show();
mTexture = new Texture(Gdx.files.internal("textures/player.png"));
mPlayerTexture = new TextureRegion(mTexture, 0, 0, 64, 64);
mFont = new BitmapFont();
mFont.setColor(1.0f, 0.5f, 1.0f, 1.0f);
// TODO: Change input based on settings
if ((Gdx.app.getType() == ApplicationType.Android) && (Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer))) {
mUsePolling = true;
} else {
mUsePolling = false;
}
mInputManager = new InputManager(mGame, mLevel, mPlayer);
Gdx.input.setInputProcessor(mInputManager);
}
项目:ingress-indonesia-dev
文件:AndroidInput.java
public final boolean isPeripheralAvailable(Input.Peripheral paramPeripheral)
{
boolean bool = true;
if (paramPeripheral == Input.Peripheral.Accelerometer)
bool = this.accelerometerAvailable;
do
{
do
{
return bool;
if (paramPeripheral == Input.Peripheral.Compass)
return this.compassAvailable;
if (paramPeripheral == Input.Peripheral.HardwareKeyboard)
return this.keyboardAvailable;
}
while (paramPeripheral == Input.Peripheral.OnscreenKeyboard);
if (paramPeripheral != Input.Peripheral.Vibrator)
break;
}
while (this.vibrator != null);
return false;
if (paramPeripheral == Input.Peripheral.MultitouchScreen)
return this.hasMultitouch;
return false;
}
项目:ingress-indonesia-dev
文件:RemoteSender.java
public RemoteSender(String paramString, int paramInt)
{
try
{
Socket localSocket = new Socket(paramString, paramInt);
localSocket.setTcpNoDelay(true);
localSocket.setSoTimeout(3000);
this.out = new DataOutputStream(localSocket.getOutputStream());
this.out.writeBoolean(Gdx.input.isPeripheralAvailable(Input.Peripheral.MultitouchScreen));
this.connected = true;
Gdx.input.setInputProcessor(this);
return;
}
catch (Exception localException)
{
Gdx.app.log("RemoteSender", "couldn't connect to " + paramString + ":" + paramInt);
}
}
项目:libgdxcn
文件:RemoteSender.java
public RemoteSender (String ip, int port) {
try {
Socket socket = new Socket(ip, port);
socket.setTcpNoDelay(true);
socket.setSoTimeout(3000);
out = new DataOutputStream(socket.getOutputStream());
out.writeBoolean(Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen));
connected = true;
Gdx.input.setInputProcessor(this);
} catch (Exception e) {
Gdx.app.log("RemoteSender", "couldn't connect to " + ip + ":" + port);
}
}
项目:libgdxcn
文件:MultitouchTest.java
@Override
public void create () {
Gdx.app.log("Multitouch", "multitouch supported: " + Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen));
renderer = new ShapeRenderer();
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.set(Gdx.graphics.getWidth() / 2.0f, Gdx.graphics.getHeight() / 2.0f, 0);
Gdx.input.setInputProcessor(this);
}
项目:HAW-SE2-projecthorse
文件:SettingsImpl.java
@Override
public boolean getAccelerometerState() {
if (prefs.contains("Accelerometer")) {
return prefs.getBoolean("Accelerometer");
}
boolean isPossible = Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer);
prefs.putBoolean("Accelerometer", isPossible);
prefs.flush();
return isPossible;
}
项目:bladecoder-adventure-engine
文件:DefaultSceneScreen.java
@Override
public void setUI(final UI ui) {
this.ui = ui;
recorder = ui.getRecorder();
testerBot = ui.getTesterBot();
pie = new PieMenu(this);
textManagerUI = new TextManagerUI(ui.getSkin());
menuButton = new Button(ui.getSkin(), "menu");
dialogUI = new DialogUI(ui);
pointer = new ScenePointer(ui.getSkin());
inventoryUI = new InventoryUI(this, pointer);
inventoryButton = new InventoryButton(ui.getSkin(), inventoryUI);
uiMode = UIModes.valueOf(Config.getProperty(Config.UI_MODE, "TWO_BUTTONS").toUpperCase(Locale.ENGLISH));
if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen) && uiMode == UIModes.TWO_BUTTONS) {
uiMode = UIModes.PIE;
}
pie.setVisible(false);
menuButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
ui.setCurrentScreen(Screens.MENU_SCREEN);
}
});
retrieveAssets(ui.getUIAtlas());
stage = new Stage(viewport);
stage.addActor(textManagerUI);
stage.addActor(dialogUI);
stage.addActor(inventoryButton);
stage.addActor(menuButton);
stage.addActor(inventoryUI);
stage.addActor(pie);
}
项目:bladecoder-adventure-engine
文件:ScenePointer.java
public void draw(SpriteBatch batch, Viewport v) {
getInputUnproject(v, mousepos);
boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen);
// DRAW TARGET DESCRIPTION
if (desc != null && (!multiTouch || Gdx.input.isTouched())) {
float margin = DPIUtils.UI_SPACE;
float textX = mousepos.x - layout.width / 2;
float textY = mousepos.y + layout.height + DPIUtils.UI_SPACE + DPIUtils.getTouchMinSize();
if (textX < 0)
textX = 0;
RectangleRenderer.draw(batch, textX - margin, textY - layout.height - margin, layout.width + margin * 2,
layout.height + margin * 2, Color.BLACK);
font.draw(batch, layout, textX, textY);
}
if (draggingActor == null) {
if (!multiTouch || currentIcon == leaveIcon) {
batch.draw(currentIcon, mousepos.x - currentIcon.getRegionWidth() / 2,
mousepos.y - currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth() / 2,
currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth(), currentIcon.getRegionHeight(),
pointerScale, pointerScale, currentIcon == leaveIcon ? leaveRotation : 0);
}
} else {
float h = (draggingActor.getHeight() > draggingActor.getWidth() ? draggingActor.getHeight()
: draggingActor.getWidth());
float size = DPIUtils.getTouchMinSize() / h * 1.8f;
ActorRenderer r = draggingActor.getRenderer();
r.draw(batch, mousepos.x, mousepos.y - draggingActor.getHeight() * size / 2, size, 0f,
currentIcon != hotspotIcon ? tmpTint : draggingActor.getTint());
}
}
项目:bladecoder-adventure-engine
文件:HelpScreen.java
@Override
public void show() {
final Locale locale = I18N.getCurrentLocale();
String filename = null;
UIModes uiMode = UIModes.valueOf(Config.getProperty(Config.UI_MODE, "TWO_BUTTONS").toUpperCase(Locale.ENGLISH));
if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen) && uiMode == UIModes.TWO_BUTTONS) {
uiMode = UIModes.PIE;
}
switch (uiMode) {
case PIE:
filename = PIE_FILENAME;
break;
case SINGLE_CLICK:
filename = SINGLE_CLICK_FILENAME;
break;
case TWO_BUTTONS:
filename = TWO_BUTTONS_FILENAME;
break;
}
localeFilename = MessageFormat.format("{0}_{1}.png", filename, locale.getLanguage());
if (!EngineAssetManager.getInstance().assetExists(localeFilename))
localeFilename = MessageFormat.format("{0}.png", filename);
tex = new Texture(EngineAssetManager.getInstance().getResAsset(localeFilename));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Gdx.input.setInputProcessor(inputProcessor);
}
项目:bladecoder-adventure-engine
文件:Pointer.java
public void show() {
if(!Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)) {
setVisible(true);
} else {
setVisible(false);
}
}
项目:GlassSensorTest
文件:TestSensor.java
@Override
public void create() {
// Gdx.input
// .setInputProcessor(new GestureDetector(new MyGestureListener(this)));
Gdx.input.setInputProcessor(new InputHandler(this));
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
available = Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer);
}
项目:ingress-indonesia-dev
文件:RemoteInput.java
public boolean isPeripheralAvailable(Input.Peripheral paramPeripheral)
{
if (paramPeripheral == Input.Peripheral.Accelerometer);
while (paramPeripheral == Input.Peripheral.Compass)
return true;
if (paramPeripheral == Input.Peripheral.MultitouchScreen)
return this.multiTouch;
return false;
}
项目:gaiasky
文件:NaturalCamera.java
public void initialize(AssetManager assetManager) {
camera = new PerspectiveCamera(GlobalConf.scene.CAMERA_FOV, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = (float) CAM_NEAR;
camera.far = (float) CAM_FAR;
// init cameras vector
cameras = new PerspectiveCamera[] { camera, camLeft, camRight };
fovFactor = camera.fieldOfView / 40f;
up = new Vector3d(1, 0, 0);
direction = new Vector3d(0, 1, 0);
focusDirection = new Vector3d();
desired = new Vector3d();
pitch = new Vector3d(0.0f, 0.0f, -3.0291599E-6f);
yaw = new Vector3d(0.0f, 0.0f, -7.9807205E-6f);
roll = new Vector3d(0.0f, 0.0f, -1.4423944E-4f);
horizontal = new Vector3d();
vertical = new Vector3d();
friction = new Vector3d();
lastvel = new Vector3d();
focusPos = new Vector3d();
aux1 = new Vector3d();
aux2 = new Vector3d();
aux3 = new Vector3d();
aux4 = new Vector3d();
aux5 = new Vector3d();
auxf1 = new Vector3();
aux2f2 = new Vector2();
dx = new Vector3d();
accelerometer = Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer);
inputController = new NaturalInputController(this);
controllerListener = new NaturalControllerListener(this, GlobalConf.controls.CONTROLLER_MAPPINGS_FILE);
// Init sprite batch for crosshair
spriteBatch = new SpriteBatch();
// Focus crosshair
focusCrosshair = new Texture(Gdx.files.internal("img/crosshair-green.png"));
focusCrosshair.setFilter(TextureFilter.Linear, TextureFilter.Linear);
// Focus arrow
focusArrow = new Texture(Gdx.files.internal("img/crosshair-green-arrow.png"));
focusArrow.setFilter(TextureFilter.Linear, TextureFilter.Linear);
// Velocity vector crosshair
velocityCrosshair = new Texture(Gdx.files.internal("img/ai-vel.png"));
velocityCrosshair.setFilter(TextureFilter.Linear, TextureFilter.Linear);
// Antivelocity vector crosshair
antivelocityCrosshair = new Texture(Gdx.files.internal("img/ai-antivel.png"));
antivelocityCrosshair.setFilter(TextureFilter.Linear, TextureFilter.Linear);
// Speed HUD
Texture sHUD = new Texture(Gdx.files.internal("img/hud-corners.png"));
sHUD.setFilter(TextureFilter.Linear, TextureFilter.Linear);
hudw = sHUD.getWidth();
hudh = sHUD.getHeight();
hudScales = new double[] { HUD_SCALE_MIN, HUD_SCALE_MIN + (HUD_SCALE_MAX - HUD_SCALE_MIN) / 3d, HUD_SCALE_MIN + (HUD_SCALE_MAX - HUD_SCALE_MIN) * 2d / 3d };
hudSprites = new Sprite[hudScales.length];
hudColors = new Color[] { Color.WHITE, Color.GREEN, Color.GOLD, Color.LIME, Color.PINK, Color.ORANGE, Color.CORAL, Color.CYAN, Color.FIREBRICK, Color.FOREST };
for (int i = 0; i < hudScales.length; i++) {
hudSprites[i] = new Sprite(sHUD);
hudSprites[i].setOriginCenter();
}
// Focus is changed from GUI
EventManager.instance.subscribe(this, Events.FOCUS_CHANGE_CMD, Events.FOV_CHANGED_CMD, Events.ORIENTATION_LOCK_CMD, Events.CAMERA_POS_CMD, Events.CAMERA_DIR_CMD, Events.CAMERA_UP_CMD, Events.CAMERA_FWD, Events.CAMERA_ROTATE, Events.CAMERA_PAN, Events.CAMERA_ROLL, Events.CAMERA_TURN, Events.CAMERA_STOP, Events.CAMERA_CENTER, Events.GO_TO_OBJECT_CMD, Events.PLANETARIUM_FOCUS_ANGLE_CMD, Events.PLANETARIUM_CMD);
}
项目:Secludedness
文件:InputManager.java
public void pollPlayerInput(float delta, Level level, Player player) {
int xPosition = player.getPositionX();
int yPosition = player.getPositionY();
if ((Gdx.app.getType() == ApplicationType.Android) && (Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer))) {
float accelX = Gdx.input.getAccelerometerX();
float accelY = Gdx.input.getAccelerometerY();
// Game is in landscape, so rotate axes when default orientation is portrait
if (Gdx.input.getNativeOrientation() == Orientation.Portrait) {
accelX = Gdx.input.getAccelerometerY();
accelY = Gdx.input.getAccelerometerX();
}
float sensibility = 4.0f;
if (Math.abs(accelX) <= 1.0f && Math.abs(accelY) <= 1.0f) {
mAccelerometerReadyForPolling = true;
return;
}
if (mAccelerometerReadyForPolling) {
if (accelX > sensibility) {
xPosition += 64;
mAccelerometerReadyForPolling = false;
} else if (accelX < -sensibility) {
xPosition -= 64;
mAccelerometerReadyForPolling = false;
} else if (accelY > sensibility) {
yPosition -= 64;
mAccelerometerReadyForPolling = false;
} else if (accelY < -sensibility) {
yPosition += 64;
mAccelerometerReadyForPolling = false;
}
}
} else {
if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
xPosition += 64;
} else if (Gdx.input.isKeyPressed(Keys.LEFT)) {
xPosition -= 64;
} else if (Gdx.input.isKeyPressed(Keys.UP)) {
yPosition += 64;
} else if (Gdx.input.isKeyPressed(Keys.DOWN)) {
yPosition -= 64;
}
}
handlePlayer(xPosition, yPosition);
}
项目:smoothcam
文件:SmoothCamTest.java
@Override
public void render () {
if (isTweening && timeline.isFinished()) {
isTweening = false;
}
if (!isTweening) {
if (Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer)) {
float accelX = Gdx.input.getAccelerometerX();
float accelY = Gdx.input.getAccelerometerY();
body.applyLinearImpulse(new Vector2(accelY * 30f, accelX * -30f), body.getLocalCenter(), true);
} else {
if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT))
body.applyLinearImpulse(new Vector2(-150f, 0f), body.getLocalCenter(), true);
if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT))
body.applyLinearImpulse(new Vector2(150f, 0f), body.getLocalCenter(), true);
if (Gdx.input.isKeyPressed(Keys.DPAD_UP))
body.applyLinearImpulse(new Vector2(0f, 150f), body.getLocalCenter(), true);
if (Gdx.input.isKeyPressed(Keys.DPAD_DOWN))
body.applyLinearImpulse(new Vector2(0f, -150f), body.getLocalCenter(), true);
if (Gdx.input.isKeyPressed(Keys.D) || Gdx.input.isKeyPressed(Keys.A)) {
if (Gdx.input.isKeyPressed(Keys.D)) {
player.setAiming(1, player.getAimingY());
}
if (Gdx.input.isKeyPressed(Keys.A)) {
player.setAiming(-1, player.getAimingY());
}
}
else {
player.setAiming(0, player.getAimingY());
}
if (Gdx.input.isKeyPressed(Keys.W) || Gdx.input.isKeyPressed(Keys.S)) {
if (Gdx.input.isKeyPressed(Keys.W)) {
player.setAiming(player.getAimingX(), 1);
}
if (Gdx.input.isKeyPressed(Keys.S)) {
player.setAiming(player.getAimingX(), -1);
}
}
else {
player.setAiming(player.getAimingX(), 0);
}
}
/*
* Updating the position and velocity of the SmoothCamSubject using Box2D. In this example, maximum velocity of the body
* is around 122, so we have to divide by that value to get the relative value between -1 and 1 that we need for
* SmoothCamWorld. After that, update the SmoothCamWorld.
*/
world.step(1 / 60f, 6, 2);
player.setPosition(body.getPosition().x, body.getPosition().y);
player.setVelocity(body.getLinearVelocity().x / 122f, body.getLinearVelocity().y / 122f);
scw.update();
} else {
/*
* Updating the Tween-Timeline
*/
tweenManager.update(Gdx.graphics.getDeltaTime());
}
/*
* Center the libGDX camera using the coordinates of the SmoothCamWorld
*/
camera.position.set(scw.getX(), scw.getY(), 0);
camera.viewportWidth = w * scw.getZoom();
camera.viewportHeight = h * scw.getZoom();
camera.update();
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
debugRenderer.render(world, camera.combined);
/* Rendering the debug shapes for the SmoothCamWorld */
scDebug.render(scw, camera.combined);
}
项目:JavaLib
文件:InputSystem.java
/**
* Constructs an InputSystem.
*
* @param input
* The game's {@link InputMultiplexer}.
*/
public InputSystem(InputMultiplexer input) {
this.input = input;
tiltEnabled = Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer);
}