Merge remote-tracking branch 'ilag11111/sdl2' into sdl2

Conflicts:
	src/sdl2/i_video.c
This commit is contained in:
Alam Ed Arias 2014-04-09 19:47:11 -04:00
commit 2005421a7e
1 changed files with 24 additions and 18 deletions

View File

@ -134,6 +134,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;
@ -842,32 +843,35 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
SDLdoUngrabMouse(); SDLdoUngrabMouse();
return; return;
} }
// If the event is from warping the pointer back to middle
// of the screen then ignore it. if (mousewarp && (evt.x == wwidth/2) && (evt.y == wheight/2))
/*if (ignorenext || ((evt.x == wwidth/2) && (evt.y == wheight/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
// or we cannot move any further if it's at a border. if (mousewarp){
/*if ((evt.x < (wwidth/2 )-(wwidth/4 )) || // Warp the pointer back to the middle of the window
(evt.y < (wheight/2)-(wheight/4)) || // or we cannot move any further if it's at a border.
(evt.x > (wwidth/2 )+(wwidth/4 )) || if ((evt.x < (wwidth/2 )-(wwidth/4 )) ||
(evt.y > (wheight/2)+(wheight/4) ) )*/ (evt.y < (wheight/2)-(wheight/4)) ||
{ (evt.x > (wwidth/2 )+(wwidth/4 )) ||
//if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok) (evt.y > (wheight/2)+(wheight/4) ) )
{
HalfWarpMouse(wwidth, wheight);
}
} else {
SDL_SetWindowGrab(window, mousegrabok); SDL_SetWindowGrab(window, mousegrabok);
//HalfWarpMouse(wwidth, wheight);
SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetRelativeMouseMode(SDL_TRUE);
} }
} }
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
@ -1983,6 +1987,8 @@ void I_StartupGraphics(void)
} }
if (M_CheckParm("-nomousegrab")) if (M_CheckParm("-nomousegrab"))
mousegrabok = SDL_FALSE; mousegrabok = SDL_FALSE;
else if (M_CheckParm("-mousewarp") || SDL_SetRelativeMouseMode(SDL_TRUE) == -1)
mousewarp = SDL_TRUE;
#if 1 // defined (_DEBUG) #if 1 // defined (_DEBUG)
else else
{ {
@ -1990,7 +1996,7 @@ void I_StartupGraphics(void)
if (!M_CheckParm("-mousegrab") && if (!M_CheckParm("-mousegrab") &&
*strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0' && *strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0' &&
strncasecmp("x11",videodriver,4) == 0 && strncasecmp("x11",videodriver,4) == 0 &&
SDL_SetRelativeMouseMode(1) == -1) SDL_SetRelativeMouseMode(SDL_TRUE) == -1)
mousegrabok = SDL_FALSE; //X11's XGrabPointer not good mousegrabok = SDL_FALSE; //X11's XGrabPointer not good
} }
#endif #endif