ref: c1876609045eb1cf8c4cd779edbc31b625b8f148
parent: 8fdaea5d8b8cb218f5a3c1597eb267f1086d48de
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Apr 4 20:20:41 EDT 2020
Hat cleanup
--- a/src/Backends/GLFW3/Controller.cpp
+++ b/src/Backends/GLFW3/Controller.cpp
@@ -137,22 +137,22 @@
// Then the joystick hats
for (int i = 0; i < total_axes; ++i)
{
- status->bButton[buttons_done] = hats[i] == GLFW_HAT_UP;
+ status->bButton[buttons_done] = hats[i] & GLFW_HAT_UP;
if (++buttons_done >= button_limit)
break;
- status->bButton[buttons_done] = hats[i] == GLFW_HAT_RIGHT;
+ status->bButton[buttons_done] = hats[i] & GLFW_HAT_RIGHT;
if (++buttons_done >= button_limit)
break;
- status->bButton[buttons_done] = hats[i] == GLFW_HAT_DOWN;
+ status->bButton[buttons_done] = hats[i] & GLFW_HAT_DOWN;
if (++buttons_done >= button_limit)
break;
- status->bButton[buttons_done] = hats[i] == GLFW_HAT_LEFT;
+ status->bButton[buttons_done] = hats[i] & GLFW_HAT_LEFT;
if (++buttons_done >= button_limit)
break;
--- a/src/Backends/SDL2/Controller.cpp
+++ b/src/Backends/SDL2/Controller.cpp
@@ -78,42 +78,22 @@
{
Uint8 hat = SDL_JoystickGetHat(joystick, i);
- status->bButton[buttons_done] = hat == SDL_HAT_UP;
+ status->bButton[buttons_done] = hat == SDL_HAT_UP || hat == SDL_HAT_LEFTUP || hat == SDL_HAT_RIGHTUP;
if (++buttons_done >= button_limit)
break;
- status->bButton[buttons_done] = hat == SDL_HAT_RIGHT;
+ status->bButton[buttons_done] = hat == SDL_HAT_RIGHT || hat == SDL_HAT_RIGHTUP || hat == SDL_HAT_RIGHTDOWN;
if (++buttons_done >= button_limit)
break;
- status->bButton[buttons_done] = hat == SDL_HAT_DOWN;
+ status->bButton[buttons_done] = hat == SDL_HAT_DOWN || hat == SDL_HAT_LEFTDOWN || hat == SDL_HAT_RIGHTDOWN;
if (++buttons_done >= button_limit)
break;
- status->bButton[buttons_done] = hat == SDL_HAT_LEFT;
-
- if (++buttons_done >= button_limit)
- break;
-
- status->bButton[buttons_done] = hat == SDL_HAT_RIGHTUP;
-
- if (++buttons_done >= button_limit)
- break;
-
- status->bButton[buttons_done] = hat == SDL_HAT_RIGHTDOWN;
-
- if (++buttons_done >= button_limit)
- break;
-
- status->bButton[buttons_done] = hat == SDL_HAT_LEFTUP;
-
- if (++buttons_done >= button_limit)
- break;
-
- status->bButton[buttons_done] = hat == SDL_HAT_LEFTDOWN;
+ status->bButton[buttons_done] = hat == SDL_HAT_LEFT || hat == SDL_HAT_LEFTUP || hat == SDL_HAT_LEFTDOWN;
if (++buttons_done >= button_limit)
break;