From 4f919f883d66502fc92c926424fe4c45bbaff1d4 Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Tue, 12 Apr 2022 16:38:40 +0200 Subject: [PATCH] Bandaid fix for trigger mapping, not super consistent but it helps most of the time... --- src/k_menu.h | 5 +++++ src/k_menudraw.c | 38 +++++++++++++++++++++++++++++++++++++- src/k_menufunc.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/k_menu.h b/src/k_menu.h index 64162ae87..be0f24b47 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -454,6 +454,7 @@ void M_SortServerList(void); void M_MapMenuControls(event_t *ev); boolean M_Responder(event_t *ev); boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt); +boolean M_MenuButtonHeld(UINT8 pid, UINT32 bt); void M_StartControlPanel(void); void M_ClearMenus(boolean callexitmenufunc); void M_SelectableClearMenus(INT32 choice); @@ -673,6 +674,10 @@ extern struct optionsmenu_s { UINT8 bindcontrol; // 0: not binding, 1: binding control #1, 2: binding control #2 INT16 bindtimer; // Timer until binding is cancelled (5s) + // Used for horrible axis shenanigans + INT32 lastkey; + tic_t keyheldfor; + // controller coords... // Works the same as (t)opt INT16 contx; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index bbff97bba..a1098bc26 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2672,6 +2672,24 @@ INT16 controlleroffsets[][2] = { {149, 187}, // gc_start }; +// Controller patches for button presses. +// {patch if not pressed, patch if pressed} +// if NULL, draws nothing. +// reminder that lumpnames can only be 8 chars at most. (+1 for \0) + +char controllerpresspatch[9][2][9] = { + {"", "BTP_A"}, // MBT_A + {"", "BTP_B"}, // MBT_B + {"", "BTP_C"}, // MBT_C + {"", "BTP_X"}, // MBT_X + {"", "BTP_Y"}, // MBT_Y + {"", "BTP_Z"}, // MBT_Z + {"BTNP_L", "BTP_L"},// MBT_L + {"BTNP_R", "BTP_R"},// MBT_R + {"", "BTP_ST"} // MBT_START +}; + + // the control stuff. // Dear god. void M_DrawProfileControls(void) @@ -2680,12 +2698,30 @@ void M_DrawProfileControls(void) INT32 y = 16 - (optionsmenu.controlscroll*spacing); INT32 x = 8; INT32 i, j, k; + const UINT8 pid = 0; M_DrawOptionsCogs(); - // @TODO: have it move around and shit. V_DrawScaledPatch(BASEVIDWIDTH*2/3 - optionsmenu.contx, BASEVIDHEIGHT/2 -optionsmenu.conty, 0, W_CachePatchName("PR_CONT", PU_CACHE)); + // Draw button presses... + // @TODO: Dpad when we get the sprites for it. + + for (i = 0; i < 9; i++) + { + INT32 bt = 1<kickstartaccel = cv_dummyprofilekickstart.value; // Make sure to save kickstart accel. + } return false; } @@ -4284,6 +4294,8 @@ void M_ProfileSetControl(INT32 ch) } // Map the event to the profile. + +#define KEYHOLDFOR 1 void M_MapProfileControl(event_t *ev) { INT32 c = 0; @@ -4357,6 +4369,32 @@ void M_MapProfileControl(event_t *ev) } } } + + /* I hate this. + I shouldn't have to do this. + But we HAVE to because of some controllers, INCLUDING MINE. + + Triggers on X360 controllers go from -1024 when not held + To 1023 when pressed. + The result is that pressing the trigger makes the game THINK the input is for a negative value. + Which then means that the input is considered pressed when the trigger is released. + + So what we're going to do is make sure that the detected 'c' key is the same for multiple rolls of ev_joystick. + NOTE: We need the player to press the key all the way down otherwise this might just not work... + + @TODO: This isn't entirely consistent because we only check for events..... maybe check continuously for gamekeydown[]? + but this seems messy... + */ + + //CONS_Printf("mapping joystick ... attempt (%d)\n", optionsmenu.keyheldfor); + + if (c != optionsmenu.lastkey) + { + optionsmenu.lastkey = c; + optionsmenu.keyheldfor = 0; + return; + } + break; default: return; @@ -4386,6 +4424,7 @@ void M_MapProfileControl(event_t *ev) optionsmenu.profile->controls[controln][where] = c; optionsmenu.bindcontrol = 0; // not binding anymore } +#undef KEYHOLDFOR void M_HandleItemToggles(INT32 choice) {