Mercurial > sdl-ios-xcode
diff src/video/win32/SDL_win32window.c @ 2580:64fa227c01ce gsoc2008_force_feedback
Added the concept of the HelperWindow to help with DirectInput.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Mon, 04 Aug 2008 11:22:01 +0000 |
parents | ba0d62354872 |
children | a1c00531ee00 |
line wrap: on
line diff
--- a/src/video/win32/SDL_win32window.c Sun Aug 03 10:25:25 2008 +0000 +++ b/src/video/win32/SDL_win32window.c Mon Aug 04 11:22:01 2008 +0000 @@ -30,6 +30,10 @@ #include "SDL_syswm.h" +/* Fake window to help with DirectInput events. */ +HWND SDL_HelperWindow = NULL; + + static int SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) { @@ -409,4 +413,48 @@ } } + +/* + * Creates a HelperWindow used for DirectInput events. + */ +int +SDL_HelperWindowCreate(void) +{ + HINSTANCE hInstance = pGetModuleHandleA(NULL); + const char *class_name = "SDLHelperWindowInputCatcher"; + const char *win_name = "SDLHelperWindowInputMsgWindow"; + WNDCLASSEX wce; + + ZeroMemory(&wce, sizeof (wce)); + wce.cbSize = sizeof(WNDCLASSEX); + wce.lpfnWndProc = RawWndProc; + wce.lpszClassName = class_name; + wce.hInstance = hInstance; + + SDL_HelperWindow = pCreateWindowExA(0, class_name, win_name, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL); + + if (SDL_HelperWindow == NULL) { + SDL_SetError("Unable to create Helper Window."); + return -1; + } + + return 0; +} + + +/* + * Destroys the HelperWindow previously created with SDL_HelperWindowCreate. + */ +void +SDL_HelperWindowDestroy(void) +{ + if (SDL_HelperWindow) { + pDestroyWindow(SDL_HelperWindow); + SDL_HelperWindow = NULL; + } +} + + /* vi: set ts=4 sw=4 expandtab: */