comparison src/video/windx5/SDL_dx5events.c @ 453:a6fa62b1be09

Updated for embedded Visual C++ 4.0
author Sam Lantinga <slouken@libsdl.org>
date Tue, 20 Aug 2002 00:20:06 +0000
parents 3d6dd1b7b7ba
children a8a0a4f19df7
comparison
equal deleted inserted replaced
452:4c5c10383201 453:a6fa62b1be09
41 41
42 #ifndef WM_APP 42 #ifndef WM_APP
43 #define WM_APP 0x8000 43 #define WM_APP 0x8000
44 #endif 44 #endif
45 45
46 #ifdef _WIN32_WCE
47 #define NO_GETKEYBOARDSTATE
48 #endif
49
46 /* The keyboard and mouse device input */ 50 /* The keyboard and mouse device input */
47 #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */ 51 #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */
48 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ 52 #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */
49 53
50 static LPDIRECTINPUT dinput = NULL; 54 static LPDIRECTINPUT dinput = NULL;
65 69
66 /* Convert a DirectInput return code to a text message */ 70 /* Convert a DirectInput return code to a text message */
67 static void SetDIerror(char *function, int code) 71 static void SetDIerror(char *function, int code)
68 { 72 {
69 static char *error; 73 static char *error;
70 static char errbuf[BUFSIZ]; 74 static char errbuf[1024];
71 75
72 errbuf[0] = 0; 76 errbuf[0] = 0;
73 switch (code) { 77 switch (code) {
74 case DIERR_GENERIC: 78 case DIERR_GENERIC:
75 error = "Undefined error!"; 79 error = "Undefined error!";
447 /* The main Win32 event handler */ 451 /* The main Win32 event handler */
448 LONG 452 LONG
449 DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 453 DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
450 { 454 {
451 switch (msg) { 455 switch (msg) {
456 #ifdef WM_ACTIVATEAPP
452 case WM_ACTIVATEAPP: { 457 case WM_ACTIVATEAPP: {
453 int i, active; 458 int i, active;
454 459
455 active = (wParam && (GetForegroundWindow() == hwnd)); 460 active = (wParam && (GetForegroundWindow() == hwnd));
456 if ( active ) { 461 if ( active ) {
465 } 470 }
466 mouse_lost = 1; 471 mouse_lost = 1;
467 } 472 }
468 } 473 }
469 break; 474 break;
470 475 #endif /* WM_ACTIVATEAPP */
476
477 #ifdef WM_DISPLAYCHANGE
471 case WM_DISPLAYCHANGE: { 478 case WM_DISPLAYCHANGE: {
472 WORD BitsPerPixel; 479 WORD BitsPerPixel;
473 WORD SizeX, SizeY; 480 WORD SizeX, SizeY;
474 481
475 /* Ack! The display changed size and/or depth! */ 482 /* Ack! The display changed size and/or depth! */
477 SizeY = HIWORD(lParam); 484 SizeY = HIWORD(lParam);
478 BitsPerPixel = wParam; 485 BitsPerPixel = wParam;
479 /* We cause this message when we go fullscreen */ 486 /* We cause this message when we go fullscreen */
480 } 487 }
481 break; 488 break;
489 #endif /* WM_DISPLAYCHANGE */
482 490
483 /* The keyboard is handled via DirectInput */ 491 /* The keyboard is handled via DirectInput */
484 case WM_SYSKEYUP: 492 case WM_SYSKEYUP:
485 case WM_SYSKEYDOWN: 493 case WM_SYSKEYDOWN:
486 case WM_KEYUP: 494 case WM_KEYUP:
487 case WM_KEYDOWN: { 495 case WM_KEYDOWN: {
488 /* Ignore windows keyboard messages */; 496 /* Ignore windows keyboard messages */;
489 } 497 }
490 return(0); 498 return(0);
491 499
500 #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
492 /* Don't allow screen savers or monitor power downs. 501 /* Don't allow screen savers or monitor power downs.
493 This is because they quietly clear DirectX surfaces. 502 This is because they quietly clear DirectX surfaces.
494 It would be better to allow the application to 503 It would be better to allow the application to
495 decide whether or not to blow these off, but the 504 decide whether or not to blow these off, but the
496 semantics of SDL_PrivateSysWMEvent() don't allow 505 semantics of SDL_PrivateSysWMEvent() don't allow
499 case WM_SYSCOMMAND: { 508 case WM_SYSCOMMAND: {
500 if ((wParam&0xFFF0)==SC_SCREENSAVE || 509 if ((wParam&0xFFF0)==SC_SCREENSAVE ||
501 (wParam&0xFFF0)==SC_MONITORPOWER) 510 (wParam&0xFFF0)==SC_MONITORPOWER)
502 return(0); 511 return(0);
503 } 512 }
504 goto custom_processing; 513 /* Fall through to default processing */
505 break; 514
515 #endif /* SC_SCREENSAVE || SC_MONITORPOWER */
506 516
507 default: { 517 default: {
508 custom_processing:
509 /* Only post the event if we're watching for it */ 518 /* Only post the event if we're watching for it */
510 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { 519 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
511 SDL_SysWMmsg wmmsg; 520 SDL_SysWMmsg wmmsg;
512 521
513 SDL_VERSION(&wmmsg.version); 522 SDL_VERSION(&wmmsg.version);
757 keysym->sym = DIK_keymap[scancode]; 766 keysym->sym = DIK_keymap[scancode];
758 keysym->mod = KMOD_NONE; 767 keysym->mod = KMOD_NONE;
759 keysym->unicode = 0; 768 keysym->unicode = 0;
760 if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ 769 if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
761 UINT vkey; 770 UINT vkey;
771 #ifndef NO_GETKEYBOARDSTATE
762 BYTE keystate[256]; 772 BYTE keystate[256];
763 BYTE chars[2]; 773 BYTE chars[2];
774 #endif
764 775
765 vkey = MapVirtualKey(scancode, 1); 776 vkey = MapVirtualKey(scancode, 1);
777 #ifdef NO_GETKEYBOARDSTATE
778 /* Uh oh, better hope the vkey is close enough.. */
779 keysym->unicode = vkey;
780 #else
766 GetKeyboardState(keystate); 781 GetKeyboardState(keystate);
767 if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { 782 if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
768 keysym->unicode = chars[0]; 783 keysym->unicode = chars[0];
769 } 784 }
785 #endif
770 } 786 }
771 return(keysym); 787 return(keysym);
772 } 788 }
773 789
774 int DX5_CreateWindow(_THIS) 790 int DX5_CreateWindow(_THIS)
780 SDL_DIdev[i] = NULL; 796 SDL_DIdev[i] = NULL;
781 SDL_DIevt[i] = NULL; 797 SDL_DIevt[i] = NULL;
782 SDL_DIfun[i] = NULL; 798 SDL_DIfun[i] = NULL;
783 } 799 }
784 800
785 /* Create the SDL window */ 801 #ifndef CS_BYTEALIGNCLIENT
802 #define CS_BYTEALIGNCLIENT 0
803 #endif
786 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); 804 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
787 if ( SDL_windowid ) { 805 if ( SDL_windowid ) {
788 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); 806 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
789 807
790 /* DJM: we want all event's for the user specified 808 /* DJM: we want all event's for the user specified