void handleEvent(const sf::Event& event) { #if !(INPUT_DISABLE_KEYBOARD) if (keyEvent(event)) return; #endif #if !(INPUT_DISABLE_MOUSE) if (mouseEvent(event)) return; #endif #if !(INPUT_DISABLE_JOYSTICK) if (joystickEvent(event)) return; #endif }
void Input::preferRawControllers(bool prefer){ _preferRawControllers = prefer; for(int id = GLFW_JOYSTICK_1; id <= GLFW_JOYSTICK_LAST; ++id){ _controllers[id] = nullptr; // We only register the first joystick encountered if it exists. if(glfwJoystickPresent(id) == GL_TRUE){ joystickEvent(id, GLFW_CONNECTED); _joystickConnected = true; } } }
Input::Input(){ // Check if any joystick is available. bool first = true; for(int id = GLFW_JOYSTICK_1; id <= GLFW_JOYSTICK_LAST; ++id){ _controllers[id] = nullptr; // We only register the first joystick encountered if it exists. if(glfwJoystickPresent(id) == GL_TRUE && first){ joystickEvent(id, GLFW_CONNECTED); first = false; _joystickConnected = true; } } }
void InputHandler::handleEvent(const sf::Event& event) { if (keyEvent(event)) return; if (mouseEvent(event)) return; if (joystickEvent(event)) return; }