From ed59f2bea63a4aa9be3234e1142d32f03d69889a Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sat, 29 Jun 2024 14:09:18 -0700 Subject: [PATCH] CLIENT: Track held duration for all positive gamepad constants --- source/client/defs/custom.qc | 3 +- source/client/main.qc | 66 ++++++++++++++++++++++++++++++++++++ tools/qc-compiler-gnu.sh | 2 +- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/source/client/defs/custom.qc b/source/client/defs/custom.qc index 00fd036..69e9e0a 100644 --- a/source/client/defs/custom.qc +++ b/source/client/defs/custom.qc @@ -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} -}; \ No newline at end of file +}; diff --git a/source/client/main.qc b/source/client/main.qc index c590ffb..7d7c9b9 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -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; }; diff --git a/tools/qc-compiler-gnu.sh b/tools/qc-compiler-gnu.sh index 2238e9f..a1f66d1 100755 --- a/tools/qc-compiler-gnu.sh +++ b/tools/qc-compiler-gnu.sh @@ -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." \ No newline at end of file +echo "End of script."