comparison src/video/win32/SDL_win32window.c @ 2713:0906692aa6a4

Final merge of Google Summer of Code 2008 work... Force Feedback for SDL by Edgar Simo, mentored by Ryan C. Gordon
author Sam Lantinga <slouken@libsdl.org>
date Mon, 25 Aug 2008 09:55:03 +0000
parents 44e49d3fa6cf
children 1d1be6137875
comparison
equal deleted inserted replaced
2712:c4e697245676 2713:0906692aa6a4
44 #define PACKETMODE 0 44 #define PACKETMODE 0
45 #include <pktdef.h> 45 #include <pktdef.h>
46 46
47 extern HCTX *g_hCtx; /* the table of tablet event contexts, each windows has to have it's own tablet context */ 47 extern HCTX *g_hCtx; /* the table of tablet event contexts, each windows has to have it's own tablet context */
48 int highestId = 0; /* the highest id of the tablet context */ 48 int highestId = 0; /* the highest id of the tablet context */
49
50 /* Fake window to help with DirectInput events. */
51 HWND SDL_HelperWindow = NULL;
52 static const char *SDL_HelperWindowClassName = "SDLHelperWindowInputCatcher";
53 static const char *SDL_HelperWindowName = "SDLHelperWindowInputMsgWindow";
54 static ATOM SDL_HelperWindowClass = 0;
49 55
50 static int 56 static int
51 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) 57 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
52 { 58 {
53 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 59 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
468 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); 474 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
469 return SDL_FALSE; 475 return SDL_FALSE;
470 } 476 }
471 } 477 }
472 478
479
480 /*
481 * Creates a HelperWindow used for DirectInput events.
482 */
483 int
484 SDL_HelperWindowCreate(void)
485 {
486 HINSTANCE hInstance = GetModuleHandleA(NULL);
487 WNDCLASSEX wce;
488
489 /* Create the class. */
490 SDL_memset(&wce, 0, sizeof(wce));
491 wce.cbSize = sizeof(WNDCLASSEX);
492 wce.lpfnWndProc = DefWindowProcA;
493 wce.lpszClassName = (LPCWSTR) SDL_HelperWindowClassName;
494 wce.hInstance = hInstance;
495
496 /* Register the class. */
497 SDL_HelperWindowClass = RegisterClassExA(&wce);
498 if (SDL_HelperWindowClass == 0) {
499 SDL_SetError("Unable to create Helper Window Class: error %d.",
500 GetLastError());
501 return -1;
502 }
503
504 /* Create the window. */
505 SDL_HelperWindow = CreateWindowExA(0, SDL_HelperWindowClassName,
506 SDL_HelperWindowName,
507 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
508 CW_USEDEFAULT, CW_USEDEFAULT,
509 CW_USEDEFAULT, HWND_MESSAGE, NULL,
510 hInstance, NULL);
511 if (SDL_HelperWindow == NULL) {
512 SDL_SetError("Unable to create Helper Window: error %d.",
513 GetLastError());
514 return -1;
515 }
516
517 return 0;
518 }
519
520
521 /*
522 * Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
523 */
524 void
525 SDL_HelperWindowDestroy(void)
526 {
527 /* Destroy the window. */
528 if (SDL_HelperWindow) {
529 DestroyWindow(SDL_HelperWindow);
530 SDL_HelperWindow = NULL;
531 }
532
533 /* Unregister the class. */
534 if (SDL_HelperWindowClass) {
535 UnregisterClassA(SDL_HelperWindowClassName, GetModuleHandleA(NULL));
536 SDL_HelperWindowClass = 0;
537 }
538 }
539
540
473 /* vi: set ts=4 sw=4 expandtab: */ 541 /* vi: set ts=4 sw=4 expandtab: */