Added support for WM_XBUTTON to the windib driver, to support more mouse SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sat, 16 Jun 2007 05:10:47 +0000
branchSDL-1.2
changeset 3970203695f768e0
parent 3969 e6112676c9a0
child 3971 aea2f9cd5b8e
Added support for WM_XBUTTON to the windib driver, to support more mouse
buttons.

Fixes Bugzilla #311.
docs.html
src/video/wincommon/SDL_sysevents.c
src/video/wincommon/wmmsg.h
     1.1 --- a/docs.html	Fri Jun 15 15:52:04 2007 +0000
     1.2 +++ b/docs.html	Sat Jun 16 05:10:47 2007 +0000
     1.3 @@ -75,6 +75,9 @@
     1.4  
     1.5  <BLOCKQUOTE>
     1.6  <P>
     1.7 +	The windib driver now supports more mouse buttons with WM_XBUTTON events.
     1.8 +</P>
     1.9 +<P>
    1.10  	Added support for UTF-8 window titles on Windows.
    1.11  </P>
    1.12  <P>
     2.1 --- a/src/video/wincommon/SDL_sysevents.c	Fri Jun 15 15:52:04 2007 +0000
     2.2 +++ b/src/video/wincommon/SDL_sysevents.c	Sat Jun 16 05:10:47 2007 +0000
     2.3 @@ -24,6 +24,17 @@
     2.4  #define WIN32_LEAN_AND_MEAN
     2.5  #include <windows.h>
     2.6  
     2.7 +/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
     2.8 +#ifndef WM_XBUTTONDOWN
     2.9 +#define WM_XBUTTONDOWN 0x020B
    2.10 +#endif
    2.11 +#ifndef WM_XBUTTONUP
    2.12 +#define WM_XBUTTONUP 0x020C
    2.13 +#endif
    2.14 +#ifndef GET_XBUTTON_WPARAM
    2.15 +#define GET_XBUTTON_WPARAM(w) (HIWORD(w))
    2.16 +#endif
    2.17 +
    2.18  #include "SDL_events.h"
    2.19  #include "SDL_video.h"
    2.20  #include "SDL_syswm.h"
    2.21 @@ -466,9 +477,12 @@
    2.22  		case WM_MBUTTONDOWN:
    2.23  		case WM_MBUTTONUP:
    2.24  		case WM_RBUTTONDOWN:
    2.25 -		case WM_RBUTTONUP: {
    2.26 +		case WM_RBUTTONUP:
    2.27 +		case WM_XBUTTONDOWN:
    2.28 +		case WM_XBUTTONUP: {
    2.29  			/* Mouse is handled by DirectInput when fullscreen */
    2.30  			if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) {
    2.31 +				WORD xbuttonval = 0;
    2.32  				Sint16 x, y;
    2.33  				Uint8 button, state;
    2.34  
    2.35 @@ -505,6 +519,16 @@
    2.36  						button = SDL_BUTTON_RIGHT;
    2.37  						state = SDL_RELEASED;
    2.38  						break;
    2.39 +					case WM_XBUTTONDOWN:
    2.40 +						xbuttonval = GET_XBUTTON_WPARAM(wParam);
    2.41 +						button = SDL_BUTTON_WHEELDOWN + xbuttonval;
    2.42 +						state = SDL_PRESSED;
    2.43 +						break;
    2.44 +					case WM_XBUTTONUP:
    2.45 +						xbuttonval = GET_XBUTTON_WPARAM(wParam);
    2.46 +						button = SDL_BUTTON_WHEELDOWN + xbuttonval;
    2.47 +						state = SDL_RELEASED;
    2.48 +						break;
    2.49  					default:
    2.50  						/* Eh? Unknown button? */
    2.51  						return(0);
    2.52 @@ -535,6 +559,19 @@
    2.53  				}
    2.54  				posted = SDL_PrivateMouseButton(
    2.55  							state, button, x, y);
    2.56 +
    2.57 +				/*
    2.58 +				 * MSDN says:
    2.59 +				 *  "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP
    2.60 +				 *   messages, an application should return TRUE from [an 
    2.61 +				 *   XBUTTON message] if it processes it. Doing so will allow
    2.62 +				 *   software that simulates this message on Microsoft Windows
    2.63 +				 *   systems earlier than Windows 2000 to determine whether
    2.64 +				 *   the window procedure processed the message or called
    2.65 +				 *   DefWindowProc to process it.
    2.66 +				 */
    2.67 +				if (xbuttonval > 0)
    2.68 +					return(TRUE);
    2.69  			}
    2.70  		}
    2.71  		return(0);
     3.1 --- a/src/video/wincommon/wmmsg.h	Fri Jun 15 15:52:04 2007 +0000
     3.2 +++ b/src/video/wincommon/wmmsg.h	Sat Jun 16 05:10:47 2007 +0000
     3.3 @@ -525,8 +525,8 @@
     3.4  	"WM_MBUTTONUP",
     3.5  	"WM_MOUSELAST",
     3.6  	"WM_MOUSELAST",
     3.7 -	"UNKNOWN (523)",
     3.8 -	"UNKNOWN (524)",
     3.9 +	"WM_XBUTTONDOWN",
    3.10 +	"WM_XBUTTONUP",
    3.11  	"UNKNOWN (525)",
    3.12  	"UNKNOWN (526)",
    3.13  	"UNKNOWN (527)",