Java Code Examples for org.newdawn.slick.Input#getAxisValue()

The following examples show how to use org.newdawn.slick.Input#getAxisValue() . 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: ControllerManager.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Joystick If you hold ontrue
 * @param player Player number
 * @param input InputClass (container.getInput()Can be obtained by)
 * @return Press down on thetrue
 */
public static boolean isControllerUp(int player, Input input) {
	try {
		int controller = controllerID[player];

		if(controller < 0) return false;

		if(method == CONTROLLER_METHOD_SLICK_DEFAULT) {
			return input.isControllerUp(controller);
		} else if(method == CONTROLLER_METHOD_SLICK_ALTERNATE) {
			return input.isControllerUp(controller) || (!ignoreAxis[player] && (input.getAxisValue(controller, 1) < -border[player]));
		} else if(method == CONTROLLER_METHOD_LWJGL) {
			if((controller >= 0) && (controller < controllers.size())) {
				float axisValue = controllers.get(controller).getYAxisValue();
				float povValue = controllers.get(controller).getPovY();
				return (!ignoreAxis[player] && (axisValue < -border[player])) || (!ignorePOV[player] && (povValue < -border[player]));
			}
		}
	} catch (Throwable e) {
		log.debug("Exception on isControllerUp", e);
	}
	return false;
}
 
Example 2
Source File: ControllerManager.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Joystick When I press the bottom of thetrue
 * @param player Player number
 * @param input InputClass (container.getInput()Can be obtained by)
 * @return If you hold undertrue
 */
public static boolean isControllerDown(int player, Input input) {
	try {
		int controller = controllerID[player];

		if(controller < 0) return false;

		if(method == CONTROLLER_METHOD_SLICK_DEFAULT) {
			return input.isControllerDown(controller);
		} else if(method == CONTROLLER_METHOD_SLICK_ALTERNATE) {
			return input.isControllerDown(controller) || (!ignoreAxis[player] && (input.getAxisValue(controller, 1) > border[player]));
		} else if(method == CONTROLLER_METHOD_LWJGL) {
			if((controller >= 0) && (controller < controllers.size())) {
				float axisValue = controllers.get(controller).getYAxisValue();
				float povValue = controllers.get(controller).getPovY();
				return (!ignoreAxis[player] && (axisValue > border[player])) || (!ignorePOV[player] && (povValue > border[player]));
			}
		}
	} catch (Throwable e) {
		log.debug("Exception on isControllerDown", e);
	}
	return false;
}
 
Example 3
Source File: ControllerManager.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Joystick When I press the lefttrue
 * @param player Player number
 * @param input InputClass (container.getInput()Can be obtained by)
 * @return If you hold the lefttrue
 */
public static boolean isControllerLeft(int player, Input input) {
	try {
		int controller = controllerID[player];

		if(controller < 0) return false;

		if(method == CONTROLLER_METHOD_SLICK_DEFAULT) {
			return input.isControllerLeft(controller);
		} else if(method == CONTROLLER_METHOD_SLICK_ALTERNATE) {
			return input.isControllerLeft(controller) || (!ignoreAxis[player] && (input.getAxisValue(controller, 0) < -border[player]));
		} else if(method == CONTROLLER_METHOD_LWJGL) {
			if((controller >= 0) && (controller < controllers.size())) {
				float axisValue = controllers.get(controller).getXAxisValue();
				float povValue = controllers.get(controller).getPovX();
				return (!ignoreAxis[player] && (axisValue < -border[player])) || (!ignorePOV[player] && (povValue < -border[player]));
			}
		}
	} catch (Throwable e) {
		log.debug("Exception on isControllerLeft", e);
	}
	return false;
}
 
Example 4
Source File: ControllerManager.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Joystick When I press the righttrue
 * @param player Player number
 * @param input InputClass (container.getInput()Can be obtained by)
 * @return If you hold the righttrue
 */
public static boolean isControllerRight(int player, Input input) {
	try {
		int controller = controllerID[player];

		if(controller < 0) return false;

		if(method == CONTROLLER_METHOD_SLICK_DEFAULT) {
			return input.isControllerRight(controller);
		} else if(method == CONTROLLER_METHOD_SLICK_ALTERNATE) {
			return input.isControllerRight(controller) || (!ignoreAxis[player] && (input.getAxisValue(controller, 0) > border[player]));
		} else if(method == CONTROLLER_METHOD_LWJGL) {
			if((controller >= 0) && (controller < controllers.size())) {
				float axisValue = controllers.get(controller).getXAxisValue();
				float povValue = controllers.get(controller).getPovX();
				return (!ignoreAxis[player] && (axisValue > border[player])) || (!ignorePOV[player] && (povValue > border[player]));
			}
		}
	} catch (Throwable e) {
		log.debug("Exception on isControllerRight", e);
	}
	return false;
}