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


Java Controller.getButtonCount方法代码示例

本文整理汇总了Java中org.lwjgl.input.Controller.getButtonCount方法的典型用法代码示例。如果您正苦于以下问题:Java Controller.getButtonCount方法的具体用法?Java Controller.getButtonCount怎么用?Java Controller.getButtonCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.input.Controller的用法示例。


在下文中一共展示了Controller.getButtonCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
    }
}
 
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:28,代码来源:MotherBrain.java

示例2: serializeControllerData

import org.lwjgl.input.Controller; //导入方法依赖的package包/类
public static ByteBuf serializeControllerData(ByteBuf buf, Controller controller) {
	buf.writeInt(controller.getIndex()); //Controller ID
	writeString(buf, controller.getName()); //Controller Name
	
	buf.writeInt(controller.getButtonCount()); //Buttons
	for(int i = 0; i < controller.getButtonCount(); i++) {
		writeString(buf, controller.getButtonName(i));
		buf.writeBoolean(controller.isButtonPressed(i));
	}
	
	buf.writeInt(controller.getAxisCount()); //Axes
	for(int i = 0; i < controller.getAxisCount(); i++) {
		writeString(buf, controller.getAxisName(i));
		buf.writeFloat(controller.getAxisValue(i));
		buf.writeFloat(controller.getDeadZone(i));
	}
	
	buf.writeInt(controller.getRumblerCount()); //Rumblers
	for(int i = 0; i < controller.getRumblerCount(); i++) {
		writeString(buf, controller.getRumblerName(i));
	}
	
	buf.writeFloat(controller.getPovX());
	buf.writeFloat(controller.getPovY());
	
	int[] specialIds = getSpecialIds(controller);
	buf.writeInt(specialIds.length);
	for(int id : specialIds) {
		buf.writeInt(id);
	}
	return buf;
}
 
开发者ID:thilokru,项目名称:Controller-Support,代码行数:33,代码来源:SerializationHelper.java

示例3: getPossibleControls

import org.lwjgl.input.Controller; //导入方法依赖的package包/类
@Override
public Control[] getPossibleControls() {
    List<Control> possibleControls = new ArrayList<Control>();
    try {
        if (!Controllers.isCreated()) {
            Controllers.create();
        }
        for (int c = 0; c < Controllers.getControllerCount(); ++c) {
            Controller pad = Controllers.getController(c);
            for (int a = 0; a < pad.getAxisCount(); ++a) {
                possibleControls.add(new GamepadAxisControl(pad, a, true));
                possibleControls.add(new GamepadAxisControl(pad, a, false));
            }
            for (int b = 0; b < pad.getButtonCount(); ++b) {
                possibleControls.add(new GamepadButtonControl(pad, b));
            }
        }
    } catch (LWJGLException ex) {
        Logger.getLogger(LwjglNuitControls.class.getName()).log(Level.SEVERE, null, ex);
    }
    for (Field field : Keyboard.class.getFields()) {
        String name = field.getName();
        if (name.startsWith("KEY_")) {
            try {
                int key = field.getInt(null);
                possibleControls.add(new KeyControl(key));
            } catch (Exception e) {
                Logger.getLogger(ControlsConfigurator.class.getName()).log(Level.SEVERE, "error retrieving key", e);
            }
        }
    }
    for (int m = 0; m < Mouse.getButtonCount(); ++m) {
        possibleControls.add(new MouseButtonControl(m));
    }
    return possibleControls.toArray(new Control[possibleControls.size()]);
}
 
开发者ID:devnewton,项目名称:jnuit,代码行数:37,代码来源:LwjglNuitControls.java

示例4: getDefaultMenuOkControls

import org.lwjgl.input.Controller; //导入方法依赖的package包/类
@Override
public Control[] getDefaultMenuOkControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_RETURN);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getButtonCount() >= 1) {
            controls[1] = new GamepadButtonControl(pad, 0);
        }
    }
    return controls;
}
 
开发者ID:devnewton,项目名称:jnuit,代码行数:14,代码来源:LwjglNuitControls.java

示例5: getDefaultMenuCancelControls

import org.lwjgl.input.Controller; //导入方法依赖的package包/类
@Override
public Control[] getDefaultMenuCancelControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_ESCAPE);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getButtonCount() >= 2) {
            controls[1] = new GamepadButtonControl(pad, 1);
        }
    }
    return controls;
}
 
开发者ID:devnewton,项目名称:jnuit,代码行数:14,代码来源:LwjglNuitControls.java


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