本文整理汇总了Java中com.badlogic.gdx.controllers.Controller.getButton方法的典型用法代码示例。如果您正苦于以下问题:Java Controller.getButton方法的具体用法?Java Controller.getButton怎么用?Java Controller.getButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.controllers.Controller
的用法示例。
在下文中一共展示了Controller.getButton方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPressed
import com.badlogic.gdx.controllers.Controller; //导入方法依赖的package包/类
private boolean isPressed(Controller controller, ConfigKeymap.Input input) {
switch (input.getType()) {
case ConfigKeymap.Input.TYPE_AXIS:
return input.getExtra() == 0 ? controller.getAxis(input.getInput()) < -.2 :
controller.getAxis(input.getInput()) > .2;
case ConfigKeymap.Input.TYPE_POV:
return controller.getPov(input.getInput()).ordinal() == input.getExtra();
case ConfigKeymap.Input.TYPE_BUTTON:
return controller.getButton(input.getInput());
}
return false;
}
示例2: findPressedButton
import com.badlogic.gdx.controllers.Controller; //导入方法依赖的package包/类
public static int findPressedButton(Controller controller) {
// Cycle through button indexes to check if a button is pressed
// Some gamepads report buttons from 90 to 107, so we check up to index 500
// this should be moved into controller implementation which knows it better
for (int i = 0; i <= 500; i++)
if (controller.getButton(i))
return i;
return -1;
}
示例3: pollInputController
import com.badlogic.gdx.controllers.Controller; //导入方法依赖的package包/类
private void pollInputController() {
int input = -1;
int input_extra = -1;
int input_type = -1;
main:
for (Controller controller : Controllers.getControllers()) {
if (!controller.getName().equals(this.controllerName))
continue;
// Check axes
for (int axis = 0; axis < 1000; axis++) {
float ax = controller.getAxis(axis);
if (ax > .5) {
input_type = ConfigKeymap.Input.TYPE_AXIS;
input = axis;
input_extra = 1; // positive
break main;
}
else if (ax < -.5) {
input_type = ConfigKeymap.Input.TYPE_AXIS;
input = axis;
input_extra = 0; // negative
break main;
}
}
// Only allow an axis to be set for joystick input.
// TODO Map all 4(8) axes to allow any input to control the joystick(s). 4 directions per joystick
if (key.contains("JOYSTICK"))
break;
// Check dpad/pov
for (int pov = 0; pov < 1000; pov++) {
PovDirection povDirection = controller.getPov(pov);
if (!povDirection.equals(PovDirection.center)) {
input_type = ConfigKeymap.Input.TYPE_POV;
input = pov;
input_extra = povDirection.ordinal();
break main;
}
}
// Check buttons
for (int button = 0; button < 1000; button++) {
if (controller.getButton(button)) {
input_type = ConfigKeymap.Input.TYPE_BUTTON;
input = button;
break main;
}
}
return;
}
if (input < 0)
return;
// Save input
config.putInput(this.key, input_type, input, input_extra);
config.load();
config.flush();
Client.setStage(new StageConfigInput(type, config, key, displayName, controllerName));
}