本文整理汇总了Java中com.badlogic.gdx.controllers.Controller类的典型用法代码示例。如果您正苦于以下问题:Java Controller类的具体用法?Java Controller怎么用?Java Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Controller类属于com.badlogic.gdx.controllers包,在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buttonDown
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean buttonDown(Controller controller, int buttonCode) {
if (currentMenuOption != null && KeyboardInputProcessor.isXbox360Controller(controller.getName())) {
switch(buttonCode) {
case KeyboardInputProcessor.XBOX_360_A:
menuAction();
return true;
case KeyboardInputProcessor.XBOX_360_BACK:
dismissMenu();
return true;
}
}
if (currentMenuOption == returnToTitleOption && KeyboardInputProcessor.isXbox360Controller(controller.getName())) {
if (buttonCode != KeyboardInputProcessor.XBOX_360_A) {
returnToTitleOption.resetVisited();
}
}
return false;
}
示例2: axisMoved
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean axisMoved(Controller controller, int axisCode, float value) {
Gdx.app.log(getClass().getSimpleName(), "axisMoved(" + controller + ", " + axisCode + ", " + value + ")");
if (Math.abs(value) > .5f) {
if (currentMenuOption.buttonIndex == com.gradualgames.ggvm.Controller.Buttons.LEFT ||
currentMenuOption.buttonIndex == com.gradualgames.ggvm.Controller.Buttons.RIGHT) {
inputProcessor.getActualAxisToAxisCode().inverse().forcePut(axisCode, KeyboardInputProcessor.Axis.X);
} else if (currentMenuOption.buttonIndex == com.gradualgames.ggvm.Controller.Buttons.UP ||
currentMenuOption.buttonIndex == com.gradualgames.ggvm.Controller.Buttons.DOWN) {
inputProcessor.getActualAxisToAxisCode().inverse().forcePut(axisCode, KeyboardInputProcessor.Axis.Y);
}
menu = topLevelMenu;
menu.activate();
}
return false;
}
示例3: buttonUp
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean buttonUp(Controller controller, int buttonCode) {
if(controller == pads[0]) {
if(buttonCode == 0){
InputManager.jump[0] = false;
}else if(buttonCode == 2) {
InputManager.attack[0] = false;
}
}else if(controller == pads[1]) {
if(buttonCode == 0){
InputManager.jump[1] = false;
}else if(buttonCode == 2) {
InputManager.attack[1] = false
;
}
}
return true;
}
示例4: axisReleased
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
/**
* Hilfsfunktion, die prüft, ob eine Axe losgelassen wurde.
*
* @see InputManager#axisMoved(Controller, int, float)
*
* @param controller der Controller, von dem das Ereignis aus geht
* @param axisCode der Code der Axe
* @return true, wenn die Axe wirklich losgelassen wurde
*/
private boolean axisReleased(Controller controller, int axisCode)
{
AxisKey lowAxis = new AxisKey(axisCode, false, controller);
if (controllerGameAxisStateInverse.containsKey(lowAxis) && controllerGameAxisStateInverse.get(lowAxis))
{
controllerGameAxisStateInverse.put(lowAxis, false);
return controllerUp(controllerGameAxisBindingInverse.get(lowAxis));
}
AxisKey highAxis = new AxisKey(axisCode, true, controller);
if (controllerGameAxisStateInverse.containsKey(highAxis) && controllerGameAxisStateInverse.get(highAxis))
{
controllerGameAxisStateInverse.put(highAxis, false);
return controllerUp(controllerGameAxisBindingInverse.get(highAxis));
}
return false;
}
示例5: findHighAxisValue
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
public static int findHighAxisValue(Controller controller, float analogToDigitalTreshold,
float maxAcceptedAnalogValue) {
// Cycle through axis indexes to check if there is a high value
float highestValue = 0;
int axisWithHighestValue = -1;
for (int i = 0; i <= 500; i++) {
float abs = Math.abs(controller.getAxis(i));
if (abs > highestValue && abs >= analogToDigitalTreshold && abs <= maxAcceptedAnalogValue) {
highestValue = abs;
axisWithHighestValue = i;
}
}
return axisWithHighestValue;
}
示例6: getControllerMapping
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
protected MappedInputs getControllerMapping(Controller controller) {
if (!initialized)
throw new IllegalStateException("Call commitConfig() before creating Controller Listeners");
MappedInputs retVal = null;
// initialize mapping map and controller information if not already present
if (mappedInputs == null)
mappedInputs = new HashMap<>();
retVal = mappedInputs.get(controller.getName());
// in case the controller is not recorded or loaded already, initialize it
if (retVal == null) {
MappedInputs defaultMapping = new MappedInputs(controller);
if (getDefaultMapping(defaultMapping)) {
retVal = defaultMapping;
mappedInputs.put(retVal.controllerName, retVal);
}
}
return retVal;
}
示例7: buttonDown
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean buttonDown(Controller controller, int buttonCode) {
if(controller == pads[0]) {
if(buttonCode == 0) {
InputManager.jump[0] = true;
}else if(buttonCode == 2) {
InputManager.attack[0] = true;
}
}else if(controller == pads[1]) {
if(buttonCode == 0){
InputManager.jump[1] = true;
}else if(buttonCode == 2) {
InputManager.attack[1] = true;
}
}
return true;
}
示例8: povMoved
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
switch(value) {
case north:
cursorUp();
break;
case south:
cursorDown();
break;
}
return false;
}
示例9: KeyboardInputProcessor
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
public KeyboardInputProcessor() {
super();
buttonToButtonUpIndex.put(com.gradualgames.ggvm.Controller.Buttons.LEFT.ordinal(), com.gradualgames.ggvm.Controller.Buttons.RIGHT.ordinal());
buttonToButtonUpIndex.put(com.gradualgames.ggvm.Controller.Buttons.RIGHT.ordinal(), com.gradualgames.ggvm.Controller.Buttons.LEFT.ordinal());
buttonToButtonUpIndex.put(com.gradualgames.ggvm.Controller.Buttons.UP.ordinal(), com.gradualgames.ggvm.Controller.Buttons.DOWN.ordinal());
buttonToButtonUpIndex.put(com.gradualgames.ggvm.Controller.Buttons.DOWN.ordinal(), com.gradualgames.ggvm.Controller.Buttons.UP.ordinal());
logControllers();
}
示例10: logControllers
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
private void logControllers() {
Array<Controller> controllers = Controllers.getControllers();
Gdx.app.log(getClass().getSimpleName(), "****** Controller Names *********");
for(Controller controller: controllers) {
Gdx.app.log(getClass().getSimpleName(), controller.getName());
}
Gdx.app.log(getClass().getSimpleName(), "********************************");
}
示例11: autoConfigure
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
public void autoConfigure() {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
Controller controller = controllers.get(0);
if (isXbox360Controller(controller.getName())) {
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, XBOX_360_A);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, XBOX_360_X);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, XBOX_360_LEFT_SHOULDER);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, XBOX_360_START);
} else if (controller.getName().equals(RETRO_USB_NAME)) {
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, RETRO_USB_A);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, RETRO_USB_B);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, RETRO_USB_SELECT);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, RETRO_USB_START);
actualAxisToAxisCode.put(Axis.X, 1);
actualAxisToAxisCode.put(Axis.Y, 0);
}
}
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.A, Input.Keys.F);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.B, Input.Keys.D);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, Input.Keys.A);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.START, Input.Keys.S);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.UP, Input.Keys.UP);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.RIGHT, Input.Keys.RIGHT);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.DOWN, Input.Keys.DOWN);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.LEFT, Input.Keys.LEFT);
}
示例12: getNameForButton
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
public String getNameForButton(int button) {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
Controller controller = controllers.get(0);
if (KeyboardInputProcessor.isXbox360Controller(controller.getName())) {
switch(button) {
case XBOX_360_A:
return "A";
case XBOX_360_B:
return "B";
case XBOX_360_X:
return "X";
case XBOX_360_Y:
return "Y";
case XBOX_360_LEFT_SHOULDER:
return "LSHLDR";
case XBOX_360_RIGHT_SHOULDER:
return "RSHLDR";
case XBOX_360_BACK:
return "BACK";
case XBOX_360_START:
return "START";
}
} else if (controller.getName().equals(RETRO_USB_NAME)) {
switch(button) {
case RETRO_USB_A:
return "A";
case RETRO_USB_B:
return "B";
case RETRO_USB_SELECT:
return "SELECT";
case RETRO_USB_START:
return "START";
}
}
}
return Integer.toString(button);
}
示例13: axisMoved
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean axisMoved(Controller controller, int axisCode, float value) {
//Controller 1
if(controller == pads[0]) {
if(axisCode == 1) {
if(Math.abs(value) < 0.3) InputManager.horizontal[0] = 0;
else InputManager.horizontal[0] = value;
}
// Trigger
if(axisCode ==4){
if(Math.abs(value) < 0.1) InputManager.trigger[0] = 0;
else InputManager.trigger[0] = value;
}
}
//Controller 2
else if(controller == pads[1]) {
if(axisCode == 1) {
if(Math.abs(value) < 0.3) InputManager.horizontal[1] = 0;
else InputManager.horizontal[1] = value;
}
// Trigger
if(axisCode ==4){
if(Math.abs(value) < 0.1) InputManager.trigger[1] = 0;
else InputManager.trigger[1] = value;
}
}
return true;
}
示例14: buttonDown
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean buttonDown(Controller controller, int buttonCode) {
if (buttonIndexToButton.containsValue(buttonCode)) {
ggvm.setButtonState(buttonIndexToButton.inverse().get(buttonCode).ordinal(), true);
}
if (KeyboardInputProcessor.isXbox360Controller(controller.getName()) && buttonCode == XBOX_360_BACK) {
stopGGVmAndActivateMenu();
}
return false;
}
示例15: buttonUp
import com.badlogic.gdx.controllers.Controller; //导入依赖的package包/类
@Override
public boolean buttonUp(Controller controller, int buttonCode) {
if (buttonIndexToButton.containsValue(buttonCode)) {
ggvm.setButtonState(buttonIndexToButton.inverse().get(buttonCode).ordinal(), false);
}
return false;
}