com.badlogic.gdx.Input.Buttons Java Examples

The following examples show how to use com.badlogic.gdx.Input.Buttons. 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: FluidSimulatorSPH.java    From fluid-simulator-v2 with Apache License 2.0 6 votes vote down vote up
public boolean touchDown(int x, int y, int pointer, int button) {
	touching = true;
	camera.unproject(testPoint.set(x, y, 0));
	testPoint2D.x = testPoint.x;
	testPoint2D.y = testPoint.y;
	if (button == Buttons.LEFT) {
		if (!IS_DESKTOP) {
			isRepulsing = true;
			isAttracting = false;
		} else {
			isAttracting = false;
			isRepulsing = false;
		}
	}
	if (button == Buttons.RIGHT) {
		isAttracting = true;
	}
	if (button == Buttons.MIDDLE) {
		isRepulsing = true;
	}
	return false;
}
 
Example #2
Source File: FluidSimulatorSPH.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
public boolean touchUp(int x, int y, int pointer, int button) {
	touching = false;
	if (!IS_DESKTOP) {
		isRepulsing = false;
		isAttracting = false;
	}
	if (button == Buttons.RIGHT) {
		isAttracting = false;
	}
	if (button == Buttons.MIDDLE) {
		isRepulsing = false;
	}
	return false;
}
 
Example #3
Source File: KeyMap.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
private void refresh() {
    this.reloadKey = getKey(config, "reload", Keys.R);
    this.walkKey = getKey(config, "walk", Keys.SHIFT_LEFT);
    this.crouchKey = getKey(config, "crouch", Keys.CONTROL_LEFT);
    this.sprintKey = getKey(config, "sprint", Keys.SPACE);
    this.upKey = getKey(config, "up", Keys.W);
    this.downKey = getKey(config, "down", Keys.S);
    this.leftKey = getKey(config, "left", Keys.A);
    this.rightKey = getKey(config, "right", Keys.D);
    this.fireKey = getKey(config, "fire", Buttons.LEFT);
    this.throwGrenadeKey = getKey(config, "throw_grenade", Buttons.RIGHT);
    this.useKey  = getKey(config, "use", Keys.E);
    this.dropWeaponKey  = getKey(config, "drop_weapon", Keys.F);
    this.meleeAttackKey = getKey(config, "melee_attack", Keys.Q);
    this.ironSightsKey = getKey(config, "iron_sites", Keys.Z);
    this.invertMouse = LeoObject.isTrue(config.getByString("inverted"));
    this.tileSelectKey = getKey(config, "tile_select", Keys.F1);
    
    this.sayKey = getKey(config, "say", Keys.Y);
    this.teamSayKey = getKey(config, "team_say", Keys.T);
    
    this.reloadBtn = getKey(joystick, "reload", ControllerButtons.X_BTN);
    this.walkBtn = getKey(joystick, "walk", ControllerButtons.LEFT_TRIGGER_BTN);
    this.crouchBtn = getKey(joystick, "crouch", ControllerButtons.LEFT_BUMPER_BTN);
    this.sprintBtn = getKey(joystick, "sprint", ControllerButtons.LEFT_JOYSTICK_BTN);
    this.upBtn = getKey(joystick, "up", ControllerButtons.NORTH_DPAD_BTN);
    this.downBtn = getKey(joystick, "down", ControllerButtons.SOUTH_DPAD_BTN);
    this.leftBtn = getKey(joystick, "left", ControllerButtons.WEST_DPAD_BTN);
    this.rightBtn = getKey(joystick, "right", ControllerButtons.EAST_DPAD_BTN);
    this.fireBtn = getKey(joystick, "fire", ControllerButtons.RIGHT_TRIGGER_BTN);
    this.throwGrenadeBtn = getKey(joystick, "throw_grenade", ControllerButtons.B_BTN);
    this.useBtn  = getKey(joystick, "use", ControllerButtons.A_BTN);
    this.dropWeaponBtn = getKey(joystick, "drop_weapon", ControllerButtons.SELECT_BTN);
    this.meleeAttackBtn = getKey(joystick, "melee_attack", ControllerButtons.RIGHT_JOYSTICK_BTN);
    this.ironSightsBtn = getKey(joystick, "iron_sites", ControllerButtons.RIGHT_BUMPER_BTN);
    // TODO: this.tileSelectBtn = getKey(joystick, "tile_select", ControllerButtons.SELECT_BTN);
    
    this.invertJoystick = LeoObject.isTrue(joystick.getByString("inverted"));
    this.isSouthPaw = LeoObject.isTrue(joystick.getByString("south_paw"));
}
 
Example #4
Source File: FluidSimulatorMPM.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
	touching = false;
	
	// MPM Fluid interaction 
	mpmSolver.pressed = false;
	
	if (!IS_DESKTOP) {
		isRepulsing = false;
		isAttracting = false;
	}
	if (button == Buttons.RIGHT) {
		isAttracting = false;
	}
	if (button == Buttons.MIDDLE) {
		isRepulsing = false;
	}
	
	// if a mouse joint exists we simply destroy it
	if (mouseJoint != null) {
		if (dragVelocity.len() > 1)
			mouseJoint.getBodyB().setLinearVelocity(dragVelocity.scl(50000));
		world.destroyJoint(mouseJoint);
		mouseJoint = null;
	}
	hitBody = null;
	dragVelocity.set(0, 0);
	
	if (pointer == 2) {
		emitType ++;
		if (emitType > 3)
			emitType = 1;
	}
	
	return false;
}
 
Example #5
Source File: AttackBattleState.java    From Norii with Apache License 2.0 5 votes vote down vote up
@Override
public void buttonPressed(int button) {
	switch (button) {
	case Buttons.RIGHT:
		ParticleMaker.deactivateAllParticlesOfType(ParticleType.ATTACK);
		exit();
		break;
	case Buttons.LEFT:
		break;
	case Buttons.MIDDLE:
		break;
	default:
		break;
	}
}
 
Example #6
Source File: InputController.java    From TerraLegion with MIT License 5 votes vote down vote up
/**
 * Returns the last input that was pressed.
 *
 * @return an integer representing either Buttons.LEFT, Buttons.MIDDLE, or Buttons.RIGHT. -1 if not one of the buttons.
 */
private int getButtonPressed() {
	if (Gdx.input.isButtonPressed(Buttons.LEFT))
		return Buttons.LEFT;
	else if (Gdx.input.isButtonPressed(Buttons.MIDDLE))
		return Buttons.MIDDLE;
	else if (Gdx.input.isButtonPressed(Buttons.RIGHT))
		return Buttons.RIGHT;
	return -1;
}
 
Example #7
Source File: ResizeFourArrowListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void enter(InputEvent event, float x, float y, int pointer,
        Actor fromActor) {
    if (event.getListenerActor().equals(event.getTarget()) && !Gdx.input.isButtonPressed(Buttons.LEFT)) {
        Gdx.graphics.setCursor(cursor);
    }
}
 
Example #8
Source File: ResizeFourArrowListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void exit(InputEvent event, float x, float y, int pointer,
        Actor toActor) {
    if (event.getListenerActor().equals(event.getTarget()) && !Gdx.input.isButtonPressed(Buttons.LEFT)) {
        Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
    }
}
 
Example #9
Source File: SpellBattleState.java    From Norii with Apache License 2.0 5 votes vote down vote up
@Override
public void buttonPressed(final int button) {
	switch (button) {
	case Buttons.RIGHT:
		ParticleMaker.deactivateAllParticlesOfType(ParticleType.SPELL);
		exit();
		break;
	case Buttons.LEFT:
		break;
	case Buttons.MIDDLE:
		break;
	default:
		break;
	}
}
 
Example #10
Source File: MovementBattleState.java    From Norii with Apache License 2.0 5 votes vote down vote up
@Override
public void buttonPressed(int button) {
	switch (button) {
	case Buttons.RIGHT:
		ParticleMaker.deactivateAllParticlesOfType(ParticleType.MOVE);
		exit();
		break;
	case Buttons.LEFT:
		break;
	case Buttons.MIDDLE:
		break;
	default:
		break;
	}
}
 
Example #11
Source File: FluidSimulatorLiquid.java    From fluid-simulator-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
	touching = true;
	camera.unproject(testPoint.set(x, y, 0));
	testPoint2D.x = testPoint.x;
	testPoint2D.y = testPoint.y;
	oldDragPos.set(testPoint2D);
	
	if (button == Buttons.LEFT) {

		// Drag Mode
		if (isDragging) {
			for (Piece piece : pieces.values()) {
				hitBody = null;
				if (piece.body.getFixtureList().get(0).testPoint(testPoint2D)) {
					hitBody = piece.body;
					if (hitBody.getType() == BodyType.KinematicBody || hitBody.getType() == BodyType.StaticBody)
						continue;
					MouseJointDef def = new MouseJointDef();
					def.bodyA = groundBody;
					def.bodyB = hitBody;
					def.collideConnected = true;
					def.target.set(testPoint2D);
					def.maxForce = 10.0f * hitBody.getMass();
					mouseJoint = (MouseJoint)world.createJoint(def);
					hitBody.setAwake(true);
					break;
				}
			}
			if (mouseJoint != null)
				return false;
		}
		
		if (!IS_DESKTOP) {
			isRepulsing = true;
			isAttracting = false;
		} else {
			isAttracting = false;
			isRepulsing = false;
		}
	}
	if (button == Buttons.RIGHT) {
		isAttracting = true;
	}
	if (button == Buttons.MIDDLE) {
		isRepulsing = true;
	}
	return false;
}
 
Example #12
Source File: FluidSimulatorLiquid.java    From fluid-simulator-v2 with Apache License 2.0 4 votes vote down vote up
@Override
	public boolean touchUp(int x, int y, int pointer, int button) {
		touching = false;
		
		if (!IS_DESKTOP) {
			isRepulsing = false;
			isAttracting = false;
		}
		if (button == Buttons.RIGHT) {
			isAttracting = false;
		}
		if (button == Buttons.MIDDLE) {
			isRepulsing = false;
		}
		
		// if a mouse joint exists we simply destroy it
		if (mouseJoint != null) {
			if (dragVelocity.len() > 1)
				mouseJoint.getBodyB().setLinearVelocity(dragVelocity.scl(50000));
			world.destroyJoint(mouseJoint);
			mouseJoint = null;
		}
		hitBody = null;
		dragVelocity.set(0, 0);
		
		if (pointer == 1 || pointer == 3) {
			if (pointer == 3)
				enableBox2DCollisions = !enableBox2DCollisions;
			if (pointer == 1)
				bgMode = !bgMode;
//			if (shapes)
//				dropRadiusK = 1.3f;
//			else
//				dropRadiusK = 2.5f;
//			dropRadius = 0.1f + dropRadiusK;
//			dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE);
//			dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel;
//			dropSprite.setSize(dropRadiusPixel, dropRadiusPixel);
		}
		else if (pointer == 2) {
			emitType ++;
			if (emitType > 3)
				emitType = 1;
			for (Particle p : particles)
				p.type = emitType;
		}
		
		return false;
	}
 
Example #13
Source File: FluidSimulator.java    From fluid-simulator-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
	touching = true;
	camera.unproject(testPoint.set(x, y, 0));
	testPoint2D.x = testPoint.x;
	testPoint2D.y = testPoint.y;
	oldDragPos.set(testPoint2D);
	
	if (button == Buttons.LEFT) {

		// Drag Mode
		if (isDragging) {
			for (Piece piece : pieces.values()) {
				hitBody = null;
				if (piece.body.getFixtureList().get(0).testPoint(testPoint2D)) {
					hitBody = piece.body;
					if (hitBody.getType() == BodyType.KinematicBody || hitBody.getType() == BodyType.StaticBody)
						continue;
					MouseJointDef def = new MouseJointDef();
					def.bodyA = groundBody;
					def.bodyB = hitBody;
					def.collideConnected = true;
					def.target.set(testPoint2D);
					def.maxForce = 10.0f * hitBody.getMass();
					mouseJoint = (MouseJoint)world.createJoint(def);
					hitBody.setAwake(true);
					break;
				}
			}
			if (mouseJoint != null)
				return false;
		}
		
		if (!IS_DESKTOP) {
			isRepulsing = true;
			isAttracting = false;
		} else {
			isAttracting = false;
			isRepulsing = false;
		}
	}
	if (button == Buttons.RIGHT) {
		isAttracting = true;
	}
	if (button == Buttons.MIDDLE) {
		isRepulsing = true;
	}
	return false;
}
 
Example #14
Source File: FluidSimulator.java    From fluid-simulator-v2 with Apache License 2.0 4 votes vote down vote up
@Override
	public boolean touchUp(int x, int y, int pointer, int button) {
		touching = false;
		
		if (!IS_DESKTOP) {
			isRepulsing = false;
			isAttracting = false;
		}
		if (button == Buttons.RIGHT) {
			isAttracting = false;
		}
		if (button == Buttons.MIDDLE) {
			isRepulsing = false;
		}
		
		// if a mouse joint exists we simply destroy it
		if (mouseJoint != null) {
			if (dragVelocity.len() > 1)
				mouseJoint.getBodyB().setLinearVelocity(dragVelocity.scl(50000));
			world.destroyJoint(mouseJoint);
			mouseJoint = null;
		}
		hitBody = null;
		dragVelocity.set(0, 0);
		
		if (pointer == 1 || pointer == 3) {
			if (pointer == 3)
				enableBox2DCollisions = !enableBox2DCollisions;
			if (pointer == 1)
				bgMode = !bgMode;
//			if (shapes)
//				dropRadiusK = 1.3f;
//			else
//				dropRadiusK = 2.5f;
//			dropRadius = 0.1f + dropRadiusK;
//			dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE);
//			dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel;
//			dropSprite.setSize(dropRadiusPixel, dropRadiusPixel);
		}
		else if (pointer == 2) {
			emitType ++;
			if (emitType > 3)
				emitType = 1;
			for (Particle p : particles)
				p.type = emitType;
		}
		
		return false;
	}
 
Example #15
Source File: FluidSimulatorMPM.java    From fluid-simulator-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
	touching = true;
	camera.unproject(testPoint.set(x, y, 0));
	testPoint2D.x = testPoint.x;
	testPoint2D.y = testPoint.y;
	oldDragPos.set(testPoint2D);
	
	if (button == Buttons.LEFT) {
		
		// MPM
		mpmSolver.pressed = true;
		mpmSolver.mx = (int)testPoint2D.x;
		mpmSolver.my = BOX_HEIGHT - (int)testPoint2D.y;

		// Drag Mode
		if (isDragging) {
			for (Piece piece : pieces.values()) {
				hitBody = null;
				if (piece.body.getFixtureList().get(0).testPoint(testPoint2D)) {
					hitBody = piece.body;
					if (hitBody.getType() == BodyType.KinematicBody || hitBody.getType() == BodyType.StaticBody)
						continue;
					MouseJointDef def = new MouseJointDef();
					def.bodyA = groundBody;
					def.bodyB = hitBody;
					def.collideConnected = true;
					def.target.set(testPoint2D);
					def.maxForce = 10.0f * hitBody.getMass();
					mouseJoint = (MouseJoint)world.createJoint(def);
					hitBody.setAwake(true);
					break;
				}
			}
			if (mouseJoint != null)
				return false;
		}
		
		if (!IS_DESKTOP) {
			isRepulsing = true;
			isAttracting = false;
		} else {
			isAttracting = false;
			isRepulsing = false;
		}
	}
	if (button == Buttons.RIGHT) {
		isAttracting = true;
	}
	if (button == Buttons.MIDDLE) {
		isRepulsing = true;
	}
	return false;
}
 
Example #16
Source File: InventoryTransferManager.java    From Cubes with MIT License 4 votes vote down vote up
@Override
public boolean modifier() {
  return Gdx.input.isButtonPressed(Buttons.RIGHT);
}
 
Example #17
Source File: PopupMenu.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Returns input listener that can be added to scene2d actor. When right mouse button is pressed on that actor,
 * menu will be displayed
 */
public InputListener getDefaultInputListener () {
	return getDefaultInputListener(Buttons.RIGHT);
}