From 1bcc4dddb616c09442d02ea75d0ed6fc0795d55a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 1 Feb 2024 11:16:36 +0900 Subject: [PATCH] [ruamoko] Wrap some more input functions IN_UpdateAxis (for nice handling of axis updates, especially relative motion for mice) and IN_Binding_HandleEvent because registering an event handler blocks qwaq's internall call to IN_Binding_HandleEvent. --- libs/ruamoko/rua_input.c | 19 +++++++++++++++++++ ruamoko/include/input.h | 2 ++ ruamoko/lib/input.r | 3 +++ 3 files changed, 24 insertions(+) diff --git a/libs/ruamoko/rua_input.c b/libs/ruamoko/rua_input.c index 18ec8d63f..060d92df8 100644 --- a/libs/ruamoko/rua_input.c +++ b/libs/ruamoko/rua_input.c @@ -154,6 +154,14 @@ bi_IN_ProcessEvents (progs_t *pr, void *_res) IN_ProcessEvents (); } +static void +bi_IN_UpdateAxis (progs_t *pr, void *_res) +{ + qfZoneScoped (true); + in_axis_t *axis = &P_STRUCT (pr, in_axis_t, 0); + R_FLOAT(pr) = IN_UpdateAxis (axis); +} + static void bi_IN_ClearStates (progs_t *pr, void *_res) { @@ -491,6 +499,14 @@ bi_IMT_SetContext (progs_t *pr, void *_res) IMT_SetContext (P_INT (pr, 0)); } +static void +bi_IN_Binding_HandleEvent (progs_t *pr, void *_res) +{ + qfZoneScoped (true); + auto ie_event = (struct IE_event_s *) P_GPOINTER (pr, 0); + IN_Binding_HandleEvent (ie_event); +} + static void secured (progs_t *pr, void *_res) { @@ -528,6 +544,7 @@ static builtin_t builtins[] = { bi(IN_GetAxisNumber, 2, p(int), p(string)), bi(IN_GetButtonNumber, 2, p(int), p(string)), bi(IN_ProcessEvents, 0), + bi(IN_UpdateAxis, 1, p(ptr)), bi(IN_ClearStates, 0), bi(IN_GetAxisInfo, 3, p(int), p(int), p(ptr)), bi(IN_GetButtonInfo, 3, p(int), p(int), p(ptr)), @@ -552,6 +569,8 @@ static builtin_t builtins[] = { bi(IMT_GetContext, 0), bi(IMT_SetContext, 1, p(int)), + bi(IN_Binding_HandleEvent, 1, p(ptr)), + {0} }; diff --git a/ruamoko/include/input.h b/ruamoko/include/input.h index 5a6e9413e..2c4ff6db1 100644 --- a/ruamoko/include/input.h +++ b/ruamoko/include/input.h @@ -19,6 +19,7 @@ string IN_GetButtonName (int devid, int button); int IN_GetAxisNumber (int devid, string axis); int IN_GetButtonNumber (int devid, string button); void IN_ProcessEvents (void); +float IN_UpdateAxis (in_axis_t *axis); void IN_ClearStates (void); int IN_GetAxisInfo (int devid, int axis, in_axisinfo_t *info); int IN_GetButtonInfo (int devid, int button, in_buttoninfo_t *info); @@ -43,5 +44,6 @@ typedef void (*axis_listener_t) (void *data, in_axis_t *axis);//FIXME const int IMT_CreateContext (string name); int IMT_GetContext (void); void IMT_SetContext (int ctx); +/*bool*/int IN_Binding_HandleEvent (/*const*/ struct IE_event_s *ie_event); #endif//__ruamoko_input_h diff --git a/ruamoko/lib/input.r b/ruamoko/lib/input.r index 368efff43..548d1220e 100644 --- a/ruamoko/lib/input.r +++ b/ruamoko/lib/input.r @@ -14,6 +14,7 @@ string IN_GetButtonName (int devid, int button) = #0; int IN_GetAxisNumber (int devid, string axis) = #0; int IN_GetButtonNumber (int devid, string button) = #0; void IN_ProcessEvents (void) = #0; +float IN_UpdateAxis (in_axis_t *axis) = #0; void IN_ClearStates (void) = #0; int IN_GetAxisInfo (int devid, int axis, in_axisinfo_t *info) = #0; int IN_GetButtonInfo (int devid, int button, in_buttoninfo_t *info) = #0; @@ -42,6 +43,8 @@ int IMT_CreateContext (string name) = #0; int IMT_GetContext (void) = #0; void IMT_SetContext (int ctx) = #0; +/*bool*/int IN_Binding_HandleEvent (/*const*/ struct IE_event_s *ie_event) = #0; + #define IE_EVENT(event) #event, string ie_event_names[] = { #include "QF/input/event_names.h"