diff --git a/port/src/input.c b/port/src/input.c index 38bc1f005..ddfc7369d 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -8,6 +8,7 @@ #include "input.h" #include "video.h" #include "config.h" +#include "constants.h" #define MAX_BINDS 4 #define TRIG_THRESHOLD (30 * 256) diff --git a/src/game/activemenutick.c b/src/game/activemenutick.c index 39681565a..a7823299c 100644 --- a/src/game/activemenutick.c +++ b/src/game/activemenutick.c @@ -12,6 +12,9 @@ #include "lib/str.h" #include "data.h" #include "types.h" +#ifndef PLATFORM_N64 +#include "input.h" +#endif void amTick(void) { @@ -45,6 +48,7 @@ void amTick(void) s8 gotonextscreen = false; s8 cstickx = joyGetStickXOnSample(j, contpadnum); s8 csticky = joyGetStickYOnSample(j, contpadnum); + s8 absstickx; s8 abssticky; u16 buttonsstate = joyGetButtonsOnSample(j, contpadnum, 0xffff); @@ -63,6 +67,24 @@ void amTick(void) g_AmMenus[g_AmIndex].allbots = false; +#ifndef PLATFORM_N64 + if (j == 0 && g_Vars.currentplayernum == 0 && inputMouseIsLocked()) { + f32 mdx, mdy; + struct activemenu *am = &g_AmMenus[g_AmIndex]; + inputMouseGetScaledDelta(&mdx, &mdy); + if (mdx || mdy) { + am->mousex += mdx * 4.f; + am->mousey += mdy * 4.f; + am->mousex = (am->mousex > 127.f) ? 127.f : (am->mousex < -128.f) ? -128.f : am->mousex; + am->mousey = (am->mousey > 127.f) ? 127.f : (am->mousey < -128.f) ? -128.f : am->mousey; + } + const s32 newstickx = (s32)cstickx + (s32)am->mousex; + const s32 newsticky = (s32)csticky - (s32)am->mousey; + cstickx = (newstickx < -128) ? -128 : (newstickx > 127) ? 127 : newstickx; + csticky = (newsticky < -128) ? -128 : (newsticky > 127) ? 127 : newsticky; + } +#endif + if (g_Vars.currentplayer->activemenumode == AMMODE_EDIT) { buttonsstate = buttonsstate & D_JPAD; cstickx = 0; @@ -337,6 +359,12 @@ void amTick(void) } } } +#ifndef PLATFORM_N64 + else { + g_AmMenus[g_AmIndex].mousex = 0.f; + g_AmMenus[g_AmIndex].mousey = 0.f; + } +#endif if (g_Vars.currentplayer->activemenumode != AMMODE_EDIT) { s16 dist; diff --git a/src/include/types.h b/src/include/types.h index 026e37808..ab9df277b 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4303,6 +4303,11 @@ struct activemenu { /*0x32*/ u8 allbots; // when player holds R on the bot command screen /*0x33*/ u8 prevallbots; // used when opening "Pick Target" menu for attack command /*0x34*/ s8 origscreennum; // original screen number before using allbots + +#ifndef PLATFORM_N64 + /* */ f32 mousex; + /* */ f32 mousey; +#endif }; struct briefing {