aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-12-30 13:43:59 +0100
committerStapleButter <thetotalworm@gmail.com>2018-12-30 13:43:59 +0100
commit52d783e06628b5f832a25dfeee28709d3627db58 (patch)
tree804ba44b1deca5a15f29a4e1d569a9817dc3ce11 /src
parent9eab6618dab72ae83161fba8c7c510894b57906b (diff)
might want to update that when hotplugging joysticks, too
Diffstat (limited to 'src')
-rw-r--r--src/libui_sdl/main.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 44c29f8..7d7b090 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -403,7 +403,7 @@ int EmuThreadFunc(void* burp)
if (Joystick)
{
njoybuttons = SDL_JoystickNumButtons(Joystick);
- if (njoybuttons)
+ if (njoybuttons)
{
joybuttons = new Uint8[njoybuttons];
memset(joybuttons, 0, sizeof(Uint8)*njoybuttons);
@@ -422,9 +422,9 @@ int EmuThreadFunc(void* burp)
if (EmuRunning == 1)
{
EmuStatus = 1;
-
+
SDL_JoystickUpdate();
-
+
if (Joystick)
{
if (!SDL_JoystickGetAttached(Joystick))
@@ -436,6 +436,16 @@ int EmuThreadFunc(void* burp)
if (!Joystick && (SDL_NumJoysticks() > 0))
{
Joystick = SDL_JoystickOpen(0);
+ if (Joystick)
+ {
+ njoybuttons = SDL_JoystickNumButtons(Joystick);
+ if (joybuttons) delete[] joybuttons;
+ if (njoybuttons)
+ {
+ joybuttons = new Uint8[njoybuttons];
+ memset(joybuttons, 0, sizeof(Uint8)*njoybuttons);
+ }
+ }
}
// poll input
@@ -1006,10 +1016,10 @@ void OnAreaResize(uiAreaHandler* handler, uiArea* area, int width, int height)
// but... we never know, I guess
WindowWidth = width;
WindowHeight = height;
-
+
int max = uiWindowMaximized(MainWindow);
int min = uiWindowMinimized(MainWindow);
-
+
Config::WindowMaximized = max;
if (!max && !min)
{
@@ -1828,7 +1838,7 @@ int main(int argc, char** argv)
int h = Config::WindowHeight;
//if (w < 256) w = 256;
//if (h < 384) h = 384;
-
+
WindowWidth = w;
WindowHeight = h;