port: add mouse controls to eyespy and slayer
This commit is contained in:
parent
bc4c08fe2f
commit
a49bfd00a4
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue