mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 04:11:18 +00:00
Revert "(Messiness warning) attempt to start using SDL_SetRelativeMouseMode instead of the old hacks of making the mouse do movement without leaving the window and be hidden"
This reverts commit 347b531881
.
(Too experimental, may end up adding new bugs; let's just keep it to clean up for now)
This commit is contained in:
parent
347b531881
commit
ae3e11369e
1 changed files with 14 additions and 52 deletions
|
@ -527,7 +527,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
|
|
||||||
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
{
|
{
|
||||||
//static SDL_bool firsttimeonmouse = SDL_TRUE;
|
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||||
static SDL_bool mousefocus = SDL_TRUE;
|
static SDL_bool mousefocus = SDL_TRUE;
|
||||||
static SDL_bool kbfocus = SDL_TRUE;
|
static SDL_bool kbfocus = SDL_TRUE;
|
||||||
|
|
||||||
|
@ -535,21 +535,17 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
mousefocus = SDL_TRUE;
|
mousefocus = SDL_TRUE;
|
||||||
//CONS_Printf("Window gained mouse focus!\n");
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_LEAVE:
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
mousefocus = SDL_FALSE;
|
mousefocus = SDL_FALSE;
|
||||||
//CONS_Printf("Window lost mouse focus!\n");
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
kbfocus = SDL_TRUE;
|
kbfocus = SDL_TRUE;
|
||||||
mousefocus = SDL_TRUE;
|
mousefocus = SDL_TRUE;
|
||||||
//CONS_Printf("Window gained keyboard focus!\n");
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
kbfocus = SDL_FALSE;
|
kbfocus = SDL_FALSE;
|
||||||
mousefocus = SDL_FALSE;
|
mousefocus = SDL_FALSE;
|
||||||
//CONS_Printf("Window lost keyboard focus!\n");
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
break;
|
break;
|
||||||
|
@ -562,14 +558,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
if (!paused)
|
if (!paused)
|
||||||
I_ResumeSong(0); //resume it
|
I_ResumeSong(0); //resume it
|
||||||
|
|
||||||
/*if (!firsttimeonmouse)
|
if (!firsttimeonmouse)
|
||||||
{
|
{
|
||||||
if (cv_usemouse.value) I_StartupMouse();
|
if (cv_usemouse.value) I_StartupMouse();
|
||||||
}
|
}
|
||||||
//else firsttimeonmouse = SDL_FALSE;
|
//else firsttimeonmouse = SDL_FALSE;
|
||||||
|
|
||||||
if (!disable_mouse && cv_usemouse.value)
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);*/
|
|
||||||
}
|
}
|
||||||
else if (!mousefocus && !kbfocus)
|
else if (!mousefocus && !kbfocus)
|
||||||
{
|
{
|
||||||
|
@ -577,34 +570,15 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
window_notinfocus = true;
|
window_notinfocus = true;
|
||||||
I_PauseSong(0);
|
I_PauseSong(0);
|
||||||
|
|
||||||
/*if (!disable_mouse)
|
if (!disable_mouse)
|
||||||
{
|
{
|
||||||
SDLforceUngrabMouse();
|
SDLforceUngrabMouse();
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
}
|
||||||
HalfWarpMouse(realwidth, realheight); // warp to center
|
|
||||||
}*/
|
|
||||||
memset(gamekeydown, 0, NUMKEYS); // TODO this is a scary memset
|
memset(gamekeydown, 0, NUMKEYS); // TODO this is a scary memset
|
||||||
|
|
||||||
/*if (MOUSE_MENU)
|
if (MOUSE_MENU)
|
||||||
{
|
{
|
||||||
SDLdoUngrabMouse();
|
SDLdoUngrabMouse();
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!disable_mouse)
|
|
||||||
{
|
|
||||||
if (mousefocus)
|
|
||||||
{
|
|
||||||
//if (cv_usemouse.value)
|
|
||||||
//SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SDL_GetRelativeMouseMode() == SDL_TRUE)
|
|
||||||
{
|
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
||||||
HalfWarpMouse(realwidth, realheight); // warp to center
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,15 +614,15 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
|
|
||||||
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
|
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
|
||||||
{
|
{
|
||||||
//SDLdoUngrabMouse();
|
SDLdoUngrabMouse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if ((evt.x == realwidth/2) && (evt.y == realheight/2))
|
if ((evt.x == realwidth/2) && (evt.y == realheight/2))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else*/
|
else
|
||||||
{
|
{
|
||||||
event.data2 = (INT32)lround((evt.xrel) * ((float)wwidth / (float)realwidth));
|
event.data2 = (INT32)lround((evt.xrel) * ((float)wwidth / (float)realwidth));
|
||||||
event.data3 = (INT32)lround(-evt.yrel * ((float)wheight / (float)realheight));
|
event.data3 = (INT32)lround(-evt.yrel * ((float)wheight / (float)realheight));
|
||||||
|
@ -658,13 +632,9 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
|
|
||||||
if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
|
if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
|
||||||
{
|
{
|
||||||
if (SDL_GetRelativeMouseMode() == SDL_FALSE)
|
D_PostEvent(&event);
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
SDL_SetWindowGrab(window, SDL_TRUE);
|
||||||
else
|
HalfWarpMouse(wwidth, wheight);
|
||||||
D_PostEvent(&event);
|
|
||||||
//SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
//SDL_SetWindowGrab(window, SDL_TRUE);
|
|
||||||
//HalfWarpMouse(wwidth, wheight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,18 +832,11 @@ void I_GetEvent(void)
|
||||||
|
|
||||||
void I_StartupMouse(void)
|
void I_StartupMouse(void)
|
||||||
{
|
{
|
||||||
//static SDL_bool firsttimeonmouse = SDL_TRUE;
|
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||||
|
|
||||||
if (disable_mouse)
|
if (disable_mouse)
|
||||||
return;
|
return;
|
||||||
if (cv_usemouse.value)
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
else if (SDL_GetRelativeMouseMode() == SDL_TRUE) {
|
|
||||||
SDLdoUngrabMouse();
|
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
||||||
HalfWarpMouse(realwidth, realheight); // warp to center
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if (!firsttimeonmouse)
|
if (!firsttimeonmouse)
|
||||||
HalfWarpMouse(realwidth, realheight); // warp to center
|
HalfWarpMouse(realwidth, realheight); // warp to center
|
||||||
else
|
else
|
||||||
|
@ -882,7 +845,6 @@ void I_StartupMouse(void)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
SDLdoUngrabMouse();
|
SDLdoUngrabMouse();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1508,7 +1470,7 @@ void I_StartupGraphics(void)
|
||||||
realheight = (Uint16)vid.height;
|
realheight = (Uint16)vid.height;
|
||||||
|
|
||||||
VID_Command_Info_f();
|
VID_Command_Info_f();
|
||||||
if (!disable_mouse) SDL_SetRelativeMouseMode(SDL_TRUE);
|
if (!disable_mouse) SDL_ShowCursor(SDL_DISABLE);
|
||||||
SDLdoUngrabMouse();
|
SDLdoUngrabMouse();
|
||||||
|
|
||||||
graphics_started = true;
|
graphics_started = true;
|
||||||
|
|
Loading…
Reference in a new issue