mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
sdl2: Fix mouse motion in fullscreen
This commit is contained in:
parent
1882cf9233
commit
ec559c84c1
1 changed files with 28 additions and 27 deletions
|
@ -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
|
// If the event is from warping the pointer back to middle
|
||||||
// of the screen then ignore it.
|
// of the screen then ignore it.
|
||||||
if ((evt.x == realwidth/2) &&
|
/*if (ignorenext || ((evt.x == wwidth/2) && (evt.y == wheight/2)))
|
||||||
(evt.y == realheight/2))
|
|
||||||
{
|
{
|
||||||
|
ignorenext = SDL_FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{*/
|
||||||
event.data2 = +evt.xrel;
|
event.data2 = +evt.xrel;
|
||||||
event.data3 = -evt.yrel;
|
event.data3 = -evt.yrel;
|
||||||
}
|
//}
|
||||||
event.type = ev_mouse;
|
event.type = ev_mouse;
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
// Warp the pointer back to the middle of the window
|
// Warp the pointer back to the middle of the window
|
||||||
// or we cannot move any further if it's at a border.
|
// or we cannot move any further if it's at a border.
|
||||||
if ((evt.x < (realwidth/2 )-(realwidth/4 )) ||
|
/*if ((evt.x < (wwidth/2 )-(wwidth/4 )) ||
|
||||||
(evt.y < (realheight/2)-(realheight/4)) ||
|
(evt.y < (wheight/2)-(wheight/4)) ||
|
||||||
(evt.x > (realwidth/2 )+(realwidth/4 )) ||
|
(evt.x > (wwidth/2 )+(wwidth/4 )) ||
|
||||||
(evt.y > (realheight/2)+(realheight/4) ) )
|
(evt.y > (wheight/2)+(wheight/4) ) )*/
|
||||||
{
|
{
|
||||||
//if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok)
|
//if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok)
|
||||||
SDL_SetWindowGrab(window, mousegrabok);
|
SDL_SetWindowGrab(window, mousegrabok);
|
||||||
HalfWarpMouse(realwidth, realheight);
|
//HalfWarpMouse(wwidth, wheight);
|
||||||
}
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue