From 2373da5d94fe8b977e89786519090cfd556862dd Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 11 Jul 2022 09:49:00 -0700
Subject: [PATCH] Exposed SDL_ResetKeyboard() as a public function
This will be used by Source 2 titles to reset keyboard state before showing assertion dialogs
---
include/SDL_keyboard.h | 12 ++++++++++++
src/dynapi/SDL2.exports | 1 +
src/dynapi/SDL_dynapi_overrides.h | 1 +
src/dynapi/SDL_dynapi_procs.h | 1 +
src/events/SDL_keyboard_c.h | 3 ---
5 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h
index b80a7dcab23..e7663fb34ce 100644
--- a/include/SDL_keyboard.h
+++ b/include/SDL_keyboard.h
@@ -90,9 +90,21 @@ 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.
*
diff --git a/src/dynapi/SDL2.exports b/src/dynapi/SDL2.exports
index 746b5fc9699..082de10011f 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 babe19e096f..18e406e5f5f 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 2d6e1e8896c..a76806acce8 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 d10158d0426..beee8276d7c 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);