diff --git a/control.cpp b/control.cpp index c1cada8d..1f3df4db 100644 --- a/control.cpp +++ b/control.cpp @@ -30,7 +30,9 @@ bool mousemoved = false; bool actonrelease = false; bool mousepan, oldmousepan; +#if CAP_MOUSEGRAB ld mouseaim_x, mouseaim_y; +#endif ld mouseaim_sensitivity = 0.01; int timetowait; @@ -561,6 +563,7 @@ void mainloopiter() { mousepan = (cmode & (sm::NORMAL | sm::DRAW | sm::MAP)) && DIM == 3 && mouseaim_sensitivity; if(mousepan != oldmousepan) { oldmousepan = mousepan; + #if CAP_MOUSEGRAB if(mousepan) { SDL_WM_GrabInput(SDL_GRAB_ON); SDL_ShowCursor(SDL_DISABLE); @@ -572,6 +575,7 @@ void mainloopiter() { SDL_WarpMouse(vid.xres/2, vid.yres/2); mouseaim_x = mouseaim_y = 0; } + #endif } #if ISWEB @@ -635,8 +639,10 @@ void mainloopiter() { DEBB(DF_GRAPH, ("polling for events\n")); if(DIM == 3 && !shmup::on && !rug::rugged) { + #if CAP_MOUSEGRAB View = cspin(0, 2, -mouseaim_x) * cspin(1, 2, -mouseaim_y) * View; mouseaim_x = mouseaim_y = 0; + #endif } if(smooth_scrolling && !shmup::on && !rug::rugged) { diff --git a/hyper.h b/hyper.h index b8abdeb0..1bd0a078 100644 --- a/hyper.h +++ b/hyper.h @@ -2591,7 +2591,10 @@ void initquickqueue(); void quickqueue(); int darkenedby(int c, int lev); extern int mousex, mousey; -extern ld mouseaim_x, mouseaim_y, mouseaim_sensitivity; +#if CAP_MOUSEGRAB +extern ld mouseaim_x, mouseaim_y; +#endif +extern ld mouseaim_sensitivity; string generateHelpForItem(eItem it); bool graphglyph(); extern bool hiliteclick; diff --git a/shmup.cpp b/shmup.cpp index 456c9448..65812412 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -726,11 +726,13 @@ void handleInput(int delta) { panspin *= d; panmove *= d; + #if CAP_MOUSEGRAB if(lctrlclick) { panx += mouseaim_x / 2; pany += mouseaim_y / 2; mouseaim_x = mouseaim_y = 0; } + #endif if(panx || pany || panspin || (GDIM == 3 && panmove)) { if(DIM == 2) { @@ -1717,12 +1719,14 @@ void movePlayer(monster *m, int delta) { bool blown = m->blowoff > curtime; + #if CAP_MOUSEGRAB if(WDIM == 2 && GDIM == 3 && !lctrlclick && cpid == 0) { if(!stdracing) playerturn[cpid] -= mouseaim_x; playerturny[cpid] -= mouseaim_y; mouseaim_x = 0; mouseaim_y = 0; } + #endif if(playerturn[cpid] && canmove && !blown && WDIM == 2) { m->swordangle -= playerturn[cpid]; @@ -1775,11 +1779,13 @@ void movePlayer(monster *m, int delta) { playerturn[cpid] = mgo * SCALE * delta / 200; playerturny[cpid] = mturn * SCALE * delta / 200; + #if CAP_MOUSEGRAB if(!lctrlclick && cpid == 0) { playerturn[cpid] += mouseaim_x; playerturny[cpid] += mouseaim_y; mouseaim_x = mouseaim_y = 0; } + #endif } if(playergo[cpid] && markOrb(itOrbDash)) playergo[cpid] *= 1.5; @@ -3295,12 +3301,18 @@ void turn(int delta) { if(racing::on && subscreens::split( [delta] () { turn(delta); })) return; int id = 0; + #if CAP_MOUSEGRAB ld maimx = mouseaim_x; ld maimy = mouseaim_y; + #else + ld maimx, maimy; + #endif if(dual::split( [&id, maimx, maimy, delta] () { turn(delta); id++; + #if CAP_MOUSEGRAB if(id==1) mouseaim_x = maimx, mouseaim_y = maimy; + #endif })) return; if(callhandlers(false, hooks_turn, delta)) return; diff --git a/sysconfig.h b/sysconfig.h index c75aca7b..bbdd3a4f 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -194,6 +194,10 @@ #define CAP_ORIENTATION ISMOBILE #endif +#ifndef CAP_MOUSEGRAB +#define CAP_MOUSEGRAB (!ISMOBILE) +#endif + #ifndef CAP_COMMANDLINE #define CAP_COMMANDLINE (!ISMOBILE) #endif