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


Java ControllerEnvironment.getControllers方法代码示例

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


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

示例1: getButtonController

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param index Description of the Parameter
 * @return Description of the Return Value
 */
public static int getButtonController(int index) {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();

    int controllerCount = 0;
    for (int d = 0; d < cs.length; d++) {
        Controller.Type type = cs[d].getType();
        if ((type == Controller.Type.GAMEPAD) || (type == Controller.Type.STICK) || cs[d].getName().toLowerCase().contains("wiimote") || cs[d].getName().toLowerCase().contains("shuttle")) {
            if (controllerCount == index) {
                return d;
            }
            controllerCount++;
        }
    }
    return -1;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:23,代码来源:YassInput.java

示例2: getButton

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Gets the button attribute of the YassInput class
 *
 * @param d Description of the Parameter
 * @param i Description of the Parameter
 * @return The button value
 */
public static int getButton(int d, int i) {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();

    int buttonCount = 0;
    Component[] comps = cs[d].getComponents();
    for (int c = 0; c < comps.length; c++) {
        if (!(comps[c].getIdentifier() instanceof Component.Identifier.Axis)) {
            if (buttonCount == i) {
                return c;
            }
            buttonCount++;
        }
    }
    return -1;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:24,代码来源:YassInput.java

示例3: pollAllButtons

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Description of the Method
 */
public void pollAllButtons() {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();
    for (Controller cc : cs) {
        Controller.Type type = cc.getType();
        //if (type == Controller.Type.MOUSE || type == Controller.Type.KEYBOARD) {
            // continue;
        //} else
        if (type == Controller.Type.GAMEPAD || type == Controller.Type.STICK) {
            cc.poll();
        } else if (type == Controller.Type.UNKNOWN) {
            cc.poll();
        } else if (cc.getName().toLowerCase().contains("wiimote")) {
            cc.poll();
        }
    }
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:21,代码来源:YassInput.java

示例4: init

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Description of the Method
 */
public static void init() {
    try {
        // JInput bug: list is never refreshed
        ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
        ce.getControllers();
    } catch (java.lang.UnsatisfiedLinkError e) {
        System.out.println("No jinput-raw in java.library.path");
    }
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:13,代码来源:YassInput.java

示例5: getControllerIndex

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Gets the controllerIndex attribute of the YassInput object
 *
 * @param s Description of the Parameter
 * @return The controllerIndex value
 */
public int getControllerIndex(String s) {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();
    for (int d = 0; d < cs.length; d++) {
        if (cs[d].getName().equals(s)) {
            return d;
        }
    }
    return -1;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:17,代码来源:YassInput.java

示例6: getController

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

示例7: getComponentIndex

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Gets the componentIndex attribute of the YassInput object
 *
 * @param d Description of the Parameter
 * @param s Description of the Parameter
 * @return The componentIndex value
 */
public int getComponentIndex(int d, String s) {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();
    Component[] comps = cs[d].getComponents();
    for (int c = 0; c < comps.length; c++) {
        if (comps[c].getName().equals(s)) {
            return c;
        }
    }
    return -1;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:19,代码来源:YassInput.java

示例8: getButtonValue

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Gets the value attribute of the YassInput object
 *
 * @param d Description of the Parameter
 * @param c Description of the Parameter
 * @return The value value
 */
public int getButtonValue(int d, int c) {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();
    Component[] comps = cs[d].getComponents();
    float val = comps[c].getPollData();
    if (comps[c].getIdentifier() instanceof Component.Identifier.Axis) {
        return 0;
    }
    if (val < comps[c].getDeadZone()) {
        return 0;
    }
    return (int) val;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:21,代码来源:YassInput.java

示例9: getCompatibleControllers

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
	 * Get controllers from JInput that would be suitable
	 * 
	 * @return
	 */
	private static List<Controller> getCompatibleControllers() {
		ControllerEnvironment controllerEnvironment = ControllerEnvironment.getDefaultEnvironment(); 
//		controllerEnvironment.addControllerListener(new ControllerListener() {
//			public void controllerRemoved(ControllerEvent ev) {
//				System.err.println("ADDED: " + ev);
//			}
//
//		    /**
//		     * Invoked when a controller has been added.
//		     */
//		    public void controllerAdded(ControllerEvent ev) {
//				System.err.println("REMOVED: " + ev);
//		    }
//		});
		Controller[] controllers = controllerEnvironment.getControllers();
		List<Controller> advancedControllers = new ArrayList<>();
		for (Controller controller : controllers) {
			// For now, we only support 'Space Navigator' controllers... being more permissive can cause strange things to happen
			// (in particular, things go very badly wrong with VirtualBox)
			if (controller.getType() == Type.STICK && controller.getName().toLowerCase().equals("spacenavigator")) {
//			if (controller.getType() == Type.STICK || !controller.getName().toLowerCase().contains("virtualbox")) {
				logger.info("Registering controller: " + controller.getName() + ", " + controller.getType() ); 
				advancedControllers.add(controller);
			} else
				logger.trace("Skipping controller: " + controller.getName() + ", " + controller.getType() ); 
		}
		return advancedControllers;
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:34,代码来源:AdvancedControllerActionFactory.java

示例10: testJInput

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
@Test
public void testJInput() {
    ControllerEnvironment controllerEnvironment = ControllerEnvironment.getDefaultEnvironment();
    Controller[] controllers = controllerEnvironment.getControllers();
    System.out.println(String.format("%s controllers found.", controllers.length));
    Arrays.asList(controllers).forEach(controller -> {
        System.out.println(String.format("  %s (%s)", controller, controller.getType()));
    });
}
 
开发者ID:andrew-hoffman,项目名称:halfnes,代码行数:10,代码来源:JInputTest.java

示例11: getControllerCount

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Gets the controllerCount attribute of the YassInput object
 *
 * @return The controllerCount value
 */
public int getControllerCount() {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();
    return cs.length;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:11,代码来源:YassInput.java

示例12: toString

import net.java.games.input.ControllerEnvironment; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param d Description of the Parameter
 * @param c Description of the Parameter
 * @return Description of the Return Value
 */
public String toString(int d, int c) {
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cs = ce.getControllers();
    Component[] comps = cs[d].getComponents();
    return d + ":" + cs[d].getType() + " - " + comps[c].getName();
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:14,代码来源:YassInput.java


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