diff --git a/config.cpp b/config.cpp index 469bc454..cfde5749 100644 --- a/config.cpp +++ b/config.cpp @@ -363,6 +363,7 @@ void initConfig() { addsaver(sightranges[gCell120], "sight-120cell", 2 * M_PI); addsaver(sightranges[gECell120], "sight-120cell-elliptic", M_PI); addsaver(smooth_scrolling, "smooth-scrolling", false); + addsaver(mouseaim_sensitivity, "mouseaim_sensitivity", 0.01); addsaver(vid.consider_shader_projection, "shader-projection", true); diff --git a/control.cpp b/control.cpp index b62cbbca..c2d5aaca 100644 --- a/control.cpp +++ b/control.cpp @@ -492,6 +492,10 @@ void resize_screen_to(int x, int y) { setvideomode(); } +bool mousepan, oldmousepan; +ld mouseaim_x, mouseaim_y; +ld mouseaim_sensitivity = 0.01; + void mainloopiter() { DEBB(DF_GRAPH, (debugfile,"main loop\n")); @@ -524,6 +528,22 @@ void mainloopiter() { cwtV = gmatrix[cwt.at] * ddspin(cwt.at, cwt.spin); if(cwt.mirrored) playerV = playerV * Mirror; } + + mousepan = normal && DIM == 3; + if(mousepan != oldmousepan) { + oldmousepan = mousepan; + if(mousepan) { + SDL_WM_GrabInput(SDL_GRAB_ON); + SDL_ShowCursor(SDL_DISABLE); + mouseaim_x = mouseaim_y = 0; + } + else { + SDL_WM_GrabInput( SDL_GRAB_OFF ); + SDL_ShowCursor(SDL_ENABLE); + SDL_WarpMouse(vid.xres/2, vid.yres/2); + mouseaim_x = mouseaim_y = 0; + } + } #if ISWEB timetowait = 0; @@ -581,6 +601,11 @@ void mainloopiter() { SDL_Event ev; DEBB(DF_GRAPH, (debugfile,"polling for events\n")); + if(DIM == 3 && !shmup::on && !rug::rugged) { + View = cspin(0, 2, -mouseaim_x) * cspin(1, 2, -mouseaim_y) * View; + mouseaim_x = mouseaim_y = 0; + } + if(smooth_scrolling && !shmup::on && !rug::rugged) { static int lastticks; ld t = (ticks - lastticks) * shiftmul / 1000.; @@ -796,6 +821,13 @@ void handle_event(SDL_Event& ev) { mousex = ev.motion.x; mousey = ev.motion.y; + if(mousepan) { + mousex = vid.xres/2; + mousey = vid.yres/2; + mouseaim_x += ev.motion.xrel * mouseaim_sensitivity; + mouseaim_y += ev.motion.yrel * mouseaim_sensitivity; + } + need_mouseh = true; if(holdmouse && getcstat == '-') sym = uni = getcstat, fix_mouseh(); diff --git a/hyper.h b/hyper.h index 18aac776..aaaabdbb 100644 --- a/hyper.h +++ b/hyper.h @@ -2473,6 +2473,7 @@ void initquickqueue(); void quickqueue(); int darkenedby(int c, int lev); extern int mousex, mousey; +extern ld mouseaim_x, mouseaim_y, mouseaim_sensitivity; string generateHelpForItem(eItem it); bool graphglyph(); extern bool hiliteclick; diff --git a/shmup.cpp b/shmup.cpp index 4c3d6fb1..066ae7c0 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -764,12 +764,23 @@ void handleInput(int delta) { if(actionspressed[58] && !lactionpressed[58]) pushScreen(showMainMenu); + + panx *= d; + pany *= d; + panspin *= d; + panmove *= d; + if(lctrlclick) { + panx += mouseaim_x / 2; + pany += mouseaim_y / 2; + mouseaim_x = mouseaim_y = 0; + } + if(panx || pany || panspin || (DIM == 3 && panmove)) { if(DIM == 2) - View = xpush(-panx * d) * ypush(-pany * d) * spin(panspin * d) * View; + View = xpush(-panx) * ypush(-pany) * spin(panspin) * View; else - View = cspin(0, 2, panx/10) * cspin(0, 1, pany/10) * spin(panspin * d) * cpush(2, panmove/10) * View; + View = cspin(0, 2, panx*2) * cspin(0, 1, pany*2) * spin(panspin) * cpush(2, panmove*2) * View; playermoved = false; } #endif @@ -1710,6 +1721,12 @@ void movePlayer(monster *m, int delta) { playerstrafe[cpid] = mturn * SCALE * delta / 600; playerturn[cpid] = mdx * SCALE * delta / 200; playerturny[cpid] = mdy * SCALE * delta / 200; + + if(!lctrlclick) { + playerturn[cpid] += mouseaim_x; + playerturny[cpid] += mouseaim_y; + mouseaim_x = mouseaim_y = 0; + } } if(playergo[cpid] && markOrb(itOrbDash)) playergo[cpid] *= 1.5;