mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Default controls in menus works for all players
Prevents keyboard-only profile softlock.
This commit is contained in:
parent
f952be1e2c
commit
0a11eef569
1 changed files with 34 additions and 30 deletions
18
src/g_game.c
18
src/g_game.c
|
|
@ -900,7 +900,8 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers)
|
||||||
{
|
{
|
||||||
const INT32 deadzone = (JOYAXISRANGE * cv_deadzone[p].value) / FRACUNIT;
|
const INT32 deadzone = (JOYAXISRANGE * cv_deadzone[p].value) / FRACUNIT;
|
||||||
const INT32 keyboard_player = G_GetPlayerForDevice(KEYBOARD_MOUSE_DEVICE);
|
const INT32 keyboard_player = G_GetPlayerForDevice(KEYBOARD_MOUSE_DEVICE);
|
||||||
const boolean is_main_menu_controller = (p == 0 && menuPlayers > 0);
|
const boolean in_menu = (menuPlayers > 0);
|
||||||
|
const boolean main_player = (p == 0);
|
||||||
INT32 deviceID = UNASSIGNED_DEVICE;
|
INT32 deviceID = UNASSIGNED_DEVICE;
|
||||||
INT32 value = -1;
|
INT32 value = -1;
|
||||||
INT32 avail_gamepad_id = 0;
|
INT32 avail_gamepad_id = 0;
|
||||||
|
|
@ -916,14 +917,14 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers)
|
||||||
|
|
||||||
deviceID = G_GetDeviceForPlayer(p);
|
deviceID = G_GetDeviceForPlayer(p);
|
||||||
|
|
||||||
if ((menuPlayers > 0 && G_KeyBindIsNecessary(gc) == true) // In menu: check for all unoverrideable menu default controls.
|
if ((in_menu == true && G_KeyBindIsNecessary(gc) == true) // In menu: check for all unoverrideable menu default controls.
|
||||||
|| (menuPlayers == 0 && gc == gc_start)) // In gameplay: check for the unoverrideable start button to be able to bring up the menu.
|
|| (in_menu == false && gc == gc_start)) // In gameplay: check for the unoverrideable start button to be able to bring up the menu.
|
||||||
{
|
{
|
||||||
value = G_GetValueFromControlTable(KEYBOARD_MOUSE_DEVICE, JOYAXISRANGE/4, &(menucontrolreserved[gc][0]));
|
value = G_GetValueFromControlTable(KEYBOARD_MOUSE_DEVICE, JOYAXISRANGE/4, &(menucontrolreserved[gc][0]));
|
||||||
if (value > 0) // Check for press instead of bound.
|
if (value > 0) // Check for press instead of bound.
|
||||||
{
|
{
|
||||||
// This is only intended for P1.
|
// This is only intended for P1.
|
||||||
if (p == 0)
|
if (main_player == true)
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -935,7 +936,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player 1 is always allowed to use the keyboard in 1P, even if they got disconnected.
|
// Player 1 is always allowed to use the keyboard in 1P, even if they got disconnected.
|
||||||
if (p == 0 && keyboard_player == -1 && deviceID == UNASSIGNED_DEVICE)
|
if (main_player == true && keyboard_player == -1 && deviceID == UNASSIGNED_DEVICE)
|
||||||
{
|
{
|
||||||
deviceID = KEYBOARD_MOUSE_DEVICE;
|
deviceID = KEYBOARD_MOUSE_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
@ -948,7 +949,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you're on gamepad in 1P, and you didn't have a gamepad bind for this, then try your keyboard binds.
|
// If you're on gamepad in 1P, and you didn't have a gamepad bind for this, then try your keyboard binds.
|
||||||
if (p == 0 && keyboard_player == -1 && deviceID > KEYBOARD_MOUSE_DEVICE)
|
if (main_player == true && keyboard_player == -1 && deviceID > KEYBOARD_MOUSE_DEVICE)
|
||||||
{
|
{
|
||||||
value = G_GetValueFromControlTable(KEYBOARD_MOUSE_DEVICE, deadzone, &(gamecontrol[p][gc][0]));
|
value = G_GetValueFromControlTable(KEYBOARD_MOUSE_DEVICE, deadzone, &(gamecontrol[p][gc][0]));
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
|
|
@ -957,7 +958,9 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_main_menu_controller == true)
|
if (in_menu == true)
|
||||||
|
{
|
||||||
|
if (main_player == true)
|
||||||
{
|
{
|
||||||
// We are P1 controlling menus. We should be able to
|
// We are P1 controlling menus. We should be able to
|
||||||
// control the menu with any unused gamepads, so
|
// control the menu with any unused gamepads, so
|
||||||
|
|
@ -991,6 +994,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Still nothing bound after everything. Try default gamepad controls.
|
// Still nothing bound after everything. Try default gamepad controls.
|
||||||
value = G_GetValueFromControlTable(deviceID, deadzone, &(gamecontroldefault[gc][0]));
|
value = G_GetValueFromControlTable(deviceID, deadzone, &(gamecontroldefault[gc][0]));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue