Fix controller name display in menu (and a segfault)
This commit is contained in:
parent
584157277f
commit
0c0680d2f3
2 changed files with 3 additions and 4 deletions
|
|
@ -2619,7 +2619,7 @@ static void M_DrawRightString(menuitem_t *item, INT16 x, INT16 y, INT32 vflags,
|
||||||
{
|
{
|
||||||
INT32 stick = cv_usecontroller[setupcontrolplayer-1].value;
|
INT32 stick = cv_usecontroller[setupcontrolplayer-1].value;
|
||||||
const char *name = stick == 0 ? "None" : I_GetControllerName(stick);
|
const char *name = stick == 0 ? "None" : I_GetControllerName(stick);
|
||||||
if (!name) name = "?";
|
if (!name) name = "Unavailable";
|
||||||
w = V_StringWidth(name, vflags);
|
w = V_StringWidth(name, vflags);
|
||||||
(w > BASEVIDWIDTH/2 - 4 ? V_DrawRightAlignedThinString : V_DrawRightAlignedString)
|
(w > BASEVIDWIDTH/2 - 4 ? V_DrawRightAlignedThinString : V_DrawRightAlignedString)
|
||||||
(BASEVIDWIDTH - x, y, vflags|highlightflags, name);
|
(BASEVIDWIDTH - x, y, vflags|highlightflags, name);
|
||||||
|
|
@ -8443,7 +8443,6 @@ INT32 MR_SetupJoystickMenu(INT32 arg)
|
||||||
const INT32 numcontrollers = I_NumControllers();
|
const INT32 numcontrollers = I_NumControllers();
|
||||||
|
|
||||||
INT32 i = 0;
|
INT32 i = 0;
|
||||||
INT32 j;
|
|
||||||
|
|
||||||
if (arg < 0 || arg >= MAXSPLITSCREENPLAYERS)
|
if (arg < 0 || arg >= MAXSPLITSCREENPLAYERS)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -8468,7 +8467,7 @@ INT32 MR_SetupJoystickMenu(INT32 arg)
|
||||||
//
|
//
|
||||||
// Update cv_usecontroller.string here so that the user can
|
// Update cv_usecontroller.string here so that the user can
|
||||||
// properly change this value.
|
// properly change this value.
|
||||||
for (j = 0; j < MAXSPLITSCREENPLAYERS; j++)
|
for (INT32 j = 0; j < MAXSPLITSCREENPLAYERS; j++)
|
||||||
{
|
{
|
||||||
if (i == cv_usecontroller[j].value)
|
if (i == cv_usecontroller[j].value)
|
||||||
CV_SetValue(&cv_usecontroller[j], i);
|
CV_SetValue(&cv_usecontroller[j], i);
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ const char *I_GetControllerName(INT32 joyid)
|
||||||
{
|
{
|
||||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
|
if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
|
||||||
{
|
{
|
||||||
if (joyid <= 0)
|
if (joyid <= 0 || joyid > numcontrollers)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!controllerlist)
|
if (!controllerlist)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue