Commit 2373da5d94fe8b977e89786519090cfd556862dd

Sam Lantinga 2022-07-11T09:49:00

Exposed SDL_ResetKeyboard() as a public function This will be used by Source 2 titles to reset keyboard state before showing assertion dialogs

diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h
index b80a7dc..e7663fb 100644
--- a/include/SDL_keyboard.h
+++ b/include/SDL_keyboard.h
@@ -90,10 +90,22 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
  * \since This function is available since SDL 2.0.0.
  *
  * \sa SDL_PumpEvents
+ * \sa SDL_ResetKeyboard
  */
 extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
 
 /**
+ * Clear the state of the keyboard
+ *
+ * This function will generate key up events for all pressed keys.
+ *
+ * \since This function is available since SDL 2.24.0.
+ *
+ * \sa SDL_GetKeyboardState
+ */
+extern DECLSPEC void SDLCALL SDL_ResetKeyboard(void);
+
+/**
  * Get the current key modifier state for the keyboard.
  *
  * \returns an OR'd combination of the modifier keys for the keyboard. See
diff --git a/src/dynapi/SDL2.exports b/src/dynapi/SDL2.exports
index 746b5fc..082de10 100644
--- a/src/dynapi/SDL2.exports
+++ b/src/dynapi/SDL2.exports
@@ -852,3 +852,4 @@
 # ++'_SDL_GDKGetTaskQueue'.'SDL2.dll'.'SDL_GDKGetTaskQueue'
 # ++'_SDL_GDKRunApp'.'SDL2.dll'.'SDL_GDKRunApp'
 ++'_SDL_GetOriginalMemoryFunctions'.'SDL2.dll'.'SDL_GetOriginalMemoryFunctions'
+++'_SDL_ResetKeyboard'.'SDL2.dll'.'SDL_ResetKeyboard'
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index babe19e..18e406e 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -878,3 +878,4 @@
 #define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_REAL
 #define SDL_GDKRunApp SDL_GDKRunApp_REAL
 #define SDL_GetOriginalMemoryFunctions SDL_GetOriginalMemoryFunctions_REAL
+#define SDL_ResetKeyboard SDL_ResetKeyboard_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 2d6e1e8..a76806a 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -961,3 +961,4 @@ SDL_DYNAPI_PROC(int,SDL_GDKGetTaskQueue,(XTaskQueueHandle *a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_GDKRunApp,(SDL_main_func a, void *b),(a,b),return)
 #endif
 SDL_DYNAPI_PROC(void,SDL_GetOriginalMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
+SDL_DYNAPI_PROC(void,SDL_ResetKeyboard,(void),(),)
diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h
index d10158d..beee827 100644
--- a/src/events/SDL_keyboard_c.h
+++ b/src/events/SDL_keyboard_c.h
@@ -29,9 +29,6 @@
 /* Initialize the keyboard subsystem */
 extern int SDL_KeyboardInit(void);
 
-/* Clear the state of the keyboard */
-extern void SDL_ResetKeyboard(void);
-
 /* Get the default keymap */
 extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap);