Skip to content

Commit

Permalink
port: fix #204; allow players 2-4 to use lstick in radial menu
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed Oct 29, 2023
1 parent c8db5fa commit 50b74e4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/game/activemenutick.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ void amTick(void)
s8 csticky = joyGetStickYOnSample(j, contpadnum);
s8 crstickx = joyGetRStickXOnSample(j, contpadnum);
s8 crsticky = joyGetRStickYOnSample(j, contpadnum);
#ifdef AVOID_UB
// if cstickx is -128, it will get negated and stored into absstickx, negating it again if it's 8 bit
s32 absstickx;
s32 abssticky;
#else
s8 absstickx;
s8 abssticky;
#endif
u32 buttonsstate = joyGetButtonsOnSample(j, contpadnum, 0xffffffff);
u32 buttonspressed = joyGetButtonsPressedOnSample(j, contpadnum, 0xffffffff);
bool stickpushed = false;
Expand All @@ -69,6 +75,8 @@ void amTick(void)
g_AmMenus[g_AmIndex].allbots = false;

#ifndef PLATFORM_N64
s32 newstickx = (s32)cstickx + (s32)crstickx;
s32 newsticky = (s32)csticky + (s32)crsticky;
if (j == 0 && g_Vars.currentplayernum == 0 && inputMouseIsLocked()) {
f32 mdx, mdy;
struct activemenu *am = &g_AmMenus[g_AmIndex];
Expand All @@ -79,11 +87,11 @@ void amTick(void)
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)crstickx + (s32)am->mousex;
const s32 newsticky = (s32)csticky + (s32)crsticky - (s32)am->mousey;
cstickx = (newstickx < -128) ? -128 : (newstickx > 127) ? 127 : newstickx;
csticky = (newsticky < -128) ? -128 : (newsticky > 127) ? 127 : newsticky;
newstickx += (s32)am->mousex;
newsticky -= (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) {
Expand Down

0 comments on commit 50b74e4

Please sign in to comment.