CLIENT: Track held duration for all positive gamepad constants

This commit is contained in:
Peter0x44 2024-06-29 14:09:18 -07:00
parent 526ee7f1e6
commit ed59f2bea6
3 changed files with 69 additions and 2 deletions

View file

@ -225,6 +225,7 @@ float stopwatch_round_starttime;
*/
float GPActive[32];
float GPButtonHeldBeginTime[24];
string build_datetime;
#define VERSION_STRING "v1.0"
@ -303,4 +304,4 @@ screenres_s screen_resolution_21x9[] =
{
{2560, 1080},
{3840, 1440}
};
};

View file

@ -923,6 +923,71 @@ void(float button, string key) setToBind =
noref float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent =
{
if (evtype == IE_KEYDOWN) {
switch (scanx) {
case K_GP_A:
case K_GP_B:
case K_GP_X:
case K_GP_Y:
case K_GP_LSHOULDER:
case K_GP_RSHOULDER:
case K_GP_LTRIGGER:
case K_GP_RTRIGGER:
case K_GP_BACK:
case K_GP_START:
case K_GP_LTHUMB:
case K_GP_RTHUMB:
case K_GP_DPAD_UP:
case K_GP_DPAD_DOWN:
case K_GP_DPAD_LEFT:
case K_GP_DPAD_RIGHT:
case K_GP_LTHUMB_UP:
case K_GP_LTHUMB_DOWN:
case K_GP_LTHUMB_LEFT:
case K_GP_LTHUMB_RIGHT:
case K_GP_RTHUMB_UP:
case K_GP_RTHUMB_DOWN:
case K_GP_RTHUMB_LEFT:
case K_GP_RTHUMB_RIGHT:
if (!GPButtonHeldBeginTime[scanx-816])
GPButtonHeldBeginTime[scanx-816] = cltime;
break;
}
}
if (evtype == IE_KEYUP) {
switch (scanx) {
case K_GP_A:
case K_GP_B:
case K_GP_X:
case K_GP_Y:
case K_GP_LSHOULDER:
case K_GP_RSHOULDER:
case K_GP_LTRIGGER:
case K_GP_RTRIGGER:
case K_GP_BACK:
case K_GP_START:
case K_GP_LTHUMB:
case K_GP_RTHUMB:
case K_GP_DPAD_UP:
case K_GP_DPAD_DOWN:
case K_GP_DPAD_LEFT:
case K_GP_DPAD_RIGHT:
case K_GP_LTHUMB_UP:
case K_GP_LTHUMB_DOWN:
case K_GP_LTHUMB_LEFT:
case K_GP_LTHUMB_RIGHT:
case K_GP_RTHUMB_UP:
case K_GP_RTHUMB_DOWN:
case K_GP_RTHUMB_LEFT:
case K_GP_RTHUMB_RIGHT:
//print(sprintf("Key: %f Duration: %f\n", scanx, cltime-GPButtonHeldBeginTime[scanx-816]));
GPButtonHeldBeginTime[scanx-816] = 0;
break;
}
}
switch(evtype)
{
case IE_KEYDOWN:
@ -1052,6 +1117,7 @@ noref float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent
cursor_pos_y = chary;
return FALSE;
}
return FALSE;
};

View file

@ -26,4 +26,4 @@ echo "Compiling FTE SSQC.."
echo "Compiling Standard/Id SSQC.."
./$FTEQCC -O3 -srcfile ../progs/ssqc.src | grep -E -i "warning |error |defined |not |unknown |branches"
echo "End of script."
echo "End of script."