Added a userdata parameter to SDL_SetWindowsMessageHook()
parent
b2be9253e3
commit
1c6ea0f226
|
@ -46,8 +46,8 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
\brief Set a function that is called for every windows message, before TranslateMessage()
|
\brief Set a function that is called for every windows message, before TranslateMessage()
|
||||||
*/
|
*/
|
||||||
typedef void (*SDL_WindowsMessageHook)(void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
|
typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
|
||||||
extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback);
|
extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Returns the D3D9 adapter index that matches the specified display index.
|
\brief Returns the D3D9 adapter index that matches the specified display index.
|
||||||
|
|
|
@ -625,5 +625,5 @@ SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
|
SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
|
||||||
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
|
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a),(a),)
|
SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -928,10 +928,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
/* A message hook called before TranslateMessage() */
|
/* A message hook called before TranslateMessage() */
|
||||||
static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
|
static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
|
||||||
|
static void *g_WindowsMessageHookData = NULL;
|
||||||
|
|
||||||
void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback)
|
void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
|
||||||
{
|
{
|
||||||
g_WindowsMessageHook = callback;
|
g_WindowsMessageHook = callback;
|
||||||
|
g_WindowsMessageHookData = userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -944,7 +946,7 @@ WIN_PumpEvents(_THIS)
|
||||||
if (g_WindowsEnableMessageLoop) {
|
if (g_WindowsEnableMessageLoop) {
|
||||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||||
if (g_WindowsMessageHook) {
|
if (g_WindowsMessageHook) {
|
||||||
g_WindowsMessageHook(msg.hwnd, msg.message, msg.wParam, msg.lParam);
|
g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
|
/* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
|
||||||
|
|
Loading…
Reference in New Issue