sdl2: Fix mouse motion in fullscreen

This commit is contained in:
Ronald Kinard 2014-04-06 22:36:47 -05:00
parent 1882cf9233
commit ec559c84c1
1 changed files with 28 additions and 27 deletions

View File

@ -822,38 +822,40 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
{ {
event_t event; event_t event;
int wwidth, wheight;
SDL_GetWindowSize(window, &wwidth, &wheight);
if (MOUSE_MENU) if (MOUSE_MENU)
{ {
SDLdoUngrabMouse(); SDLdoUngrabMouse();
return; return;
} }
//if (USE_MOUSEINPUT) TODO SDL2 stub // If the event is from warping the pointer back to middle
// of the screen then ignore it.
/*if (ignorenext || ((evt.x == wwidth/2) && (evt.y == wheight/2)))
{ {
// If the event is from warping the pointer back to middle ignorenext = SDL_FALSE;
// of the screen then ignore it. return;
if ((evt.x == realwidth/2) && }
(evt.y == realheight/2)) else
{ {*/
return; event.data2 = +evt.xrel;
} event.data3 = -evt.yrel;
else //}
{ event.type = ev_mouse;
event.data2 = +evt.xrel; D_PostEvent(&event);
event.data3 = -evt.yrel; // Warp the pointer back to the middle of the window
} // or we cannot move any further if it's at a border.
event.type = ev_mouse; /*if ((evt.x < (wwidth/2 )-(wwidth/4 )) ||
D_PostEvent(&event); (evt.y < (wheight/2)-(wheight/4)) ||
// Warp the pointer back to the middle of the window (evt.x > (wwidth/2 )+(wwidth/4 )) ||
// or we cannot move any further if it's at a border. (evt.y > (wheight/2)+(wheight/4) ) )*/
if ((evt.x < (realwidth/2 )-(realwidth/4 )) || {
(evt.y < (realheight/2)-(realheight/4)) || //if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok)
(evt.x > (realwidth/2 )+(realwidth/4 )) || SDL_SetWindowGrab(window, mousegrabok);
(evt.y > (realheight/2)+(realheight/4) ) ) //HalfWarpMouse(wwidth, wheight);
{ SDL_SetRelativeMouseMode(SDL_TRUE);
//if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok)
SDL_SetWindowGrab(window, mousegrabok);
HalfWarpMouse(realwidth, realheight);
}
} }
} }
@ -885,7 +887,6 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
event.data1 = KEY_MOUSE1 + evt.which - SDL_BUTTON_LEFT; event.data1 = KEY_MOUSE1 + evt.which - SDL_BUTTON_LEFT;
if (event.type == ev_keyup || event.type == ev_keydown) if (event.type == ev_keyup || event.type == ev_keydown)
{ {
CONS_Printf("Mouse button %d\n", evt.which);
D_PostEvent(&event); D_PostEvent(&event);
} }
} }