From 52236d79a2fdfa625943ae21b8c3aaab20f2436e Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 22 Nov 2014 12:34:46 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/src/sdlayer.c | 12 ++++++++++-- polymer/eduke32/build/src/sdlayer12.c | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 5fd927b5b..1fcb5d60e 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1691,6 +1691,10 @@ int32_t handleevents_sdlcommon(SDL_Event *ev) switch (ev->type) { case SDL_MOUSEMOTION: +#ifndef GEKKO + mouseabsx = ev->motion.x; + mouseabsy = ev->motion.y; +#endif // SDL doesn't handle relative mouse movement correctly yet as the cursor still clips to the // screen edges // 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 } } - if (ev.active.state & SDL_APPMOUSEFOCUS) - mouseinwindow = ev.active.gain; break; case SDL_MOUSEBUTTONDOWN: @@ -1947,6 +1949,12 @@ int32_t handleevents_pollsdl(void) windowy = ev.window.data2; } break; + case SDL_WINDOWEVENT_ENTER: + mouseinwindow = 1; + break; + case SDL_WINDOWEVENT_LEAVE: + mouseinwindow = 0; + break; } break; diff --git a/polymer/eduke32/build/src/sdlayer12.c b/polymer/eduke32/build/src/sdlayer12.c index b42cbcf96..721c176f0 100644 --- a/polymer/eduke32/build/src/sdlayer12.c +++ b/polymer/eduke32/build/src/sdlayer12.c @@ -514,25 +514,25 @@ int32_t handleevents_pollsdl(void) grabmouse_low(!!appactive); #endif rv = -1; + + if (ev.active.state & SDL_APPMOUSEFOCUS) + mouseinwindow = ev.active.gain; } break; // SDL_MOUSEMOTION needs to fall through to default... this is just GEKKO processing! case SDL_MOUSEMOTION: #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 - if (ev.motion.state & SDL_BUTTON_X2MASK) - { - // the absolute values are used to draw the crosshair - mouseabsx = ev.motion.x; - mouseabsy = ev.motion.y; - // hack: reduce the scale of the "relative" motions - // to make it act more like a real mouse - ev.motion.xrel /= 16; - ev.motion.yrel /= 12; - } + // the absolute values are used to draw the crosshair + mouseabsx = ev.motion.x; + mouseabsy = ev.motion.y; + // hack: reduce the scale of the "relative" motions + // to make it act more like a real mouse + ev.motion.xrel /= 16; + ev.motion.yrel /= 12; } #endif default: // OSD_Printf("Got event (%d)\n", ev.type); break;