本文整理汇总了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);
}
}
}
示例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));
}