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


Java GLFW.glfwJoystickPresent方法代码示例

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


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

示例1: setup

import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
/**
 * setup all connected joysticks
 */
public static void setup(){
	int[] joys = new int[]{
			GLFW.GLFW_JOYSTICK_1,
			GLFW.GLFW_JOYSTICK_2,
			GLFW.GLFW_JOYSTICK_3,
			GLFW.GLFW_JOYSTICK_4,
			GLFW.GLFW_JOYSTICK_5,
			GLFW.GLFW_JOYSTICK_6,
			GLFW.GLFW_JOYSTICK_7,
			GLFW.GLFW_JOYSTICK_8,
			GLFW.GLFW_JOYSTICK_9,
			GLFW.GLFW_JOYSTICK_10,
			GLFW.GLFW_JOYSTICK_11,
			GLFW.GLFW_JOYSTICK_12,
			GLFW.GLFW_JOYSTICK_13,
			GLFW.GLFW_JOYSTICK_14,
			GLFW.GLFW_JOYSTICK_15,
			GLFW.GLFW_JOYSTICK_16,
	};
	for(int joy : joys){
		if(GLFW.glfwJoystickPresent(joy)){
			setupJoystick(joy);
		}
	}
}
 
开发者ID:tek256,项目名称:LD38,代码行数:29,代码来源:Joystick.java

示例2: setupJoystick

import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
/** Setup a specific joystick that is connected
 * 
 * @param joy the joystick id to setup
 */
public static void setupJoystick(int joy){
	//make sure the joystick is connected
	if(!GLFW.glfwJoystickPresent(joy))
		return;
	
	//get the name of the joystick and normalize the casing
	String name = GLFW.glfwGetJoystickName(joy).toLowerCase();
	JoystickType type = JoystickType.OTHER;
	
	//check the name for the type
	if(name.contains("xbox"))
		type = JoystickType.XBOX360;
	else if(name.contains("playstation"))
		type = JoystickType.PLAYSTATION;
	
	//setup the axis size for the controller
	FloatBuffer buf  = GLFW.glfwGetJoystickAxes(joy);
	int axisCount = buf.capacity();
	
	//setup the button size for the controller
	ByteBuffer bbuf = GLFW.glfwGetJoystickButtons(joy);
	int buttonCount = bbuf.capacity();
	
	//add the controller to the static array for usage
	connected.add(new Joystick(joy, type, axisCount, buttonCount));
}
 
开发者ID:tek256,项目名称:LD38,代码行数:31,代码来源:Joystick.java


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