本文整理汇总了Java中org.lwjgl.input.Controller类的典型用法代码示例。如果您正苦于以下问题:Java Controller类的具体用法?Java Controller怎么用?Java Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Controller类属于org.lwjgl.input包,在下文中一共展示了Controller类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isControllerLeft
import org.lwjgl.input.Controller; //导入依赖的package包/类
/**
* Check if the controller has the left direction pressed
*
* @param controller The index of the controller to check
* @return True if the controller is pressed to the left
*/
public boolean isControllerLeft(int controller) {
if (controller >= getControllerCount()) {
return false;
}
if (controller == ANY_CONTROLLER) {
for (int i=0;i<controllers.size();i++) {
if (isControllerLeft(i)) {
return true;
}
}
return false;
}
return ((Controller) controllers.get(controller)).getXAxisValue() < -0.5f
|| ((Controller) controllers.get(controller)).getPovX() < -0.5f;
}
示例2: isControllerRight
import org.lwjgl.input.Controller; //导入依赖的package包/类
/**
* Check if the controller has the right direction pressed
*
* @param controller The index of the controller to check
* @return True if the controller is pressed to the right
*/
public boolean isControllerRight(int controller) {
if (controller >= getControllerCount()) {
return false;
}
if (controller == ANY_CONTROLLER) {
for (int i=0;i<controllers.size();i++) {
if (isControllerRight(i)) {
return true;
}
}
return false;
}
return ((Controller) controllers.get(controller)).getXAxisValue() > 0.5f
|| ((Controller) controllers.get(controller)).getPovX() > 0.5f;
}
示例3: isControllerUp
import org.lwjgl.input.Controller; //导入依赖的package包/类
/**
* Check if the controller has the up direction pressed
*
* @param controller The index of the controller to check
* @return True if the controller is pressed to the up
*/
public boolean isControllerUp(int controller) {
if (controller >= getControllerCount()) {
return false;
}
if (controller == ANY_CONTROLLER) {
for (int i=0;i<controllers.size();i++) {
if (isControllerUp(i)) {
return true;
}
}
return false;
}
return ((Controller) controllers.get(controller)).getYAxisValue() < -0.5f
|| ((Controller) controllers.get(controller)).getPovY() < -0.5f;
}
示例4: isControllerDown
import org.lwjgl.input.Controller; //导入依赖的package包/类
/**
* Check if the controller has the down direction pressed
*
* @param controller The index of the controller to check
* @return True if the controller is pressed to the down
*/
public boolean isControllerDown(int controller) {
if (controller >= getControllerCount()) {
return false;
}
if (controller == ANY_CONTROLLER) {
for (int i=0;i<controllers.size();i++) {
if (isControllerDown(i)) {
return true;
}
}
return false;
}
return ((Controller) controllers.get(controller)).getYAxisValue() > 0.5f
|| ((Controller) controllers.get(controller)).getPovY() > 0.5f;
}
示例5: isButtonPressed
import org.lwjgl.input.Controller; //导入依赖的package包/类
/**
* Check if controller button is pressed
*
* @param controller The index of the controller to check
* @param index The index of the button to check
* @return True if the button is pressed
*/
public boolean isButtonPressed(int index, int controller) {
if (controller >= getControllerCount()) {
return false;
}
if (controller == ANY_CONTROLLER) {
for (int i=0;i<controllers.size();i++) {
if (isButtonPressed(index, i)) {
return true;
}
}
return false;
}
return ((Controller) controllers.get(controller)).isButtonPressed(index);
}
示例6: getSpecialIds
import org.lwjgl.input.Controller; //导入依赖的package包/类
private static int[] getSpecialIds(Controller controller) {
try {
Class<?> targetClazz = Class.forName("org.lwjgl.input.JInputController");
if(targetClazz.isInstance(controller)) {
int[] ret = new int[6];
ret[0] = getFieldValue(controller, "xaxis");
ret[1] = getFieldValue(controller, "yaxis");
ret[2] = getFieldValue(controller, "zaxis");
ret[3] = getFieldValue(controller, "rxaxis");
ret[4] = getFieldValue(controller, "ryaxis");
ret[5] = getFieldValue(controller, "rzaxis");
return ret;
}
} catch (Exception e) {
Throwables.propagate(e);
}
return null;
}
示例7: updatePlayerMoveState
import org.lwjgl.input.Controller; //导入依赖的package包/类
@Override
public void updatePlayerMoveState(){
super.updatePlayerMoveState();
Controller controller = Config.INSTANCE.getController();
StickConfig cfg = Config.INSTANCE.getMapping().getStick(Usage.MOVEMENT);
if(cfg == null)return;
Pair<Float, Float> movement = cfg.getData(controller);
if(this.sneak) {
this.moveForward /= 0.3;
this.moveStrafe /= 0.3;
}
this.moveForward = clamp(this.moveForward + movement.getRight(), -1.0F, 1.0F);
this.moveStrafe = clamp(this.moveStrafe + movement.getLeft(), -1.0F, 1.0F);
if(this.sneak) {
this.moveForward *= 0.3;
this.moveStrafe *= 0.3;
}
}
示例8: loadSelectedController
import org.lwjgl.input.Controller; //导入依赖的package包/类
public static void loadSelectedController(Controller controller) {
if(controller == null) {
LOG.info("The user chose to use mouse and keyboard.");
} else {
controller.poll();
LOG.info(String.format("The user chose to use the following controller: '%s'", controller.getName()));
}
Config.INSTANCE.setController(controller);
if(Config.INSTANCE.hasController()) {
ControllerSupportMod.INSTANCE.handler.activate();
ControllerMapping mapping = ControllerMapping.loadFromConfig();
Config.INSTANCE.setMapping(mapping);
Config.INSTANCE.save();
} else {
ControllerSupportMod.INSTANCE.handler.deactivate();
}
}
示例9: logAllControllers
import org.lwjgl.input.Controller; //导入依赖的package包/类
/**
*
*/
private void logAllControllers() {
for (int i = 0; i < Controllers.getControllerCount(); i++) {
final Controller controller = Controllers.getController(i);
Log.debug(controller.getName());
final int controllerAxisCount = controller.getAxisCount();
Log.debug("org.lwjgl.input.Controller#getAxisName");
for (int j = 0; j < controllerAxisCount; j++) {
Log.debug(controller.getAxisName(j));
}
final int controllerButtonCount = controller.getButtonCount();
Log.debug("org.lwjgl.input.Controller#getButtonCount");
Log.debug(String.valueOf(controllerButtonCount));
Log.debug("org.lwjgl.input.Controller#getButtonName");
for (int j = 0; j < controllerButtonCount; j++) {
Log.debug(controller.getButtonName(j));
}
final int controllerRumblerCount = controller.getRumblerCount();
Log.debug("org.lwjgl.input.Controller#getRumblerName");
for (int j = 0; j < controllerRumblerCount; j++) {
Log.debug(controller.getRumblerName(j));
}
controllers.add(controller);
}
}