diff --git a/port/include/input.h b/port/include/input.h index 7080fb97a..e62d6cc30 100644 --- a/port/include/input.h +++ b/port/include/input.h @@ -107,6 +107,7 @@ void inputMouseGetPosition(s32 *x, s32 *y); void inputMouseGetRawDelta(s32 *dx, s32 *dy); // returns changes in mouse position since last frame, scaled by sensitivity +// returns 0, 0 when the mouse is not locked into the window void inputMouseGetScaledDelta(f32 *dx, f32 *dy); // call this every frame diff --git a/port/src/input.c b/port/src/input.c index a533233c0..b47767e8f 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -363,8 +363,14 @@ void inputMouseGetRawDelta(s32 *dx, s32 *dy) void inputMouseGetScaledDelta(f32 *dx, f32 *dy) { - s32 w, h; - SDL_GetWindowSize(videoGetWindowHandle(), &w, &h); - if (dx) *dx = mouseSensX * (f32)mouseDX / 100.0f; - if (dy) *dy = mouseSensY * (f32)mouseDY / 100.0f; + f32 mdx, mdy; + if (mouseLocked) { + mdx = mouseSensX * (f32)mouseDX / 100.0f; + mdy = mouseSensY * (f32)mouseDY / 100.0f; + } else { + mdx = 0.f; + mdy = 0.f; + } + if (dx) *dx = mdx; + if (dy) *dy = mdy; } diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index 9dd2b7f43..7e18e1836 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -24,6 +24,9 @@ #include "lib/collision.h" #include "data.h" #include "types.h" +#ifndef PLATFORM_N64 +#include "input.h" +#endif u8 g_EyespyPickup = false; u8 g_EyespyHit = EYESPYHIT_NONE; @@ -898,6 +901,24 @@ void eyespyProcessInput(bool allowbuttons) } #endif +#ifndef PLATFORM_N64 + if (g_Vars.currentplayernum == 0) { + f32 mdx, mdy; + inputMouseGetScaledDelta(&mdx, &mdy); + if (mdx || mdy) { + mdx *= g_Vars.lvupdate60freal; + mdy *= g_Vars.lvupdate60freal; + g_Vars.currentplayer->eyespy->theta += mdx * 1.5f; + // hold aim to move up and down, release to look up and down + if (aimpressed) { + ascendspeed -= mdy; + } else { + g_Vars.currentplayer->eyespy->verta -= mdy * 1.5f; + } + } + } +#endif + // Update theta g_Vars.currentplayer->eyespy->theta += c1stickx * 0.0625f * g_Vars.lvupdate60freal; diff --git a/src/game/bondmove.c b/src/game/bondmove.c index c077d4749..dfc60e294 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -697,7 +697,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i movedata.analogwalk = movedata.c1stickysafe; #ifndef PLATFORM_N64 - if (inputMouseIsLocked() && g_Vars.currentplayernum == 0 && (allowc1x || allowc1y)) { + if (g_Vars.currentplayernum == 0 && (allowc1x || allowc1y)) { inputMouseGetScaledDelta(&movedata.freelookdx, &movedata.freelookdy); } #endif diff --git a/src/game/player.c b/src/game/player.c index 5c1f5303e..7756e9d71 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -72,6 +72,7 @@ #include "types.h" #ifndef PLATFORM_N64 #include "video.h" +#include "input.h" #endif s32 g_DefaultWeapons[2]; @@ -3540,6 +3541,17 @@ void playerTick(bool arg0) sp178 = sticky * LVUPDATE60FREAL() * 0.00025f; sp174 = -stickx * LVUPDATE60FREAL() * 0.00025f; +#ifndef PLATFORM_N64 + if (g_Vars.currentplayernum == 0) { + f32 mdx, mdy; + inputMouseGetScaledDelta(&mdx, &mdy); + if (mdx || mdy) { + sp178 += mdy * LVUPDATE60FREAL() * 0.0025f; + sp174 -= mdx * LVUPDATE60FREAL() * 0.0025f; + } + } +#endif + f20 = sqrtf(sp2ac.f[0] * sp2ac.f[0] + sp2ac.f[2] * sp2ac.f[2]); sp2ac.x /= f20;