Allow P1 to retain controller usage when playing alone even if they started charsel with keyboard

This commit is contained in:
SinnamonLat 2022-05-20 20:07:25 +02:00
parent f4b6c55148
commit 95e4bc21ff
2 changed files with 20 additions and 0 deletions

View file

@ -528,6 +528,11 @@ typedef struct setup_player_s
UINT8 color;
UINT8 mdepth;
// Hack, save player 1's original device even if they init charsel with keyboard.
// If they play ALONE, allow them to retain that original device, otherwise, ignore this.
// We can allow them to retain the device with no consequence as when P1 is alone, they have exclusive keyboard fallback options.
UINT8 ponedevice;
INT32 followern;
INT16 followercolor;
tic_t follower_tics;

View file

@ -2287,6 +2287,13 @@ static boolean M_HandlePressStart(setup_player_t *p, UINT8 num)
if (M_DeviceAvailable(i, setup_numplayers) == true)
{
// Available!! Let's use this one!!
// if P1 is setting up using keyboard (device 0), save their last used device.
// this is to allow them to retain controller usage when they play alone.
// Because let's face it, when you test mods, you're often lazy to grab your controller for menuing :)
if (!i && !num)
setup_player[num].ponedevice = cv_usejoystick[num].value;
CV_SetValue(&cv_usejoystick[num], i);
//CONS_Printf("Device for %d set to %d\n", num, i);
//CONS_Printf("========\n");
@ -2903,6 +2910,14 @@ void M_CharacterSelectTick(void)
}
CV_StealthSetValue(&cv_splitplayers, setup_numplayers);
// P1 is alone, set their old device just in case.
if (setup_numplayers < 2)
{
CONS_Printf("Reseting controller device for P1...\n");
CV_StealthSetValue(&cv_usejoystick[0], setup_player[0].ponedevice);
}
M_SetupNextMenu(&PLAY_MainDef, false);
}
}