mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-12 21:01:00 +00:00
sdl2: fix mouse motion (remove -mousewarp)
This commit is contained in:
parent
0d82e3b54b
commit
716aa1f33a
1 changed files with 6 additions and 26 deletions
|
@ -129,7 +129,6 @@ static Uint16 realheight = BASEVIDHEIGHT;
|
|||
static const Uint32 surfaceFlagsW = 0/*|SDL_RESIZABLE*/;
|
||||
static const Uint32 surfaceFlagsF = 0;
|
||||
static SDL_bool mousegrabok = SDL_TRUE;
|
||||
static SDL_bool mousewarp = SDL_FALSE;
|
||||
#define HalfWarpMouse(x,y) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2))
|
||||
static SDL_bool videoblitok = SDL_FALSE;
|
||||
static SDL_bool exposevideo = SDL_FALSE;
|
||||
|
@ -760,6 +759,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
kbfocus = SDL_TRUE;
|
||||
mousefocus = SDL_TRUE;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
kbfocus = SDL_FALSE;
|
||||
|
@ -800,7 +800,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
if (MOUSE_MENU)
|
||||
{
|
||||
SDLdoUngrabMouse();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,43 +831,26 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
|||
|
||||
SDL_GetWindowSize(window, &wwidth, &wheight);
|
||||
|
||||
if (MOUSE_MENU)
|
||||
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
|
||||
{
|
||||
SDLdoUngrabMouse();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mousewarp && (evt.x == wwidth/2) && (evt.y == wheight/2))
|
||||
if ((evt.x == realwidth/2) && (evt.y == realheight/2))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.data2 = +evt.xrel;
|
||||
event.data3 = -evt.yrel;
|
||||
event.data2 = (evt.xrel) * (wwidth / realwidth) * 2;
|
||||
event.data3 = -evt.yrel * (wheight / realheight) * 2;
|
||||
}
|
||||
|
||||
event.type = ev_mouse;
|
||||
D_PostEvent(&event);
|
||||
|
||||
if (mousewarp)
|
||||
{
|
||||
// Warp the pointer back to the middle of the window
|
||||
// or we cannot move any further if it's at a border.
|
||||
if ((evt.x < (wwidth/2 )-(wwidth/4 )) ||
|
||||
(evt.y < (wheight/2)-(wheight/4)) ||
|
||||
(evt.x > (wwidth/2 )+(wwidth/4 )) ||
|
||||
(evt.y > (wheight/2)+(wheight/4) ) )
|
||||
{
|
||||
HalfWarpMouse(wwidth, wheight);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetWindowGrab(window, mousegrabok);
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
}
|
||||
|
||||
HalfWarpMouse(wwidth, wheight);
|
||||
}
|
||||
|
||||
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
||||
|
@ -1902,8 +1884,6 @@ void I_StartupGraphics(void)
|
|||
|
||||
if (M_CheckParm("-nomousegrab"))
|
||||
mousegrabok = SDL_FALSE;
|
||||
else if (M_CheckParm("-mousewarp") || SDL_SetRelativeMouseMode(SDL_TRUE) == -1)
|
||||
mousewarp = SDL_TRUE;
|
||||
#if 0 // defined (_DEBUG)
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue