1111
1212GraphicsDevice gGraphicsDevice ;
1313
14+ #if (GLFW_VERSION_MAJOR == 3) && (GLFW_VERSION_MINOR < 3)
15+ #else
16+ #define GLFW_SUPPORTS_GAMEPADS
17+ #endif
18+
1419// ////////////////////////////////////////////////////////////////////////
1520
1621// glfw to native input mapping
@@ -86,6 +91,7 @@ static eMButton GlfwMouseButtonToNative(int mbutton)
8691
8792static eGamepadButton GlfwGamepadButtonToNative (int gpbutton)
8893{
94+ #ifdef GLFW_SUPPORTS_GAMEPADS
8995 switch (gpbutton)
9096 {
9197 case GLFW_GAMEPAD_BUTTON_A: return eGamepadButton_A;
@@ -104,6 +110,7 @@ static eGamepadButton GlfwGamepadButtonToNative(int gpbutton)
104110 case GLFW_GAMEPAD_BUTTON_DPAD_DOWN: return eGamepadButton_DPAD_Down;
105111 case GLFW_GAMEPAD_BUTTON_DPAD_LEFT: return eGamepadButton_DPAD_Left;
106112 };
113+ #endif
107114 return eGamepadButton_null;
108115}
109116
@@ -233,14 +240,15 @@ bool GraphicsDevice::Initialize(int screensizex, int screensizey, bool fullscree
233240 };
234241 gSystem .HandleEvent (ev);
235242 });
243+ #ifdef GLFW_SUPPORTS_GAMEPADS
236244 ::glfwSetJoystickCallback ([](int gamepad, int gamepadStatus)
237245 {
238246 if (gamepad < MAX_GAMEPADS)
239247 {
240248 gInputs .SetGamepadPresent (gamepad, (gamepadStatus == GLFW_CONNECTED));
241249 }
242250 });
243-
251+ # endif
244252 // setup opengl extensions
245253 if (!InitializeOGLExtensions ())
246254 {
@@ -298,12 +306,13 @@ bool GraphicsDevice::Initialize(int screensizex, int screensizey, bool fullscree
298306 EnableVSync (vsync);
299307
300308 // init gamepads
309+ #ifdef GLFW_SUPPORTS_GAMEPADS
301310 for (int icurr = 0 ; icurr < MAX_GAMEPADS; ++icurr)
302311 {
303312 bool isGamepad = ::glfwJoystickIsGamepad (icurr) == GLFW_TRUE;
304313 gInputs .SetGamepadPresent (icurr, isGamepad);
305314 }
306-
315+ # endif
307316 return true ;
308317}
309318
@@ -783,6 +792,7 @@ void GraphicsDevice::Present()
783792
784793void GraphicsDevice::ProcessGamepadsInputs ()
785794{
795+ #ifdef GLFW_SUPPORTS_GAMEPADS
786796 GLFWgamepadstate gamepadstate;
787797
788798 for (int icurr = 0 ; icurr < MAX_GAMEPADS; ++icurr)
@@ -823,6 +833,7 @@ void GraphicsDevice::ProcessGamepadsInputs()
823833 gSystem .HandleEvent (inputEvent);
824834 }
825835 }
836+ #endif
826837}
827838
828839void GraphicsDevice::SetViewportRect (const Rect2D& sourceRectangle)
0 commit comments