mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Adds command line parameter -mousewarp to control the use of warping in place of grabbing. Works around bugs in certain versions of X.
This commit is contained in:
parent
025523f3e3
commit
c206d55568
1 changed files with 20 additions and 33 deletions
|
@ -132,6 +132,7 @@ static Uint16 realheight = BASEVIDHEIGHT;
|
||||||
static const Uint32 surfaceFlagsW = 0/*|SDL_RESIZABLE*/;
|
static const Uint32 surfaceFlagsW = 0/*|SDL_RESIZABLE*/;
|
||||||
static const Uint32 surfaceFlagsF = 0;
|
static const Uint32 surfaceFlagsF = 0;
|
||||||
static SDL_bool mousegrabok = SDL_TRUE;
|
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))
|
#define HalfWarpMouse(x,y) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2))
|
||||||
static SDL_bool videoblitok = SDL_FALSE;
|
static SDL_bool videoblitok = SDL_FALSE;
|
||||||
static SDL_bool exposevideo = SDL_FALSE;
|
static SDL_bool exposevideo = SDL_FALSE;
|
||||||
|
@ -832,30 +833,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If LINUX64 is defined, LINUX isn't defined. This code or another
|
if (mousewarp && (evt.x == wwidth/2) && (evt.y == wheight/2))
|
||||||
// fix needs to be put in a more proper spot.
|
|
||||||
#ifdef LINUX64
|
|
||||||
#ifndef LINUX
|
|
||||||
#define LINUX 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LINUX
|
|
||||||
// On most systems, grab the mouse and use relative input.
|
|
||||||
event.data2 = +evt.xrel;
|
|
||||||
event.data3 = -evt.yrel;
|
|
||||||
event.type = ev_mouse;
|
|
||||||
D_PostEvent(&event);
|
|
||||||
SDL_SetWindowGrab(window, mousegrabok);
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
#else
|
|
||||||
// On Linux, SDL_SetWindowGrab is bugged and will also grab keyboard
|
|
||||||
// input, which breaks alt-tabbing. Instead, we're warping the
|
|
||||||
// mouse as a workaround.
|
|
||||||
|
|
||||||
// If the event is from warping the pointer back to middle
|
|
||||||
// of the screen then ignore it.
|
|
||||||
if (((evt.x == wwidth/2) && (evt.y == wheight/2)))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -864,8 +842,11 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
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);
|
||||||
|
|
||||||
|
if (mousewarp){
|
||||||
// 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 < (wwidth/2 )-(wwidth/4 )) ||
|
if ((evt.x < (wwidth/2 )-(wwidth/4 )) ||
|
||||||
|
@ -875,7 +856,10 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
{
|
{
|
||||||
HalfWarpMouse(wwidth, wheight);
|
HalfWarpMouse(wwidth, wheight);
|
||||||
}
|
}
|
||||||
#endif
|
} else {
|
||||||
|
SDL_SetWindowGrab(window, mousegrabok);
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2110,6 +2094,9 @@ void I_StartupGraphics(void)
|
||||||
}
|
}
|
||||||
if (M_CheckParm("-nomousegrab"))
|
if (M_CheckParm("-nomousegrab"))
|
||||||
mousegrabok = SDL_FALSE;
|
mousegrabok = SDL_FALSE;
|
||||||
|
else if (M_CheckParm("-mousewarp")){
|
||||||
|
mousewarp = SDL_TRUE;
|
||||||
|
}
|
||||||
#if 0 // defined (_DEBUG)
|
#if 0 // defined (_DEBUG)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue