From fab5ae9d1fb8b8a9818a8cc330cee61be948e741 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 15 Sep 2023 13:51:59 +0900 Subject: [PATCH] [input] Delay button and axis init It turns out that initializing them via constructors led to their shutdowns happening too late which resulted in problems with button and axis cleanup. --- include/QF/input/binding.h | 2 ++ libs/input/in_axis.c | 4 ++-- libs/input/in_button.c | 4 ++-- libs/input/in_common.c | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/QF/input/binding.h b/include/QF/input/binding.h index a81f8a05c..fec91e9ce 100644 --- a/include/QF/input/binding.h +++ b/include/QF/input/binding.h @@ -349,7 +349,9 @@ IN_ClampAxis (in_axis_t *axis, float minval, float maxval) void IN_ButtonAction (in_button_t *buttin, int id, int pressed); int IN_RegisterButton (in_button_t *button); +void IN_ButtonInit (void); int IN_RegisterAxis (in_axis_t *axis); +void IN_AxisInit (void); in_button_t *IN_FindButton (const char *name); void IN_ButtonClearStates (void); in_axis_t *IN_FindAxis (const char *name); diff --git a/libs/input/in_axis.c b/libs/input/in_axis.c index 0c250b4ce..122b36d9e 100644 --- a/libs/input/in_axis.c +++ b/libs/input/in_axis.c @@ -111,8 +111,8 @@ in_axis_shutdown (void *data) Hash_DelTable (axis_tab); } -static void __attribute__((constructor)) -in_axis_init (void) +void +IN_AxisInit (void) { axis_tab = Hash_NewTable (127, axis_get_key, axis_free, 0, 0); Sys_RegisterShutdown (in_axis_shutdown, 0); diff --git a/libs/input/in_button.c b/libs/input/in_button.c index 4847783eb..f79d1ceaa 100644 --- a/libs/input/in_button.c +++ b/libs/input/in_button.c @@ -246,8 +246,8 @@ in_button_shutdown (void *data) Hash_DelTable (button_tab); } -static void __attribute__((constructor)) -in_button_init (void) +void +IN_ButtonInit (void) { button_tab = Hash_NewTable (127, button_get_key, button_free, 0, 0); Sys_RegisterShutdown (in_button_shutdown, 0); diff --git a/libs/input/in_common.c b/libs/input/in_common.c index f4024c753..17fa0686c 100644 --- a/libs/input/in_common.c +++ b/libs/input/in_common.c @@ -550,6 +550,8 @@ void IN_Init (void) { Sys_RegisterShutdown (IN_shutdown, 0); + IN_ButtonInit (); + IN_AxisInit (); IMT_Init (); IN_Binding_Init ();