當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。