[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.
This commit is contained in:
Bill Currie 2023-09-15 13:51:59 +09:00
parent 4eaaf28030
commit fab5ae9d1f
4 changed files with 8 additions and 4 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -550,6 +550,8 @@ void
IN_Init (void)
{
Sys_RegisterShutdown (IN_shutdown, 0);
IN_ButtonInit ();
IN_AxisInit ();
IMT_Init ();
IN_Binding_Init ();