当前位置: 首页>>代码示例>>Java>>正文


Java Controller.getButton方法代码示例

本文整理汇总了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;
}
 
开发者ID:rolandoislas,项目名称:drc-sim-client,代码行数:13,代码来源:ControlController.java

示例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;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-controllerutils,代码行数:11,代码来源:ControllerMappings.java

示例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));
}
 
开发者ID:rolandoislas,项目名称:drc-sim-client,代码行数:57,代码来源:StageConfigInput.java


注:本文中的com.badlogic.gdx.controllers.Controller.getButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。