Right mouse button event

After updating SDL to latest repository revision application no longer gets events on right (or middle) button down/up events. Is this a bug or just me doing something wrong with new code?

And many thanks for fixing full screen.

Jcw87 wrote:

Alot of things regarding the mouse are broken in the newest revision, including right and middle mouse buttons, mouse wheel, and the mouse focus window flag. I just use revision 4464, since it’s the one right before a major change in mouse functionality, and it works for me.

Many thanks on revision info, problem is that older revisions do not create window properly. On some machines window can’t be created at all with SetProp() error and full screen can’t be set on any.

Still, it is strategy game and without right mouse button and scroll I am totally blocked. Thanks again.

I am also curious about such major change, is there any official word
about this?

  • JiangOn Fri, Aug 13, 2010 at 11:11 AM, hardcoder wrote:

Jcw87 wrote:

Alot of things regarding the mouse are broken in the newest revision, including right and middle mouse buttons, mouse wheel, and the mouse focus window flag. I just use revision 4464, since it’s the one right before a major change in mouse functionality, and it works for me.

Jcw87 wrote:

I just use revision 4464, since it’s the one right before a major change in mouse functionality, and it works for me.

I’m using 4633, mouse buttons and wheel work for me.

zaphod wrote:

Jcw87 wrote:

I just use revision 4464, since it’s the one right before a major change in mouse functionality, and it works for me.

I’m using 4633, mouse buttons and wheel work for me.

The only mouse events I’m getting in that revision are mouse motion and left button. What platform are you using? I’m using Windows.

I decided to take a look at what was wrong, and sure enough, it looks like a Windows only issue. When multi-mouse support was removed, the mouse event handlers were replaced with the ones being used for WinCE, which only had events for mouse motion and left button. I made a patch that adds handlers for middle and right buttons, mouse wheel, and x buttons.

Code:

diff -r 0a07d002f10b -r d798b3b114b5 src/video/win32/SDL_win32events.c
— a/src/video/win32/SDL_win32events.c Sat Aug 14 12:28:43 2010 -0700
+++ b/src/video/win32/SDL_win32events.c Sun Aug 15 04:04:07 2010 -0700
@@ -211,6 +211,40 @@
SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_LEFT);
break;

  • case WM_RBUTTONDOWN:
  •    SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_RIGHT);
    
  •    break;+
    
  • case WM_RBUTTONUP:
  •    SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_RIGHT);
    
  •    break;
    
  • case WM_MBUTTONDOWN:
  •    SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_MIDDLE);
    
  •    break;
    
  • case WM_MBUTTONUP:
  •    SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_MIDDLE);
    
  •    break;
    
  • case WM_XBUTTONDOWN:
  •    SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1);
    
  •    returnCode = TRUE;
    
  •    break;
    
  • case WM_XBUTTONUP:
  •    SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1);
    
  •    returnCode = TRUE;
    
  •    break;
    
  • case WM_MOUSEWHEEL:
  •    {
    
  •        int motion = (short) HIWORD(wParam);
    
  •        SDL_SendMouseWheel(data->window, 0, motion);
    
  •        break;
    
  •    }
    
  • case WM_MOUSELEAVE:
    if (SDL_GetMouseFocus() == data->window) {
    SDL_SetMouseFocus(NULL);

I have no idea if the mouse wheel and x button stuff is “correct,” I just used what I observed from earlier revisions.

I’m using linux and windows. I just did a quick windows build and yes, on
windows(32) only the left button works, on linux all of them. After a quick
look at the source, it seems to me that the respective event handlers are
simply missing, the patch brought them back. Or maybe this was on purpose,
to give the windows users the old school apple-feeling (only one mouse
button and all that) :wink:

bw,
Martin

Could this patch be pushed to repo?

Jcw87 wrote:> I decided to take a look at what was wrong, and sure enough, it looks like a Windows only issue. When multi-mouse support was removed, the mouse event handlers were replaced with the ones being used for WinCE, which only had events for mouse motion and left button. I made a patch that adds handlers for middle and right buttons, mouse wheel, and x buttons.

Code:

diff -r 0a07d002f10b -r d798b3b114b5 src/video/win32/SDL_win32events.c
— a/src/video/win32/SDL_win32events.c Sat Aug 14 12:28:43 2010 -0700
+++ b/src/video/win32/SDL_win32events.c Sun Aug 15 04:04:07 2010 -0700
@@ -211,6 +211,40 @@
SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_LEFT);
break;

  • case WM_RBUTTONDOWN:
  •    SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_RIGHT);
    
  •    break;
    
  • case WM_RBUTTONUP:
  •    SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_RIGHT);
    
  •    break;
    
  • case WM_MBUTTONDOWN:
  •    SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_MIDDLE);
    
  •    break;
    
  • case WM_MBUTTONUP:
  •    SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_MIDDLE);
    
  •    break;
    
  • case WM_XBUTTONDOWN:
  •    SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1);
    
  •    returnCode = TRUE;
    
  •    break;
    
  • case WM_XBUTTONUP:
  •    SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1);
    
  •    returnCode = TRUE;
    
  •    break;
    
  • case WM_MOUSEWHEEL:
  •    {
    
  •        int motion = (short) HIWORD(wParam);
    
  •        SDL_SendMouseWheel(data->window, 0, motion);
    
  •        break;
    
  •    }
    
  • case WM_MOUSELEAVE:
    if (SDL_GetMouseFocus() == data->window) {
    SDL_SetMouseFocus(NULL);

I have no idea if the mouse wheel and x button stuff is “correct,” I just used what I observed from earlier revisions.