From 26f36da7e73ea5f6b597f64a6b23c03615efe978 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Sat, 16 May 2020 11:13:24 -0400 Subject: [PATCH] Another bug fix for gamepad config loading at startup, the first fix was in the wrong place. Removed static video variable from header. --- src/drivers/sdl/config.cpp | 7 ++++--- src/drivers/sdl/gui.cpp | 2 +- src/drivers/sdl/input.cpp | 2 +- src/drivers/sdl/sdl-video.cpp | 2 +- src/drivers/sdl/sdl-video.h | 1 - 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/drivers/sdl/config.cpp b/src/drivers/sdl/config.cpp index 3c5b04df..a249d74e 100644 --- a/src/drivers/sdl/config.cpp +++ b/src/drivers/sdl/config.cpp @@ -269,9 +269,10 @@ InitConfig() config->addOption("4buttonexit", "SDL.ABStartSelectExit", 0); // GamePad 0 - 3 - for(unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) { + for(unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) + { char buf[64]; - snprintf(buf, 20, "SDL.Input.GamePad.%d.", i); + snprintf(buf, sizeof(buf)-1, "SDL.Input.GamePad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultGamePadDevice[i]); @@ -284,7 +285,7 @@ InitConfig() // PowerPad 0 - 1 for(unsigned int i = 0; i < POWERPAD_NUM_DEVICES; i++) { char buf[64]; - snprintf(buf, 20, "SDL.Input.PowerPad.%d.", i); + snprintf(buf, sizeof(buf)-1, "SDL.Input.PowerPad.%d.", i); prefix = buf; config->addOption(prefix + "DeviceType", DefaultPowerPadDevice[i]); diff --git a/src/drivers/sdl/gui.cpp b/src/drivers/sdl/gui.cpp index 86ba5330..a483d2b8 100644 --- a/src/drivers/sdl/gui.cpp +++ b/src/drivers/sdl/gui.cpp @@ -126,7 +126,7 @@ int configGamepadButton (GtkButton * button, gpointer p) ButtonConfigBegin (); - snprintf (buf, sizeof (buf), "SDL.Input.GamePad.%d", padNo); + snprintf (buf, sizeof(buf)-1, "SDL.Input.GamePad.%d.", padNo); prefix = buf; DWaitButton (NULL, &GamePadConfig[padNo][x], configNo); diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp index 3110d32e..e6782e34 100644 --- a/src/drivers/sdl/input.cpp +++ b/src/drivers/sdl/input.cpp @@ -2145,7 +2145,7 @@ UpdateInput (Config * config) for (unsigned int i = 0; i < GAMEPAD_NUM_DEVICES; i++) { char buf[64]; - snprintf (buf, 32, "SDL.Input.GamePad.%d", i); + snprintf (buf, sizeof(buf)-1, "SDL.Input.GamePad.%d.", i); prefix = buf; config->getOption (prefix + "DeviceType", &device); diff --git a/src/drivers/sdl/sdl-video.cpp b/src/drivers/sdl/sdl-video.cpp index 4c24883d..a3538cf1 100644 --- a/src/drivers/sdl/sdl-video.cpp +++ b/src/drivers/sdl/sdl-video.cpp @@ -55,7 +55,7 @@ extern Config *g_config; // STATIC GLOBALS -extern SDL_Surface *s_screen; +static SDL_Surface *s_screen = NULL; static SDL_Surface *s_BlitBuf; // Buffer when using hardware-accelerated blits. static SDL_Surface *s_IconSurface = NULL; diff --git a/src/drivers/sdl/sdl-video.h b/src/drivers/sdl/sdl-video.h index ef6c30d5..82ac15f7 100644 --- a/src/drivers/sdl/sdl-video.h +++ b/src/drivers/sdl/sdl-video.h @@ -9,7 +9,6 @@ uint32 PtoV(uint16 x, uint16 y); bool FCEUD_ShouldDrawInputAids(); bool FCEUI_AviDisableMovieMessages(); -static SDL_Surface *s_screen; bool FCEUI_AviEnableHUDrecording(); void FCEUI_SetAviEnableHUDrecording(bool enable); bool FCEUI_AviDisableMovieMessages();