Fixups to sync WIP SDL refactor up with r4738. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@4753 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-11-22 12:34:46 +00:00
parent d73f7f113d
commit 52236d79a2
2 changed files with 22 additions and 14 deletions

View file

@ -1691,6 +1691,10 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
switch (ev->type) switch (ev->type)
{ {
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
#ifndef GEKKO
mouseabsx = ev->motion.x;
mouseabsy = ev->motion.y;
#endif
// SDL <VER> doesn't handle relative mouse movement correctly yet as the cursor still clips to the // SDL <VER> doesn't handle relative mouse movement correctly yet as the cursor still clips to the
// screen edges // screen edges
// so, we call SDL_WarpMouse() to center the cursor and ignore the resulting motion event that occurs // so, we call SDL_WarpMouse() to center the cursor and ignore the resulting motion event that occurs
@ -1706,8 +1710,6 @@ int32_t handleevents_sdlcommon(SDL_Event *ev)
#endif #endif
} }
} }
if (ev.active.state & SDL_APPMOUSEFOCUS)
mouseinwindow = ev.active.gain;
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
@ -1947,6 +1949,12 @@ int32_t handleevents_pollsdl(void)
windowy = ev.window.data2; windowy = ev.window.data2;
} }
break; break;
case SDL_WINDOWEVENT_ENTER:
mouseinwindow = 1;
break;
case SDL_WINDOWEVENT_LEAVE:
mouseinwindow = 0;
break;
} }
break; break;

View file

@ -514,25 +514,25 @@ int32_t handleevents_pollsdl(void)
grabmouse_low(!!appactive); grabmouse_low(!!appactive);
#endif #endif
rv = -1; rv = -1;
if (ev.active.state & SDL_APPMOUSEFOCUS)
mouseinwindow = ev.active.gain;
} }
break; break;
// SDL_MOUSEMOTION needs to fall through to default... this is just GEKKO processing! // SDL_MOUSEMOTION needs to fall through to default... this is just GEKKO processing!
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
#ifdef GEKKO #ifdef GEKKO
if (appactive && mousegrab) // check if it's a wiimote pointer pretending to be a mouse
if (ev.motion.state & SDL_BUTTON_X2MASK)
{ {
// check if it's a wiimote pointer pretending to be a mouse // the absolute values are used to draw the crosshair
if (ev.motion.state & SDL_BUTTON_X2MASK) mouseabsx = ev.motion.x;
{ mouseabsy = ev.motion.y;
// the absolute values are used to draw the crosshair // hack: reduce the scale of the "relative" motions
mouseabsx = ev.motion.x; // to make it act more like a real mouse
mouseabsy = ev.motion.y; ev.motion.xrel /= 16;
// hack: reduce the scale of the "relative" motions ev.motion.yrel /= 12;
// to make it act more like a real mouse
ev.motion.xrel /= 16;
ev.motion.yrel /= 12;
}
} }
#endif #endif
default: // OSD_Printf("Got event (%d)\n", ev.type); break; default: // OSD_Printf("Got event (%d)\n", ev.type); break;