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


Java Controller.getComponents方法代码示例

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


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

示例1: loadIdentifiers

import net.java.games.input.Controller; //导入方法依赖的package包/类
private void loadIdentifiers(int controllerIdx, Controller c){
    Component[] ces = c.getComponents();
    int numButtons = 0;
    int numAxes = 0;
    xAxis = -1;
    yAxis = -1;
    for (Component comp : ces){
        Identifier id = comp.getIdentifier();
        if (id instanceof Button){
            buttonIdsToIndices[controllerIdx].put((Button)id, numButtons);
            numButtons ++;
        }else if (id instanceof Axis){
            Axis axis = (Axis) id;
            if (axis == Axis.X){
                xAxis = numAxes;
            }else if (axis == Axis.Y){
                yAxis = numAxes;
            }

            axisIdsToIndices[controllerIdx].put((Axis)id, numAxes);
            numAxes ++;
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:JInputJoyInput.java

示例2: GamepadInputDevice

import net.java.games.input.Controller; //导入方法依赖的package包/类
GamepadInputDevice(Controller controller){
if(controller==null)
    throw new NullPointerException("Passed Controller intolerably null.");
this.controller = controller;
controller.setEventQueueSize(256);
eventQueue = controller.getEventQueue();
System.out.println("CONTROLLER: "+controller.getClass().getName());
controllerSources = new ArrayList<GamepadControllerSource>(controller.getComponents().length);
//System.out.println("Rumblers: "+controller.getRumblers().length);
//controller.getRumblers()[0].rumble(1f);
for(net.java.games.input.Component comp : controller.getComponents()){
    GamepadControllerSource gcs = new GamepadControllerSource(comp);
    controllerSources.add(gcs);
    controllerSourceMap.put(comp, gcs);
    nameMap.put(comp.getName(),gcs);
    System.out.println("Component found: "+comp.getName());
}//end for(components)
gamepadEventThread.start();
   }
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:20,代码来源:GamepadInputDeviceServiceFactory.java

示例3: getComponent

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * Gets the component attribute of the YassInput object
 *
 * @param d Description of the Parameter
 * @param s Description of the Parameter
 * @return The component value
 */
public Component getComponent(Controller d, String s) {
    Component[] comps = d.getComponents();
    for (Component comp : comps) {
        if (comp.getName().equals(s)) {
            return comp;
        }
    }
    return null;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:17,代码来源:YassInput.java

示例4: loadController

import net.java.games.input.Controller; //导入方法依赖的package包/类
private HIDData loadController(Controller controller){
	ArrayList<HIDAxis> axes = new ArrayList<HIDAxis>();
	ArrayList<HIDButton> buttons = new ArrayList<HIDButton>();
	ArrayList<HIDPOV> povs = new ArrayList<HIDPOV>();
	
	Component[] componenets = controller.getComponents();
	
	for (int i = 0; i < componenets.length; i++) {
		if(componenets[i].isAnalog()){
			if(componenets[i].getIdentifier().equals(Component.Identifier.Axis.POV)){
				povs.add(new HIDPOV(componenets[i]));
			}else{
				axes.add(new HIDAxis(componenets[i]));
			}
		}else{
			buttons.add(new HIDButton(componenets[i]));
		}
	}
	
	HIDData data = new HIDData(
			controller.getName(),
			axes.toArray(new HIDAxis[axes.size()]),
			buttons.toArray(new HIDButton[buttons.size()]),
			povs.toArray(new HIDPOV[povs.size()])
			);
	data.controller = controller;
	return data;
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:29,代码来源:HIDControl.java

示例5: getAvailablePadControllers

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * This method detects the available joysticks / gamepads on the computer
 * and return them in a list.
 *
 * @return List of available joysticks / gamepads connected to the computer
 */
private static Controller[] getAvailablePadControllers() {
    List<Controller> gameControllers = new ArrayList<Controller>();
    // Get a list of the controllers JInput knows about and can interact
    // with
    Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
    // Check the useable controllers (gamepads or joysticks with at least 2
    // axis and 2 buttons)
    for (Controller controller : controllers) {
        if ((controller.getType() == Controller.Type.GAMEPAD) || (controller.getType() == Controller.Type.STICK)) {
            int nbOfAxis = 0;
            // Get this controllers components (buttons and axis)
            Component[] components = controller.getComponents();
            // Check the availability of X/Y axis and at least 2 buttons
            // (for A and B, because select and start can use the keyboard)
            for (Component component : components) {
                if ((component.getIdentifier() == Component.Identifier.Axis.X)
                        || (component.getIdentifier() == Component.Identifier.Axis.Y)) {
                    nbOfAxis++;
                }
            }
            if ((nbOfAxis >= 2) && (getButtons(controller).length >= 2)) {
                // Valid game controller
                gameControllers.add(controller);
            }
        }
    }
    return gameControllers.toArray(new Controller[0]);
}
 
开发者ID:kostkol87,项目名称:Nes-emulator,代码行数:35,代码来源:ControllerImpl.java

示例6: getButtons

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * Return the available buttons on this controller (by priority order).
 *
 * @param controller
 * @return
 */
private static Component[] getButtons(Controller controller) {
    List<Component> buttons = new ArrayList<Component>();
    // Get this controllers components (buttons and axis)
    Component[] components = controller.getComponents();
    for (Component component : components) {
        if (component.getIdentifier() instanceof Component.Identifier.Button) {
            buttons.add(component);
        }
    }
    return buttons.toArray(new Component[0]);
}
 
开发者ID:kostkol87,项目名称:Nes-emulator,代码行数:18,代码来源:ControllerImpl.java

示例7: getAvailablePadControllers

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * This method detects the available joysticks / gamepads on the computer
 * and return them in a list.
 *
 * @return List of available joysticks / gamepads connected to the computer
 */
private static Controller[] getAvailablePadControllers() {
    List<Controller> gameControllers = new ArrayList<>();
    // Get a list of the controllers JInput knows about and can interact
    // with
    Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
    // Check the useable controllers (gamepads or joysticks with at least 2
    // axis and 2 buttons)
    for (Controller controller : controllers) {
        if ((controller.getType() == Controller.Type.GAMEPAD) || (controller.getType() == Controller.Type.STICK)) {
            int nbOfAxis = 0;
            // Get this controllers components (buttons and axis)
            Component[] components = controller.getComponents();
            // Check the availability of X/Y axis and at least 2 buttons
            // (for A and B, because select and start can use the keyboard)
            for (Component component : components) {
                if ((component.getIdentifier() == Component.Identifier.Axis.X)
                        || (component.getIdentifier() == Component.Identifier.Axis.Y)) {
                    nbOfAxis++;
                }
            }
            if ((nbOfAxis >= 2) && (getButtons(controller).length >= 2)) {
                // Valid game controller
                gameControllers.add(controller);
            }
        }
    }
    return gameControllers.toArray(new Controller[0]);
}
 
开发者ID:andrew-hoffman,项目名称:halfnes,代码行数:35,代码来源:ControllerImpl.java

示例8: getButtons

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * Return the available buttons on this controller (by priority order).
 */
private static Component[] getButtons(Controller controller) {
    List<Component> buttons = new ArrayList<>();
    // Get this controllers components (buttons and axis)
    Component[] components = controller.getComponents();
    for (Component component : components) {
        if (component.getIdentifier() instanceof Component.Identifier.Button) {
            buttons.add(component);
        }
    }
    return buttons.toArray(new Component[0]);
}
 
开发者ID:andrew-hoffman,项目名称:halfnes,代码行数:15,代码来源:ControllerImpl.java


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