comparison src/video/win32/SDL_win32events.c @ 2127:3bcc26b74e42

Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 16 Jun 2007 05:29:28 +0000
parents 7177581dc9fa
children 3ee59c43d784
comparison
equal deleted inserted replaced
2126:9c9c49b18693 2127:3bcc26b74e42
34 34
35 /* Masks for processing the windows KEYDOWN and KEYUP messages */ 35 /* Masks for processing the windows KEYDOWN and KEYUP messages */
36 #define REPEATED_KEYMASK (1<<30) 36 #define REPEATED_KEYMASK (1<<30)
37 #define EXTENDED_KEYMASK (1<<24) 37 #define EXTENDED_KEYMASK (1<<24)
38 38
39 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
40 #ifndef WM_XBUTTONDOWN
41 #define WM_XBUTTONDOWN 0x020B
42 #endif
43 #ifndef WM_XBUTTONUP
44 #define WM_XBUTTONUP 0x020C
45 #endif
46 #ifndef GET_XBUTTON_WPARAM
47 #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
48 #endif
39 49
40 static SDLKey 50 static SDLKey
41 TranslateKey(WPARAM vkey) 51 TranslateKey(WPARAM vkey)
42 { 52 {
43 SDLKey key; 53 SDLKey key;
532 case WM_LBUTTONUP: 542 case WM_LBUTTONUP:
533 case WM_MBUTTONDOWN: 543 case WM_MBUTTONDOWN:
534 case WM_MBUTTONUP: 544 case WM_MBUTTONUP:
535 case WM_RBUTTONDOWN: 545 case WM_RBUTTONDOWN:
536 case WM_RBUTTONUP: 546 case WM_RBUTTONUP:
537 { 547 case WM_XBUTTONDOWN:
548 case WM_XBUTTONUP:
549 {
550 int xbuttonval = 0;
538 int index; 551 int index;
539 SDL_Mouse *mouse; 552 SDL_Mouse *mouse;
540 Uint8 button, state; 553 Uint8 button, state;
541 554
542 /* DJM: 555 /* DJM:
571 button = SDL_BUTTON_RIGHT; 584 button = SDL_BUTTON_RIGHT;
572 state = SDL_PRESSED; 585 state = SDL_PRESSED;
573 break; 586 break;
574 case WM_RBUTTONUP: 587 case WM_RBUTTONUP:
575 button = SDL_BUTTON_RIGHT; 588 button = SDL_BUTTON_RIGHT;
589 state = SDL_RELEASED;
590 break;
591 case WM_XBUTTONDOWN:
592 xbuttonval = GET_XBUTTON_WPARAM(wParam);
593 button = SDL_BUTTON_WHEELDOWN + xbuttonval;
594 state = SDL_PRESSED;
595 break;
596 case WM_XBUTTONUP:
597 xbuttonval = GET_XBUTTON_WPARAM(wParam);
598 button = SDL_BUTTON_WHEELDOWN + xbuttonval;
576 state = SDL_RELEASED; 599 state = SDL_RELEASED;
577 break; 600 break;
578 default: 601 default:
579 /* Eh? Unknown button? */ 602 /* Eh? Unknown button? */
580 return (0); 603 return (0);
597 x = LOWORD(lParam); 620 x = LOWORD(lParam);
598 y = HIWORD(lParam); 621 y = HIWORD(lParam);
599 SDL_SendMouseMotion(index, 0, x, y); 622 SDL_SendMouseMotion(index, 0, x, y);
600 } 623 }
601 SDL_SendMouseButton(index, state, button); 624 SDL_SendMouseButton(index, state, button);
625
626 /*
627 * MSDN says:
628 * "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP
629 * messages, an application should return TRUE from [an
630 * XBUTTON message] if it processes it. Doing so will allow
631 * software that simulates this message on Microsoft Windows
632 * systems earlier than Windows 2000 to determine whether
633 * the window procedure processed the message or called
634 * DefWindowProc to process it.
635 */
636 if (xbuttonval > 0) {
637 return(TRUE);
638 }
602 } 639 }
603 return (0); 640 return (0);
604 641
605 case WM_MOUSEWHEEL: 642 case WM_MOUSEWHEEL:
606 { 643 {