From 9bbd33ad489fcb9acb0225810f6e577f4bcff9dc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 21:03:22 +0100 Subject: [PATCH] make float and sink use accel and brake again but also keep rebindable controls keeps intended behaviour since we now dont need to worry about player controls anymore but keeps the rebindable buttons incase someone wants to do a crazy control setup for some reason --- src/g_input.c | 6 ------ src/p_user.c | 10 +++++++++- src/st_stuff.c | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index b99874b8d..c948ed751 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1142,12 +1142,6 @@ void G_Controldefault(UINT8 player) //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up - - gamecontrol[gc_camfloat ][0] = 'a'; - gamecontrol[gc_camsink ][0] = 'd'; - - gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A - gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B } if (player == 0 || player == 2) diff --git a/src/p_user.c b/src/p_user.c index 981865740..36484e0bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3262,6 +3262,14 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; + // float and sink + axis = JoyAxis(AXISMOVE, forplayer); + if (InputDown(gc_accelerate, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, forplayer); + if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + // looking up/down laim += (mlooky<<19); @@ -3348,7 +3356,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; - int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0); + int dir = ((cmd->buttons & BT_ACCELERATE || InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((cmd->buttons & BT_BRAKE || InputDown(gc_camsink, forplayer)) ? -1 : 0); switch (dir) { diff --git a/src/st_stuff.c b/src/st_stuff.c index 6f0777919..527d7af76 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -651,16 +651,18 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } -static const char *ST_GetButtonName(INT32 control, const char *inputtext) +// returns the actual button name for any gamecontrol +// if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) { - static char buttname[32] = {0}; // Static buffer - const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; - const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + static char buttname[32] = {0}; + const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); + const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind - if (item1 != NULL && item2 != NULL) - snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + if (butt1 != NULL && butt2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); else - snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : unbound ? "Unbound" : ""), inputtext); return buttname; } @@ -789,16 +791,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); } } }