Commit f9e2e9d6 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Added support for WM_XBUTTON to the windib driver, to support more mouse

 buttons.

   Fixes Bugzilla #311.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402363
parent bacb6111
...@@ -74,6 +74,9 @@ SDL 1.2.12 is a minor bug fix release. ...@@ -74,6 +74,9 @@ SDL 1.2.12 is a minor bug fix release.
<H3> Windows Notes </H3> <H3> Windows Notes </H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>
The windib driver now supports more mouse buttons with WM_XBUTTON events.
</P>
<P> <P>
Added support for UTF-8 window titles on Windows. Added support for UTF-8 window titles on Windows.
</P> </P>
......
...@@ -24,6 +24,17 @@ ...@@ -24,6 +24,17 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
#ifndef WM_XBUTTONDOWN
#define WM_XBUTTONDOWN 0x020B
#endif
#ifndef WM_XBUTTONUP
#define WM_XBUTTONUP 0x020C
#endif
#ifndef GET_XBUTTON_WPARAM
#define GET_XBUTTON_WPARAM(w) (HIWORD(w))
#endif
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_syswm.h" #include "SDL_syswm.h"
...@@ -466,9 +477,12 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -466,9 +477,12 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONUP: { case WM_RBUTTONUP:
case WM_XBUTTONDOWN:
case WM_XBUTTONUP: {
/* Mouse is handled by DirectInput when fullscreen */ /* Mouse is handled by DirectInput when fullscreen */
if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) {
WORD xbuttonval = 0;
Sint16 x, y; Sint16 x, y;
Uint8 button, state; Uint8 button, state;
...@@ -505,6 +519,16 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -505,6 +519,16 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
button = SDL_BUTTON_RIGHT; button = SDL_BUTTON_RIGHT;
state = SDL_RELEASED; state = SDL_RELEASED;
break; break;
case WM_XBUTTONDOWN:
xbuttonval = GET_XBUTTON_WPARAM(wParam);
button = SDL_BUTTON_WHEELDOWN + xbuttonval;
state = SDL_PRESSED;
break;
case WM_XBUTTONUP:
xbuttonval = GET_XBUTTON_WPARAM(wParam);
button = SDL_BUTTON_WHEELDOWN + xbuttonval;
state = SDL_RELEASED;
break;
default: default:
/* Eh? Unknown button? */ /* Eh? Unknown button? */
return(0); return(0);
...@@ -535,6 +559,19 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -535,6 +559,19 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
posted = SDL_PrivateMouseButton( posted = SDL_PrivateMouseButton(
state, button, x, y); state, button, x, y);
/*
* MSDN says:
* "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP
* messages, an application should return TRUE from [an
* XBUTTON message] if it processes it. Doing so will allow
* software that simulates this message on Microsoft Windows
* systems earlier than Windows 2000 to determine whether
* the window procedure processed the message or called
* DefWindowProc to process it.
*/
if (xbuttonval > 0)
return(TRUE);
} }
} }
return(0); return(0);
......
...@@ -525,8 +525,8 @@ char *wmtab[] = { ...@@ -525,8 +525,8 @@ char *wmtab[] = {
"WM_MBUTTONUP", "WM_MBUTTONUP",
"WM_MOUSELAST", "WM_MOUSELAST",
"WM_MOUSELAST", "WM_MOUSELAST",
"UNKNOWN (523)", "WM_XBUTTONDOWN",
"UNKNOWN (524)", "WM_XBUTTONUP",
"UNKNOWN (525)", "UNKNOWN (525)",
"UNKNOWN (526)", "UNKNOWN (526)",
"UNKNOWN (527)", "UNKNOWN (527)",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment