diff --git a/port/src/input.c b/port/src/input.c index 11b5dd128..69de71571 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -52,22 +52,26 @@ void inputSetDefaultKeyBinds(void) { // TODO: make VK constants for all these static const u32 kbbinds[][3] = { - { CK_A, SDL_SCANCODE_Q, 0 }, - { CK_B, SDL_SCANCODE_E, 0 }, - { CK_X, SDL_SCANCODE_TAB, 0 }, - { CK_Y, SDL_SCANCODE_R, 0 }, - { CK_RTRIG, VK_MOUSE_RIGHT, SDL_SCANCODE_Z }, - { CK_LTRIG, VK_MOUSE_X1, SDL_SCANCODE_X }, - { CK_ZTRIG, VK_MOUSE_LEFT, SDL_SCANCODE_SPACE }, - { CK_START, SDL_SCANCODE_RETURN, 0 }, - { CK_DPAD_D, SDL_SCANCODE_S, 0 }, - { CK_DPAD_U, SDL_SCANCODE_W, 0 }, - { CK_DPAD_R, SDL_SCANCODE_D, 0 }, - { CK_DPAD_L, SDL_SCANCODE_A, 0 }, - { CK_STICK_XNEG, SDL_SCANCODE_LEFT, 0 }, - { CK_STICK_XPOS, SDL_SCANCODE_RIGHT, 0 }, - { CK_STICK_YNEG, SDL_SCANCODE_DOWN, 0 }, - { CK_STICK_YPOS, SDL_SCANCODE_UP, 0 }, + { CK_A, SDL_SCANCODE_Q, 0 }, + { CK_B, SDL_SCANCODE_E, 0 }, + { CK_X, SDL_SCANCODE_R, 0 }, + { CK_Y, SDL_SCANCODE_R, 0 }, + { CK_RTRIG, VK_MOUSE_RIGHT, SDL_SCANCODE_Z }, + { CK_LTRIG, SDL_SCANCODE_F, SDL_SCANCODE_X }, + { CK_ZTRIG, VK_MOUSE_LEFT, SDL_SCANCODE_SPACE }, + { CK_START, SDL_SCANCODE_RETURN, SDL_SCANCODE_TAB }, + { CK_DPAD_D, SDL_SCANCODE_G, VK_MOUSE_MIDDLE }, + { CK_DPAD_U, 0, 0 }, + { CK_DPAD_R, 0, 0 }, + { CK_DPAD_L, 0, 0 }, + { CK_C_D, SDL_SCANCODE_S, 0 }, + { CK_C_U, SDL_SCANCODE_W, 0 }, + { CK_C_R, SDL_SCANCODE_D, 0 }, + { CK_C_L, SDL_SCANCODE_A, 0 }, + { CK_STICK_XNEG, SDL_SCANCODE_LEFT, 0 }, + { CK_STICK_XPOS, SDL_SCANCODE_RIGHT, 0 }, + { CK_STICK_YNEG, SDL_SCANCODE_DOWN, 0 }, + { CK_STICK_YPOS, SDL_SCANCODE_UP, 0 }, }; static const u32 joybinds[][2] = { @@ -75,15 +79,15 @@ void inputSetDefaultKeyBinds(void) { CK_B, SDL_CONTROLLER_BUTTON_B }, { CK_X, SDL_CONTROLLER_BUTTON_X }, { CK_Y, SDL_CONTROLLER_BUTTON_Y }, - { CK_LTRIG, SDL_CONTROLLER_BUTTON_LEFTSHOULDER }, - { CK_RTRIG, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER }, - { CK_ZTRIG, VK_JOY1_LTRIG - VK_JOY1_BEGIN }, + { CK_DPAD_D, SDL_CONTROLLER_BUTTON_LEFTSHOULDER }, + { CK_LTRIG, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER }, + { CK_RTRIG, VK_JOY1_LTRIG - VK_JOY1_BEGIN }, { CK_ZTRIG, VK_JOY1_RTRIG - VK_JOY1_BEGIN }, { CK_START, SDL_CONTROLLER_BUTTON_START }, - { CK_DPAD_D, SDL_CONTROLLER_BUTTON_DPAD_DOWN }, - { CK_DPAD_U, SDL_CONTROLLER_BUTTON_DPAD_UP }, - { CK_DPAD_R, SDL_CONTROLLER_BUTTON_DPAD_RIGHT }, - { CK_DPAD_L, SDL_CONTROLLER_BUTTON_DPAD_LEFT }, + { CK_C_D, SDL_CONTROLLER_BUTTON_DPAD_DOWN }, + { CK_C_U, SDL_CONTROLLER_BUTTON_DPAD_UP }, + { CK_C_R, SDL_CONTROLLER_BUTTON_DPAD_RIGHT }, + { CK_C_L, SDL_CONTROLLER_BUTTON_DPAD_LEFT }, }; for (u32 i = 0; i < sizeof(kbbinds) / sizeof(kbbinds[0]); ++i) { diff --git a/src/game/activemenutick.c b/src/game/activemenutick.c index 71c96a318..39681565a 100644 --- a/src/game/activemenutick.c +++ b/src/game/activemenutick.c @@ -23,7 +23,7 @@ void amTick(void) g_AmIndex = g_Vars.currentplayernum; if (g_AmMenus[g_AmIndex].togglefunc) { - if (bgunConsiderToggleGunFunction(60, false, true) > 0) { + if (bgunConsiderToggleGunFunction(60, false, true, 0) > 0) { g_AmMenus[g_AmIndex].togglefunc = false; } } else { @@ -64,7 +64,7 @@ void amTick(void) g_AmMenus[g_AmIndex].allbots = false; if (g_Vars.currentplayer->activemenumode == AMMODE_EDIT) { - buttonsstate = buttonsstate & A_BUTTON; + buttonsstate = buttonsstate & D_JPAD; cstickx = 0; csticky = 0; buttonspressed = 0; @@ -72,11 +72,11 @@ void amTick(void) // JPN fixes the bug that's documented in amChangeScreen if (controlmode == CONTROLMODE_13 || controlmode == CONTROLMODE_14) { - if ((buttonsstate & R_TRIG) || (buttonsstate & L_TRIG)) { + if ((buttonsstate & R_TRIG)) { stayopen = true; } - if (buttonsstate & A_BUTTON) { + if (buttonsstate & D_JPAD) { #if VERSION >= VERSION_JPN_FINAL || !defined(PLATFORM_N64) if (g_Vars.currentplayer->numaibuddies > 0) { g_AmMenus[g_AmIndex].allbots = true; @@ -86,11 +86,11 @@ void amTick(void) #endif } } else { - if (buttonsstate & A_BUTTON) { + if (buttonsstate & D_JPAD) { stayopen = true; } - if ((buttonsstate & R_TRIG) || (buttonsstate & L_TRIG)) { + if ((buttonsstate & R_TRIG)) { #if VERSION >= VERSION_JPN_FINAL || !defined(PLATFORM_N64) if (g_Vars.currentplayer->numaibuddies > 0) { g_AmMenus[g_AmIndex].allbots = true; @@ -134,22 +134,6 @@ void amTick(void) column = 2; } - if (buttonsstate & U_JPAD) { - row = 0; - } - - if (buttonsstate & D_JPAD) { - row = 2; - } - - if (buttonsstate & L_JPAD) { - column = 0; - } - - if (buttonsstate & R_JPAD) { - column = 2; - } - if (controlmode == CONTROLMODE_23 || controlmode == CONTROLMODE_24 || controlmode == CONTROLMODE_22 @@ -161,13 +145,13 @@ void amTick(void) u16 buttonspressed2 = joyGetButtonsPressedOnSample(j, contpadnum2, 0xffff); if (g_Vars.currentplayer->activemenumode == AMMODE_EDIT) { - buttonsstate2 = buttonsstate2 & A_BUTTON; + buttonsstate2 = buttonsstate2 & D_JPAD; cstickx2 = 0; csticky2 = 0; buttonspressed2 = 0; } - if (buttonsstate2 & A_BUTTON) { + if (buttonsstate2 & D_JPAD) { stayopen = true; } @@ -191,22 +175,6 @@ void amTick(void) column = 2; } - if (buttonsstate2 & U_JPAD) { - row = 0; - } - - if (buttonsstate2 & D_JPAD) { - row = 2; - } - - if (buttonsstate2 & L_JPAD) { - column = 0; - } - - if (buttonsstate2 & R_JPAD) { - column = 2; - } - absstickx = cstickx2 < 0 ? -cstickx2 : cstickx2; abssticky = csticky2 < 0 ? -csticky2 : csticky2; diff --git a/src/game/bondbike.c b/src/game/bondbike.c index 7c83d4f5d..ce29b43f5 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -208,8 +208,8 @@ void bbikeApplyMoveData(struct movedata *data) || optionsGetControlMode(g_Vars.currentplayerstats->mpindex) == CONTROLMODE_13 || optionsGetControlMode(g_Vars.currentplayerstats->mpindex) == CONTROLMODE_11) && !lvIsPaused()) { - data->digitalstepleft = joyCountButtonsOnSpecificSamples(0, contnum, L_JPAD | L_CBUTTONS); - data->digitalstepright = joyCountButtonsOnSpecificSamples(0, contnum, R_JPAD | R_CBUTTONS); + data->digitalstepleft = joyCountButtonsOnSpecificSamples(0, contnum, L_CBUTTONS); + data->digitalstepright = joyCountButtonsOnSpecificSamples(0, contnum,R_CBUTTONS); } // Forward/back diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index 9b292c5d4..15bfca978 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -739,7 +739,7 @@ void eyespyProcessInput(bool allowbuttons) exitpressed = c1buttons & R_TRIG; activatepressed = c1buttons & B_BUTTON; } else if (controlmode <= CONTROLMODE_14) { - aimpressed = c1buttons & (L_TRIG | R_TRIG); + aimpressed = c1buttons & (R_TRIG); shootpressed = c1buttons & Z_TRIG; exitpressed = c1buttons & A_BUTTON; activatepressed = c1buttons & B_BUTTON; @@ -819,18 +819,18 @@ void eyespyProcessInput(bool allowbuttons) forwardspeed = c1sticky; } - ascendspeed = (c1buttons & (U_CBUTTONS | U_JPAD) ? 1 : 0) - (c1buttons & (D_CBUTTONS | D_JPAD) ? 1 : 0); - sidespeed = (c1buttons & (R_CBUTTONS | R_JPAD) ? 1 : 0) - (c1buttons & (L_CBUTTONS | L_JPAD) ? 1 : 0); + ascendspeed = (c1buttons & (U_CBUTTONS) ? 1 : 0) - (c1buttons & (D_CBUTTONS) ? 1 : 0); + sidespeed = (c1buttons & (R_CBUTTONS) ? 1 : 0) - (c1buttons & (L_CBUTTONS) ? 1 : 0); } else if (controlmode <= CONTROLMODE_14) { if (aimpressed) { domovecentre = false; pitchspeed = c1sticky; } else { ascendspeed = c1sticky * 0.25f; - forwardspeed = (c1buttons & (U_CBUTTONS | U_JPAD) ? 24.0f : 0) - (c1buttons & (D_CBUTTONS | D_JPAD) ? 24.0f : 0); + forwardspeed = (c1buttons & (U_CBUTTONS) ? 24.0f : 0) - (c1buttons & (D_CBUTTONS) ? 24.0f : 0); } - sidespeed = (c1buttons & (R_CBUTTONS | R_JPAD) ? 1 : 0) - (c1buttons & (L_CBUTTONS | L_JPAD) ? 1 : 0); + sidespeed = (c1buttons & (R_CBUTTONS) ? 1 : 0) - (c1buttons & (L_CBUTTONS) ? 1 : 0); } else if (controlmode == CONTROLMODE_21 || controlmode == CONTROLMODE_23) { forwardspeed = c1sticky; diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 11473d482..46cdce02b 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -11686,20 +11686,27 @@ void bgunSetTriggerOn(s32 handnum, bool on) * - USETIMER_STOP if the B button timer should stop (ie. the B press is consumed) * - USETIMER_REPEAT if this function should be called again on each frame until B is released. */ -s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu) +s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton) { switch (bgunGetWeaponNum(HAND_RIGHT)) { case WEAPON_SNIPERRIFLE: - // At 25 ticks (or B+Z), start showing the new function + if (usedowntime < 0) { + return USETIMER_CONTINUE; + } + // g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc; g_Vars.currentplayer->gunctrl.invertgunfunc = true; // B+Z immediately triggers crouch or stand if (trigpressed) { + g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; return USETIMER_STOP; } + if (fromdedicatedbutton) { + g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; + return USETIMER_CONTINUE; + } - // Don't do anything if B hasn't been held for 50/60ths of a second - if (usedowntime < TICKS(50)) { + if (ABS(usedowntime) < 0) { return USETIMER_CONTINUE; } @@ -11709,13 +11716,13 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac // Do crouch or stand g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; - return USETIMER_REPEAT; + return USETIMER_STOP; case WEAPON_RCP120: case WEAPON_LAPTOPGUN: case WEAPON_DRAGON: case WEAPON_REMOTEMINE: // These weapons use temporary alt functions - g_Vars.currentplayer->gunctrl.invertgunfunc = true; + g_Vars.currentplayer->gunctrl.invertgunfunc = !g_Vars.currentplayer->gunctrl.invertgunfunc; if (fromactivemenu && bgunIsUsingSecondaryFunction() == true) { g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; @@ -11761,8 +11768,16 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac void bgun0f0a8c50(void) { - if (g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary == false) { - g_Vars.currentplayer->gunctrl.invertgunfunc = false; + switch (bgunGetWeaponNum(HAND_RIGHT)) { + case WEAPON_RCP120: + case WEAPON_LAPTOPGUN: + case WEAPON_DRAGON: + case WEAPON_REMOTEMINE: + return; + default: + if (g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary == false) { + g_Vars.currentplayer->gunctrl.invertgunfunc = false; + } } } diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 474e08094..1c425466b 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -579,6 +579,7 @@ void bmoveResetMoveData(struct movedata *data) data->freelookdx = 0.0f; data->freelookdy = 0.0f; #endif + data->alt1tapcount = 0; } /** @@ -913,7 +914,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (g_Vars.currentplayer->invdowntime > -1 && joyGetButtonsOnSample(i, shootpad, shootallowedbuttons & Z_TRIG) == 0) { if (g_Vars.currentplayer->invdowntime > TICKS(15)) { - amOpen(); + /* amOpen(); */ g_Vars.currentplayer->invdowntime = -1; } else { g_Vars.currentplayer->invdowntime++; @@ -940,13 +941,13 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (g_Vars.currentplayer->usedowntime >= -1) { if (joyGetButtonsPressedOnSample(i, shootpad, shootallowedbuttons & Z_TRIG) && g_Vars.currentplayer->usedowntime > -1 - && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false) != USETIMER_CONTINUE) { + && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) { g_Vars.currentplayer->usedowntime = -3; } if (g_Vars.currentplayer->usedowntime > -1) { if (g_Vars.currentplayer->usedowntime > TICKS(25)) { - result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false); + result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); if (result == USETIMER_STOP) { g_Vars.currentplayer->usedowntime = -1; @@ -960,7 +961,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } } else if (g_Vars.currentplayer->usedowntime >= -2) { - bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false); + bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); } } else { // Released B - activate or reload @@ -1109,10 +1110,10 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (controlmode == CONTROLMODE_13 || controlmode == CONTROLMODE_14) { shootbuttons = A_BUTTON; aimbuttons = Z_TRIG; - invbuttons = L_TRIG | R_TRIG; + invbuttons = R_TRIG; } else { shootbuttons = Z_TRIG; - aimbuttons = L_TRIG | R_TRIG; + aimbuttons = R_TRIG; invbuttons = A_BUTTON; } @@ -1150,23 +1151,23 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i // Handle side stepping if (g_Vars.currentplayer->insightaimmode == false) { if (allowc1buttons) { - movedata.digitalstepleft = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (L_JPAD | L_CBUTTONS)); - movedata.digitalstepright = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (R_JPAD | R_CBUTTONS)); + movedata.digitalstepleft = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (L_CBUTTONS)); + movedata.digitalstepright = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (R_CBUTTONS)); } } else { // This doesn't appear to be r-leaning. // R-leaning still works when these are commented. - if (c1buttons & (L_JPAD | L_CBUTTONS)) { + if (c1buttons & (L_CBUTTONS)) { movedata.unk30 = 1; } - if (c1buttons & (R_JPAD | R_CBUTTONS)) { + if (c1buttons & (R_CBUTTONS)) { movedata.unk34 = 1; } } - movedata.digitalstepforward = !g_Vars.currentplayer->insightaimmode && (c1buttons & (U_JPAD | U_CBUTTONS)); - movedata.digitalstepback = !g_Vars.currentplayer->insightaimmode && (c1buttons & (D_JPAD | D_CBUTTONS)); + movedata.digitalstepforward = !g_Vars.currentplayer->insightaimmode && (c1buttons & (U_CBUTTONS)); + movedata.digitalstepback = !g_Vars.currentplayer->insightaimmode && (c1buttons & (D_CBUTTONS)); movedata.canlookahead = false; movedata.cannaturalpitch = !g_Vars.currentplayer->insightaimmode; movedata.speedvertadown = 0; @@ -1192,17 +1193,17 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } else { // 1.1 or 1.3 - if (c1buttons & (L_JPAD | L_CBUTTONS)) { + if (c1buttons & (L_CBUTTONS)) { movedata.unk30 = 1; } - if (c1buttons & (R_JPAD | R_CBUTTONS)) { + if (c1buttons & (R_CBUTTONS)) { movedata.unk34 = 1; } if (!g_Vars.currentplayer->insightaimmode && allowc1buttons) { - movedata.digitalstepleft = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (L_JPAD | L_CBUTTONS)); - movedata.digitalstepright = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (R_JPAD | R_CBUTTONS)); + movedata.digitalstepleft = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (L_CBUTTONS)); + movedata.digitalstepright = joyCountButtonsOnSpecificSamples(aimoffhist, contpad1, c1allowedbuttons & (R_CBUTTONS)); } movedata.digitalstepforward = false; @@ -1211,11 +1212,11 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i movedata.cannaturalpitch = false; // Looking up/down - if (!g_Vars.currentplayer->insightaimmode && (c1buttons & (U_JPAD | U_CBUTTONS))) { + if (!g_Vars.currentplayer->insightaimmode && (c1buttons & (U_CBUTTONS))) { movedata.speedvertadown = 1; } - if (!g_Vars.currentplayer->insightaimmode && (c1buttons & (D_JPAD | D_CBUTTONS))) { + if (!g_Vars.currentplayer->insightaimmode && (c1buttons & (D_CBUTTONS))) { movedata.speedvertaup = 1; } @@ -1284,7 +1285,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (g_Vars.currentplayer->invdowntime >= 0 && joyGetButtonsOnSample(i, contpad1, shootbuttons & c1allowedbuttons) == 0) { // Holding A and haven't pressed Z if (g_Vars.currentplayer->invdowntime > TICKS(15)) { - amOpen(); + /* amOpen(); */ g_Vars.currentplayer->invdowntime = -1; } else { g_Vars.currentplayer->invdowntime++; @@ -1312,13 +1313,13 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (g_Vars.currentplayer->usedowntime >= -1) { if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) && g_Vars.currentplayer->usedowntime >= 0 - && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false) != USETIMER_CONTINUE) { + && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) { g_Vars.currentplayer->usedowntime = -3; } if (g_Vars.currentplayer->usedowntime >= 0) { if (g_Vars.currentplayer->usedowntime > TICKS(25)) { - s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false); + s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); if (result == USETIMER_STOP) { g_Vars.currentplayer->usedowntime = -1; @@ -1333,7 +1334,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } else { if (g_Vars.currentplayer->usedowntime >= -2) { - bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false); + bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); } } } else { @@ -1348,11 +1349,80 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } + + // handle L button + for (i = 0; i< numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & L_TRIG)) { + if (g_Vars.currentplayer->altdowntime >= -1) { + if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) + && g_Vars.currentplayer->altdowntime >= 0 + && bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, true, false, true) != USETIMER_CONTINUE) { + g_Vars.currentplayer->altdowntime = -3; + } + + if (g_Vars.currentplayer->altdowntime != -4) { + if (g_Vars.currentplayer->altdowntime <= 0) { + g_Vars.currentplayer->altdowntime++; + } + } + } else { + if (g_Vars.currentplayer->altdowntime == -2) { + bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, false, false, true); + g_Vars.currentplayer->altdowntime = -4; + } + } + } else { + // Released L + if (g_Vars.currentplayer->altdowntime != 0) { + s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, (g_Vars.currentplayer->altdowntime == -3 ? true: false), false, true); + + if (result == USETIMER_STOP) { + g_Vars.currentplayer->altdowntime = -1; + } else if (result == USETIMER_REPEAT) { + g_Vars.currentplayer->altdowntime = -2; + } + } + g_Vars.currentplayer->altdowntime = 0; + } + } + + // Handle ALT1 / MI Reload Hack + for (i = 0; i < numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & X_BUTTON)) { + movedata.alt1tapcount++; + } + } + + + // Handle radial menu (D-Down) + for (i = 0; i < numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & D_JPAD)) { + if (g_Vars.currentplayer->amdowntime < -2) { + g_Vars.currentplayer->amdowntime += numsamples; + + if (g_Vars.currentplayer->amdowntime > -3) { + g_Vars.currentplayer->amdowntime = 0; + } + } else { + if (g_Vars.currentplayer->amdowntime >= 0) { + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & D_JPAD)) { + amOpen(); + g_Vars.currentplayer->amdowntime = -1; + } else { + g_Vars.currentplayer->amdowntime++; + } + } + } + } else { + g_Vars.currentplayer->amdowntime = 0; + } + } + // Handle manual zoom in and out (sniper, farsight and horizon scanner) if (canmanualzoom && g_Vars.currentplayer->insightaimmode) { increment = 1; - zoomout = c1buttons & (D_JPAD | D_CBUTTONS); - zoomin = c1buttons & (U_JPAD | U_CBUTTONS); + zoomout = c1buttons & (D_CBUTTONS); + zoomin = c1buttons & (U_CBUTTONS); // @bug? Should this be HAND_RIGHT? if (bgunGetWeaponNum(HAND_LEFT) == WEAPON_FARSIGHT) { @@ -1372,7 +1442,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (allowc1buttons) { for (i = 0; i < numsamples; i++) { if (!canmanualzoom && aimonhist[i]) { - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & (U_JPAD | U_CBUTTONS))) { + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & (U_CBUTTONS))) { if (movedata.crouchdown) { movedata.crouchdown--; } else { @@ -1382,7 +1452,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i g_Vars.currentplayer->aimtaptime = -1; } - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & (D_JPAD | D_CBUTTONS))) { + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & (D_CBUTTONS))) { if (movedata.crouchup) { movedata.crouchup--; } else { @@ -1422,14 +1492,14 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i && g_Vars.coopplayernum <= -1) { movedata.eyesshut = g_Vars.currentplayer->insightaimmode && !canmanualzoom - && joyGetButtons(contpad1, c1allowedbuttons & (D_JPAD | D_CBUTTONS)); + && joyGetButtons(contpad1, c1allowedbuttons & (D_CBUTTONS)); } if (bgunGetWeaponNum(HAND_RIGHT) == WEAPON_FARSIGHT) { - movedata.farsighttempautoseek = g_Vars.currentplayer->insightaimmode && (c1buttons & (L_CBUTTONS | R_CBUTTONS | L_JPAD | R_JPAD)); + movedata.farsighttempautoseek = g_Vars.currentplayer->insightaimmode && (c1buttons & (L_CBUTTONS | R_CBUTTONS)); } else { - movedata.rleanleft = g_Vars.currentplayer->insightaimmode && (c1buttons & (L_JPAD | L_CBUTTONS)); - movedata.rleanright = g_Vars.currentplayer->insightaimmode && (c1buttons & (R_JPAD | R_CBUTTONS)); + movedata.rleanleft = g_Vars.currentplayer->insightaimmode && (c1buttons & (L_CBUTTONS)); + movedata.rleanright = g_Vars.currentplayer->insightaimmode && (c1buttons & (R_CBUTTONS)); } // Handle mine detonation @@ -1474,10 +1544,13 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i g_Vars.currentplayer->bondactivateorreload = 0; + if (movedata.alt1tapcount) { + g_Vars.currentplayer->bondactivateorreload = g_Vars.currentplayer->bondactivateorreload | JO_ACTION_RELOAD; + } if (movedata.btapcount) { g_Vars.currentplayer->activatetimelast = g_Vars.currentplayer->activatetimethis; g_Vars.currentplayer->activatetimethis = g_Vars.lvframe60; - g_Vars.currentplayer->bondactivateorreload = movedata.btapcount; + g_Vars.currentplayer->bondactivateorreload = g_Vars.currentplayer->bondactivateorreload | JO_ACTION_ACTIVATE; bmoveHandleActivate(); } diff --git a/src/game/bondview.c b/src/game/bondview.c index b8ead4f64..2b24a6516 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -1264,32 +1264,32 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) // Up if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { brightness = 20; \ - if (buttonsdown & (U_JPAD | U_CBUTTONS)) { \ + if (buttonsdown & (U_CBUTTONS)) { \ brightness += 20; \ } \ - if (buttonsthisframe & (U_JPAD | U_CBUTTONS)) { \ + if (buttonsthisframe & (U_CBUTTONS)) { \ brightness += 20; \ } \ gDPSetPrimColor(gdl++, 0, 0, 0, brightness, 0, 0xff); \ } else if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_DRUGSPY) { brightness = 127; - if (buttonsdown & (U_JPAD | U_CBUTTONS)) { + if (buttonsdown & (U_CBUTTONS)) { brightness += 63; } - if (buttonsthisframe & (U_JPAD | U_CBUTTONS)) { + if (buttonsthisframe & (U_CBUTTONS)) { brightness += 63; \ } \ gDPSetPrimColor(gdl++, 0, 0, 0x10, 0x20, brightness, 0xff); } else { brightness = 20; - if (buttonsdown & (U_JPAD | U_CBUTTONS)) { + if (buttonsdown & (U_CBUTTONS)) { brightness += 20; } - if (buttonsthisframe & (U_JPAD | U_CBUTTONS)) { + if (buttonsthisframe & (U_CBUTTONS)) { brightness += 20; \ } \ gDPSetPrimColor(gdl++, 0, 0, brightness, brightness >> 2, 0, 0xff); @@ -1302,10 +1302,10 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { brightness = 20; - if (buttonsdown & (D_JPAD | D_CBUTTONS)) { \ + if (buttonsdown & (D_CBUTTONS)) { \ brightness += 20; \ } \ - if (buttonsthisframe & (D_JPAD | D_CBUTTONS)) { + if (buttonsthisframe & (D_CBUTTONS)) { brightness += 20; } @@ -1313,11 +1313,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_DRUGSPY) { brightness = 127; - if (buttonsdown & (D_JPAD | D_CBUTTONS)) { + if (buttonsdown & (D_CBUTTONS)) { brightness += 63; } - if (buttonsthisframe & (D_JPAD | D_CBUTTONS)) { + if (buttonsthisframe & (D_CBUTTONS)) { brightness += 63; } @@ -1325,11 +1325,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else { brightness = 20; - if (buttonsdown & (D_JPAD | D_CBUTTONS)) { + if (buttonsdown & (D_CBUTTONS)) { brightness += 20; } - if (buttonsthisframe & (D_JPAD | D_CBUTTONS)) { + if (buttonsthisframe & (D_CBUTTONS)) { brightness += 20; } @@ -1343,10 +1343,10 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { brightness = 20; - if (buttonsdown & (L_JPAD | L_CBUTTONS)) { \ + if (buttonsdown & (L_CBUTTONS)) { \ brightness += 20; \ } \ - if (buttonsthisframe & (L_JPAD | L_CBUTTONS)) { + if (buttonsthisframe & (L_CBUTTONS)) { brightness += 20; } @@ -1354,11 +1354,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_DRUGSPY) { brightness = 127; - if (buttonsdown & (L_JPAD | L_CBUTTONS)) { + if (buttonsdown & (L_CBUTTONS)) { brightness += 63; } - if (buttonsthisframe & (L_JPAD | L_CBUTTONS)) { + if (buttonsthisframe & (L_CBUTTONS)) { brightness += 63; } @@ -1366,11 +1366,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else { brightness = 20; - if (buttonsdown & (L_JPAD | L_CBUTTONS)) { + if (buttonsdown & (L_CBUTTONS)) { brightness += 20; } - if (buttonsthisframe & (L_JPAD | L_CBUTTONS)) { + if (buttonsthisframe & (L_CBUTTONS)) { brightness += 20; } @@ -1384,10 +1384,10 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { brightness = 20; - if (buttonsdown & (R_JPAD | R_CBUTTONS)) { \ + if (buttonsdown & (R_CBUTTONS)) { \ brightness += 20; \ } \ - if (buttonsthisframe & (R_JPAD | R_CBUTTONS)) { + if (buttonsthisframe & (R_CBUTTONS)) { brightness += 20; } @@ -1395,11 +1395,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_DRUGSPY) { brightness = 127; - if (buttonsdown & (R_JPAD | R_CBUTTONS)) { + if (buttonsdown & (R_CBUTTONS)) { brightness += 63; } - if (buttonsthisframe & (R_JPAD | R_CBUTTONS)) { + if (buttonsthisframe & (R_CBUTTONS)) { brightness += 63; } @@ -1407,11 +1407,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else { brightness = 20; - if (buttonsdown & (R_JPAD | R_CBUTTONS)) { + if (buttonsdown & (R_CBUTTONS)) { brightness += 20; } - if (buttonsthisframe & (R_JPAD | R_CBUTTONS)) { + if (buttonsthisframe & (R_CBUTTONS)) { brightness += 20; } @@ -1425,10 +1425,10 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_CAMSPY) { brightness = 20; - if (buttonsdown & (L_TRIG | R_TRIG)) { \ + if (buttonsdown & (R_TRIG)) { \ brightness += 20; \ } \ - if (buttonsthisframe & (L_TRIG | R_TRIG)) { + if (buttonsthisframe & (R_TRIG)) { brightness += 20; } @@ -1436,11 +1436,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else if (g_Vars.currentplayer->eyespy->mode == EYESPYMODE_DRUGSPY) { brightness = 127; - if (buttonsdown & (L_TRIG | R_TRIG)) { + if (buttonsdown & (R_TRIG)) { brightness += 63; } - if (buttonsthisframe & (L_TRIG | R_TRIG)) { + if (buttonsthisframe & (R_TRIG)) { brightness += 63; } @@ -1448,11 +1448,11 @@ Gfx *bviewDrawEyespyMetrics(Gfx *gdl) } else { brightness = 20; - if (buttonsdown & (L_TRIG | R_TRIG)) { + if (buttonsdown & (R_TRIG)) { brightness += 20; } - if (buttonsthisframe & (L_TRIG | R_TRIG)) { + if (buttonsthisframe & (R_TRIG)) { brightness += 20; } diff --git a/src/game/credits.c b/src/game/credits.c index 5b09ea062..63abc378f 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -684,7 +684,7 @@ void creditsTickParticles(void) } } else { #if VERSION >= VERSION_NTSC_1_0 - if (RANDOMFRAC() < 0.007f && joyGetButtons(0, L_TRIG | R_TRIG) == 0) { + if (RANDOMFRAC() < 0.007f && joyGetButtons(0, R_TRIG) == 0) { g_CreditsData->particlecolourindex1 = random() % 4; g_CreditsData->particlecolourweight = 0; } @@ -697,7 +697,7 @@ void creditsTickParticles(void) } #if VERSION >= VERSION_NTSC_1_0 - if (RANDOMFRAC() < 0.002f && joyGetButtons(0, L_TRIG | R_TRIG) == 0) { + if (RANDOMFRAC() < 0.002f && joyGetButtons(0, R_TRIG) == 0) { g_CreditsData->particlemovetype = random() % 5; } #else @@ -1681,7 +1681,7 @@ void creditsTick(void) static u32 type = 0xffff; #if VERSION >= VERSION_NTSC_1_0 - if (joyGetButtonsPressedThisFrame(0, L_TRIG)) { + if (joyGetButtonsPressedThisFrame(0, R_TRIG)) { creditsCreatePendingBgLayers(0xffffffff); } #endif @@ -1721,7 +1721,7 @@ void creditsTick(void) if (g_CreditsData->slidesenabled) { creditsTickSlide(); - } else if (RANDOMFRAC() < 0.01f && !joyGetButtons(0, L_TRIG | R_TRIG)) { + } else if (RANDOMFRAC() < 0.01f && !joyGetButtons(0, R_TRIG)) { creditsCreatePendingBgLayers(0xffffffff); } diff --git a/src/game/debug2.c b/src/game/debug2.c index c54053039..ca6f4acf3 100644 --- a/src/game/debug2.c +++ b/src/game/debug2.c @@ -580,26 +580,6 @@ bool debugProcessInput(s8 stickx, s8 sticky, u16 buttons, u16 buttonsthisframe) var80075d68 = -2; } - if (buttonsthisframe & L_JPAD) { - dmenuNavigateLeft(); - var80075d68 = -2; - } - - if (buttonsthisframe & R_JPAD) { - dmenuNavigateRight(); - var80075d68 = -2; - } - - if (buttonsthisframe & U_JPAD) { - dmenuNavigateUp(); - var80075d68 = -2; - } - - if (buttonsthisframe & D_JPAD) { - dmenuNavigateDown(); - var80075d68 = -2; - } - if (buttonsthisframe & (A_BUTTON | START_BUTTON)) { if (g_DebugCurMenu == DEBUGMENU_CUTSCENE) { if (dmenuGetSelectedOption() == 0) { diff --git a/src/game/lv.c b/src/game/lv.c index e228b4cf3..a5ace237a 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -1295,11 +1295,18 @@ Gfx *lvRender(Gfx *gdl) } // Handle opening doors and reloading - if (g_Vars.currentplayer->bondactivateorreload) { - if (currentPlayerInteract(false)) { + if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_RELOAD) { + if (g_Vars.currentplayer->hands[HAND_RIGHT].state != HANDSTATE_RELOAD){ bgunReloadIfPossible(HAND_RIGHT); + + } + if (g_Vars.currentplayer->hands[HAND_LEFT].state != HANDSTATE_RELOAD) { bgunReloadIfPossible(HAND_LEFT); } + g_Vars.currentplayer->bondactivateorreload = (g_Vars.currentplayer->bondactivateorreload & ~JO_ACTION_RELOAD) | (g_Vars.currentplayer->bondactivateorreload & 0x0); + } + if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_ACTIVATE) { + currentPlayerInteract(false); } else if (g_Vars.currentplayer->eyespy && g_Vars.currentplayer->eyespy->active && g_Vars.currentplayer->eyespy->opendoor) { diff --git a/src/game/menu.c b/src/game/menu.c index c31e27734..ef60cac09 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -2143,7 +2143,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) modelGetRootPosition(&thing->bodymodel, &oldpos); - if (joyGetButtons(0, L_TRIG)) { + if (joyGetButtons(0, R_TRIG)) { modelSetRootPosition(&thing->bodymodel, &newpos); } } @@ -4617,10 +4617,6 @@ void menuProcessInput(void) inputs.shoulder = 1; } - if (buttons & L_TRIG) { - inputs.shoulder = 1; - } - if ((stickx < 0 ? -stickx : stickx) < (thisstickx < 0 ? -thisstickx : thisstickx)) { stickx = thisstickx; } @@ -4661,37 +4657,6 @@ void menuProcessInput(void) xtapdir = 1; } - if (buttons & U_JPAD) { - yhelddir = -1; - } - - if (buttonsnow & U_JPAD) { - ytapdir = -1; - } - - if (buttons & D_JPAD) { - yhelddir = 1; - } - - if (buttonsnow & D_JPAD) { - ytapdir = 1; - } - - if (buttons & L_JPAD) { - xhelddir = -1; - } - - if (buttonsnow & L_JPAD) { - xtapdir = -1; - } - - if (buttons & R_JPAD) { - xhelddir = 1; - } - - if (buttonsnow & R_JPAD) { - xtapdir = 1; - } } // Prevent select and going back on the same frame diff --git a/src/game/player.c b/src/game/player.c index 9be5e7989..950ccf151 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -806,6 +806,8 @@ void playerLoadDefaults(void) g_Vars.currentplayer->prevoverexposurered = 0; g_Vars.currentplayer->prevoverexposuregreen = 0; g_Vars.currentplayer->prevoverexposureblue = 0; + g_Vars.currentplayer->amdowntime = 0; + g_Vars.currentplayer->altdowntime = 0; } bool playerSpawnAnti(struct chrdata *hostchr, bool force) @@ -3518,7 +3520,7 @@ void playerTick(bool arg0) explode = true; } - if (joyGetButtons(contpad1, B_BUTTON | Z_TRIG | L_TRIG | R_TRIG)) { + if (joyGetButtons(contpad1, B_BUTTON | Z_TRIG | R_TRIG)) { slow = true; } } else { @@ -3526,7 +3528,7 @@ void playerTick(bool arg0) explode = true; } - if (joyGetButtons(contpad1, A_BUTTON | B_BUTTON | L_TRIG | R_TRIG)) { + if (joyGetButtons(contpad1, A_BUTTON | B_BUTTON | R_TRIG)) { slow = true; } } @@ -4101,7 +4103,7 @@ void playerTick(bool arg0) if (!lvIsPaused() && arg0 - && joyGetButtonsPressedThisFrame(contpad1, A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | L_TRIG | R_TRIG)) { + && joyGetButtonsPressedThisFrame(contpad1, A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | R_TRIG)) { var8007074c = 2; if (playerIsFadeComplete()) { diff --git a/src/include/constants.h b/src/include/constants.h index 3a8e7ea97..c4b948425 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -4615,3 +4615,6 @@ enum weaponnum { #define BODY_DARK_NEGOTIATOR 0x96 #endif + +#define JO_ACTION_ACTIVATE 0x0001 +#define JO_ACTION_RELOAD 0x0002 diff --git a/src/include/game/bondgun.h b/src/include/game/bondgun.h index e704cdcad..5bc113d38 100644 --- a/src/include/game/bondgun.h +++ b/src/include/game/bondgun.h @@ -145,7 +145,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum); void bgunPlayGlassHitSound(struct coord *pos, RoomNum *rooms, s32 texturenum); void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, RoomNum *rooms); void bgunSetTriggerOn(s32 handnum, bool on); -s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu); +s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton); void bgun0f0a8c50(void); bool bgunIsUsingSecondaryFunction(void); void bgunTickGameplay(bool triggeron); diff --git a/src/include/types.h b/src/include/types.h index 3bf6ab3e7..a0749d2cd 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2816,6 +2816,8 @@ struct player { /*0x1c64*/ s32 unk1c64; /*0x1c68*/ u32 unk1c68; /*0x1c6c*/ u32 unk1c6c; + s16 altdowntime; // for alt-modes, used like invdowntime and amdowntime + s16 amdowntime; // for alt-modes, used like invdowntime and amdowntime }; struct ailist { @@ -5047,6 +5049,7 @@ struct movedata { /* */ f32 freelookdx; // how much the mouse moved ... /* */ f32 freelookdy; // ... in normalized window coordinates #endif + /*0xac*/ s32 alt1tapcount; }; struct attackanimgroup {