Implement Windows GetAbsoluteMouseState().
authorRyan C. Gordon <icculus@icculus.org>
Wed, 11 Jun 2014 00:12:19 -0400
changeset 895066b11e777d54
parent 8949 9738e8208dd5
child 8951 692ba71b9c04
Implement Windows GetAbsoluteMouseState().
src/video/windows/SDL_windowsmouse.c
     1.1 --- a/src/video/windows/SDL_windowsmouse.c	Wed Jun 11 00:12:06 2014 -0400
     1.2 +++ b/src/video/windows/SDL_windowsmouse.c	Wed Jun 11 00:12:19 2014 -0400
     1.3 @@ -260,6 +260,24 @@
     1.4      return ToggleRawInput(window != NULL);
     1.5  }
     1.6  
     1.7 +static Uint32
     1.8 +WIN_GetAbsoluteMouseState(int *x, int *y)
     1.9 +{
    1.10 +    Uint32 retval = 0;
    1.11 +    POINT pt = { 0, 0 };
    1.12 +    GetCursorPos(&pt);
    1.13 +    *x = (int) pt.x;
    1.14 +    *y = (int) pt.y;
    1.15 +
    1.16 +    retval |= GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_BUTTON_LMASK : 0;
    1.17 +    retval |= GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_BUTTON_RMASK : 0;
    1.18 +    retval |= GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_BUTTON_MMASK : 0;
    1.19 +    retval |= GetAsyncKeyState(VK_X1BUTTON) & 0x8000 ? SDL_BUTTON_X1MASK : 0;
    1.20 +    retval |= GetAsyncKeyState(VK_X2BUTTON) & 0x8000 ? SDL_BUTTON_X2MASK : 0;
    1.21 +
    1.22 +    return retval;
    1.23 +}
    1.24 +
    1.25  void
    1.26  WIN_InitMouse(_THIS)
    1.27  {
    1.28 @@ -272,6 +290,7 @@
    1.29      mouse->WarpMouse = WIN_WarpMouse;
    1.30      mouse->SetRelativeMouseMode = WIN_SetRelativeMouseMode;
    1.31      mouse->CaptureMouse = WIN_CaptureMouse;
    1.32 +    mouse->GetAbsoluteMouseState = WIN_GetAbsoluteMouseState;
    1.33  
    1.34      SDL_SetDefaultCursor(WIN_CreateDefaultCursor());
    1.35