本文整理汇总了C++中Gamepad::Connected方法的典型用法代码示例。如果您正苦于以下问题:C++ Gamepad::Connected方法的具体用法?C++ Gamepad::Connected怎么用?C++ Gamepad::Connected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gamepad
的用法示例。
在下文中一共展示了Gamepad::Connected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Timer
/**
* Creates an instance of InputManager
* Counts the number of players based on # of conencted controllers
* at creation
* No numPlayers is not updated after creation, but it may be possible to
* simply connect another controller and have it work
* Always at least 1 player because of mouse and keyboard support
*/
InputManager::InputManager(GLFWwindow* w)
{
window = w;
glfwSetKeyCallback(window, keyboard);
glfwSetMouseButtonCallback(window, mouseClick);
glfwSetCursorPosCallback(window, mousePosition);
kForward = kBackward = 0;
kTurnL = kTurnR = 0;
kCamH = 0;
kCamV = 0;
kDrift = false;
kPowerup = false;
kMenu = false;
kJump = false;
kHorn = false;
kDebug = false;
rumbleTimer = Timer();
int widthP = 0;
int heightP = 0;
glfwGetWindowSize(window, &widthP, &heightP);
widthP = widthP / 2;
heightP = heightP / 2;
glfwSetCursorPos(window, widthP, heightP);
lastMouseX = (float)widthP;
lastMouseY = (float)heightP;
numPlayers = 1;
for (int i = 1; i < MAX_PLAYERS; i++) {
Gamepad temp = Gamepad(i);
gamepads[i - 1] = temp;
if (temp.Connected()) {
printf("Controller connected in port %d\n", i);
// Allows for a player when no controllers connected
if (i != 1) {
numPlayers += 1;
}
rumbleEndTimes[i - 1] = 0;
//rumble(i, 0.5f, 0.5);
}
}
}