mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Bandaid fix for trigger mapping, not super consistent but it helps most of the time...
This commit is contained in:
parent
1d4ee40758
commit
4f919f883d
3 changed files with 81 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<<i;
|
||||
if (M_MenuButtonHeld(pid, bt))
|
||||
{
|
||||
if (controllerpresspatch[i][1][0] != '\0')
|
||||
V_DrawScaledPatch(BASEVIDWIDTH*2/3 - optionsmenu.contx, BASEVIDHEIGHT/2 -optionsmenu.conty, 0, W_CachePatchName(controllerpresspatch[i][1], PU_CACHE));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (controllerpresspatch[i][0][0] != '\0')
|
||||
V_DrawScaledPatch(BASEVIDWIDTH*2/3 - optionsmenu.contx, BASEVIDHEIGHT/2 -optionsmenu.conty, 0, W_CachePatchName(controllerpresspatch[i][0], PU_CACHE));
|
||||
}
|
||||
}
|
||||
|
||||
// Tooltip
|
||||
// The text is slightly shifted hence why we don't just use M_DrawMenuTooltips()
|
||||
V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUHINT", PU_CACHE), NULL);
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,11 @@ boolean M_MenuButtonPressed(UINT8 pid, UINT32 bt)
|
|||
return (menucmd[pid].buttons & bt);
|
||||
}
|
||||
|
||||
boolean M_MenuButtonHeld(UINT8 pid, UINT32 bt)
|
||||
{
|
||||
return (menucmd[pid].buttons & bt);
|
||||
}
|
||||
|
||||
// Returns true if we press the confirmation button
|
||||
static boolean M_MenuConfirmPressed(UINT8 pid)
|
||||
{
|
||||
|
|
@ -4188,6 +4193,9 @@ void M_ProfileDeviceSelect(INT32 choice)
|
|||
optionsmenu.bindcontrol = 0;
|
||||
optionsmenu.bindtimer = 0;
|
||||
|
||||
optionsmenu.lastkey = 0;
|
||||
optionsmenu.keyheldfor = 0;
|
||||
|
||||
optionsmenu.contx = optionsmenu.tcontx = controlleroffsets[gc_a][0];
|
||||
optionsmenu.conty = optionsmenu.tconty = controlleroffsets[gc_a][1];
|
||||
|
||||
|
|
@ -4255,7 +4263,9 @@ boolean M_ProfileControlsInputs(INT32 ch)
|
|||
return true;
|
||||
}
|
||||
else if (M_MenuBackPressed(pid))
|
||||
{
|
||||
optionsmenu.profile->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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue