diff --git a/src/m_menu.c b/src/m_menu.c index dfe8bbeca..82c818c73 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -160,7 +160,7 @@ typedef enum levellist_mode_t levellistmode = LLM_CREATESERVER; UINT8 maplistoption = 0; -static char joystickInfo[8][25]; +static char joystickInfo[8][29]; #ifndef NONET static UINT32 serverlistpage; #endif @@ -6711,35 +6711,32 @@ static void M_DrawJoystick(void) M_DrawGenericMenu(); - for (i = 0;i < 8; i++) + for (i = 0;i < 7; i++) { - M_DrawSaveLoadBorder(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i); + M_DrawTextBox(OP_JoystickSetDef.x-8, OP_JoystickSetDef.y+LINEHEIGHT*i-12, 28, 1); + //M_DrawSaveLoadBorder(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i); if ((setupcontrols_secondaryplayer && (i == cv_usejoystick2.value)) || (!setupcontrols_secondaryplayer && (i == cv_usejoystick.value))) - V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i,V_GREENMAP,joystickInfo[i]); + V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,V_GREENMAP,joystickInfo[i]); else - V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i,0,joystickInfo[i]); + V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,0,joystickInfo[i]); } } static void M_SetupJoystickMenu(INT32 choice) { INT32 i = 0; - const char *joyname = "None"; const char *joyNA = "Unavailable"; INT32 n = I_NumJoys(); (void)choice; - strcpy(joystickInfo[i], joyname); + strcpy(joystickInfo[i], "None"); for (i = 1; i < 8; i++) { - if (i <= n && (joyname = I_GetJoyName(i)) != NULL) - { - strncpy(joystickInfo[i], joyname, 24); - joystickInfo[i][24] = '\0'; - } + if (i <= n && (I_GetJoyName(i)) != NULL) + strncpy(joystickInfo[i], I_GetJoyName(i), 28); else strcpy(joystickInfo[i], joyNA); } diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 2b35ce8b8..68ebc5e94 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1453,18 +1453,28 @@ INT32 I_NumJoys(void) return numjoy; } +static char joyname[255]; // MAX_PATH; joystick name is straight from the driver + const char *I_GetJoyName(INT32 joyindex) { - const char *joyname = "NA"; + const char *tempname = NULL; joyindex--; //SDL's Joystick System starts at 0, not 1 if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) { if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1) - joyname = SDL_JoystickNameForIndex(joyindex); + { + tempname = SDL_JoystickNameForIndex(joyindex); + if (tempname) + strncpy(joyname, tempname, 255); + } SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } else - joyname = SDL_JoystickNameForIndex(joyindex); + { + tempname = SDL_JoystickNameForIndex(joyindex); + if (tempname) + strncpy(joyname, tempname, 255); + } return joyname; } diff --git a/src/sdl12/i_system.c b/src/sdl12/i_system.c index 8729e5921..10fbc50ee 100644 --- a/src/sdl12/i_system.c +++ b/src/sdl12/i_system.c @@ -1575,18 +1575,28 @@ INT32 I_NumJoys(void) return numjoy; } +static char joyname[255]; // MAX_PATH; joystick name is straight from the driver + const char *I_GetJoyName(INT32 joyindex) { - const char *joyname = "NA"; + const char *tempname = NULL; joyindex--; //SDL's Joystick System starts at 0, not 1 if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) { if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1) - joyname = SDL_JoystickName(joyindex); + { + tempname = SDL_JoystickNameForIndex(joyindex); + if (tempname) + strncpy(joyname, tempname, 255); + } SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } else - joyname = SDL_JoystickName(joyindex); + { + tempname = SDL_JoystickNameForIndex(joyindex); + if (tempname) + strncpy(joyname, tempname, 255); + } return joyname; }