From 5a0580005f01b7a5e7c972c942107a82e82a394c Mon Sep 17 00:00:00 2001 From: Phnod Date: Sun, 20 Aug 2023 13:57:09 -0400 Subject: [PATCH 01/11] Added scrollwheel weapon swapping --- port/src/input.c | 6 +++--- src/game/bondmove.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index a15269e61..da99ccd73 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -66,9 +66,9 @@ void inputSetDefaultKeyBinds(void) { 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_DPAD_U, 0, 0 }, + { CK_DPAD_R, VK_MOUSE_WHEEL_UP, 0 }, + { CK_DPAD_L, VK_MOUSE_WHEEL_DN, 0 }, { CK_C_D, SDL_SCANCODE_S, 0 }, { CK_C_U, SDL_SCANCODE_W, 0 }, { CK_C_R, SDL_SCANCODE_D, 0 }, diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 1c425466b..da0e3ae41 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -903,6 +903,14 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } else { for (i = 0; i < numsamples; i++) { + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & L_JPAD)) { + movedata.weaponforwardoffset++; + g_Vars.currentplayer->invdowntime = -1; + } else + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & R_JPAD)) { + movedata.weaponbackoffset++; + g_Vars.currentplayer->invdowntime = -1; + } if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & A_BUTTON) || joyGetButtonsOnSample(i, contpad2, c2allowedbuttons & A_BUTTON)) { if (g_Vars.currentplayer->invdowntime > -2) { @@ -1275,6 +1283,14 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } else { for (i = 0; i < numsamples; i++) { + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & L_JPAD)) { + movedata.weaponforwardoffset++; + g_Vars.currentplayer->invdowntime = -1; + } else + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & R_JPAD)) { + movedata.weaponbackoffset++; + g_Vars.currentplayer->invdowntime = -1; + } if (joyGetButtonsOnSample(i, contpad1, invbuttons & c1allowedbuttons)) { if (g_Vars.currentplayer->invdowntime > -2) { if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons)) { From 3f6f0b3f9c996ac47fa6def0cef2c9e3b894b62e Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sun, 20 Aug 2023 14:14:31 -0700 Subject: [PATCH 02/11] map sensible xbox inputs xbox A is mapped to n64 B for using items n64 A is unmapped for controller. When radial / weapon switching is mapped way from n64 A n64 A can be remapped as a cancel button . Trigger will need to be used for the menus until --- port/src/input.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index da99ccd73..185645096 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -80,10 +80,12 @@ void inputSetDefaultKeyBinds(void) }; static const u32 joybinds[][2] = { - { CK_A, SDL_CONTROLLER_BUTTON_A }, - { CK_B, SDL_CONTROLLER_BUTTON_B }, + // { CK_A, SDL_CONTROLLER_BUTTON_A }, + { CK_B, SDL_CONTROLLER_BUTTON_A }, { CK_X, SDL_CONTROLLER_BUTTON_X }, - { CK_Y, SDL_CONTROLLER_BUTTON_Y }, + { CK_Y, SDL_CONTROLLER_BUTTON_BACK }, + { CK_DPAD_L, SDL_CONTROLLER_BUTTON_Y, }, + { CK_DPAD_R, SDL_CONTROLLER_BUTTON_B, }, { CK_DPAD_D, SDL_CONTROLLER_BUTTON_LEFTSHOULDER }, { CK_LTRIG, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER }, { CK_RTRIG, VK_JOY1_LTRIG - VK_JOY1_BEGIN }, From f88493870a7796c944feb6747ca818f5aa37609e Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sun, 20 Aug 2023 21:54:10 -0700 Subject: [PATCH 03/11] Address multiple extended input nits - Q for radial menu - mapped remaining xbla buttons, but the menus follow switch controller handfeel - based on @Phnod's switch-weapons PR: https://github.com/fgsfdsfgs/perfect_dark/pull/57 --- include/PR/os_cont.h | 30 +++++++++ port/src/input.c | 15 ++--- src/game/bondbike.c | 2 +- src/game/bondeyespy.c | 5 ++ src/game/bondgrab.c | 4 +- src/game/bondmove.c | 148 ++++++++++++++++++++++++------------------ src/game/bondwalk.c | 2 +- src/game/menu.c | 11 ++++ 8 files changed, 142 insertions(+), 75 deletions(-) diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h index 5d81bab62..d176c7701 100644 --- a/include/PR/os_cont.h +++ b/include/PR/os_cont.h @@ -171,6 +171,36 @@ typedef struct { #define CONT_ERR_VOICE_NO_RESPONSE 15 + + +#ifdef PLATFORM_N64 + +#define BUTTON_ACCEPT_WPNFORWARD CONT_A +#define BUTTON_CANCEL_USE CONT_B + +#define BUTTON_USE BUTTON_CANCEL_USE +#define BUTTON_CANCEL BUTTON_CANCEL_USE +#define BUTTON_RELOAD BUTTON_USE +#define BUTTON_ACCEPT BUTTON_ACCEPT_WPNFORWARD +#define BUTTON_WPNFORWARD BUTTON_ACCEPT_WPNFORWARD + +#else + +// xbla behavior +#define BUTTON_ACCEPT_USE A_BUTTON +// 1964 behavior +#define BUTTON_CANCEL_USE B_BUTTON + +#define BUTTON_RELOAD X_BUTTON +// dedicated button for mousewheel / xbla parity +#define BUTTON_WPNBACK L_JPAD +// dedicated button for mousewheel / xbla parity +#define BUTTON_WPNFORWARD Y_BUTTON +#define BUTTON_RADIAL D_JPAD +#define BUTTON_ALTMODE L_TRIG +#endif + + #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) /************************************************************************** diff --git a/port/src/input.c b/port/src/input.c index 185645096..eb3c6d87e 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -57,18 +57,16 @@ 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_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_D, SDL_SCANCODE_Q, VK_MOUSE_MIDDLE }, { CK_DPAD_U, 0, 0 }, - { CK_DPAD_R, VK_MOUSE_WHEEL_UP, 0 }, - { CK_DPAD_L, VK_MOUSE_WHEEL_DN, 0 }, + { CK_Y, VK_MOUSE_WHEEL_DN, 0 }, + { CK_DPAD_L, VK_MOUSE_WHEEL_UP, 0 }, { CK_C_D, SDL_SCANCODE_S, 0 }, { CK_C_U, SDL_SCANCODE_W, 0 }, { CK_C_R, SDL_SCANCODE_D, 0 }, @@ -80,12 +78,11 @@ void inputSetDefaultKeyBinds(void) }; static const u32 joybinds[][2] = { - // { CK_A, SDL_CONTROLLER_BUTTON_A }, { CK_B, SDL_CONTROLLER_BUTTON_A }, + { CK_A, SDL_CONTROLLER_BUTTON_B }, { CK_X, SDL_CONTROLLER_BUTTON_X }, - { CK_Y, SDL_CONTROLLER_BUTTON_BACK }, - { CK_DPAD_L, SDL_CONTROLLER_BUTTON_Y, }, - { CK_DPAD_R, SDL_CONTROLLER_BUTTON_B, }, + { CK_Y, SDL_CONTROLLER_BUTTON_Y }, + { CK_DPAD_L, SDL_CONTROLLER_BUTTON_B, }, { CK_DPAD_D, SDL_CONTROLLER_BUTTON_LEFTSHOULDER }, { CK_LTRIG, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER }, { CK_RTRIG, VK_JOY1_LTRIG - VK_JOY1_BEGIN }, diff --git a/src/game/bondbike.c b/src/game/bondbike.c index ce29b43f5..b08e91856 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -192,7 +192,7 @@ void bbikeHandleActivate(void) bmoveSetMode(MOVEMODE_WALK); } - g_Vars.currentplayer->bondactivateorreload = 0; + // g_Vars.currentplayer->bondactivateorreload = 0; } } diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index 900e0ec38..8ffe51e9a 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -752,8 +752,13 @@ void eyespyProcessInput(bool allowbuttons) shootpressed = c1buttons & Z_TRIG; } + #ifdef PLATFORM_N64 exitpressed = (c1buttons | c2buttons) & A_BUTTON; activatepressed = (c1buttons | c2buttons) & B_BUTTON; + #else + exitpressed = (c1buttons | c2buttons) & BUTTON_ACCEPT_USE; + activatepressed = (c1buttons | c2buttons) & BUTTON_CANCEL_USE; + #endif } // Apply safe zone for c1stickx diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index cfca0b60f..a7ebbbb96 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -891,9 +891,9 @@ void bgrabUpdateVertical(void) void bgrabHandleActivate(void) { if (currentPlayerTryMountHoverbike(g_Vars.currentplayer->grabbedprop)) { - g_Vars.currentplayer->bondactivateorreload = 0; + // g_Vars.currentplayer->bondactivateorreload = 0; } else { - g_Vars.currentplayer->bondactivateorreload = 0; + // g_Vars.currentplayer->bondactivateorreload = 0; bmoveSetMode(MOVEMODE_WALK); } } diff --git a/src/game/bondmove.c b/src/game/bondmove.c index da0e3ae41..d1cc1c8dd 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -903,14 +903,15 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } else { for (i = 0; i < numsamples; i++) { - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & L_JPAD)) { + #ifndef PLATFORM_N64 + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & BUTTON_WPNFORWARD)) { movedata.weaponforwardoffset++; g_Vars.currentplayer->invdowntime = -1; - } else - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & R_JPAD)) { + } else if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & BUTTON_WPNBACK)) { movedata.weaponbackoffset++; g_Vars.currentplayer->invdowntime = -1; } + #else if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & A_BUTTON) || joyGetButtonsOnSample(i, contpad2, c2allowedbuttons & A_BUTTON)) { if (g_Vars.currentplayer->invdowntime > -2) { @@ -937,10 +938,12 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i g_Vars.currentplayer->invdowntime = 0; } + #endif } } } + #ifdef PLATFORM_N64 // Handle B button activation if (allowc1buttons) { for (i = 0; i < numsamples; i++) { @@ -982,6 +985,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } } + #endif // Handle manual zoom in and out (sniper, farsight and horizon scanner) if (canmanualzoom && g_Vars.currentplayer->insightaimmode) { @@ -1283,14 +1287,15 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } else { for (i = 0; i < numsamples; i++) { - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & L_JPAD)) { + #ifndef PLATFORM_N64 + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & BUTTON_WPNFORWARD)) { movedata.weaponforwardoffset++; g_Vars.currentplayer->invdowntime = -1; - } else - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & R_JPAD)) { + } else if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & BUTTON_WPNBACK)) { movedata.weaponbackoffset++; g_Vars.currentplayer->invdowntime = -1; } + #else if (joyGetButtonsOnSample(i, contpad1, invbuttons & c1allowedbuttons)) { if (g_Vars.currentplayer->invdowntime > -2) { if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons)) { @@ -1318,10 +1323,12 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i g_Vars.currentplayer->invdowntime = 0; } + #endif } } } + #ifdef PLATFORM_N64 // Handle B button if (allowc1buttons) { for (i = 0; i < numsamples; i++) { @@ -1364,75 +1371,92 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } } + #endif - // 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; + #ifndef PLATFORM_N64 + if (allowc1buttons) { + // handle B / A: cancel_use + for (i = 0; i < numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & (BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE))) { + g_Vars.currentplayer->usedowntime++; + } else { + if (g_Vars.currentplayer->usedowntime > 0) { + movedata.btapcount++; + g_Vars.currentplayer->usedowntime = 0; } + } - if (g_Vars.currentplayer->altdowntime != -4) { - if (g_Vars.currentplayer->altdowntime <= 0) { - g_Vars.currentplayer->altdowntime++; + } + // handle L button : alt switching + for (i = 0; i< numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & BUTTON_ALTMODE)) { + 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; } - } - } 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; + 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 { - if (g_Vars.currentplayer->amdowntime >= 0) { - if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & D_JPAD)) { - amOpen(); - g_Vars.currentplayer->amdowntime = -1; - } else { - g_Vars.currentplayer->amdowntime++; + // 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 & BUTTON_RELOAD)) { + movedata.alt1tapcount++; + } + } + + + // Handle radial menu (D-Down) + for (i = 0; i < numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & BUTTON_RADIAL)) { + 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 & BUTTON_RADIAL)) { + amOpen(); + g_Vars.currentplayer->amdowntime = -1; + } else { + g_Vars.currentplayer->amdowntime++; + } + } + } + } else { + g_Vars.currentplayer->amdowntime = 0; } - } else { - g_Vars.currentplayer->amdowntime = 0; } } + #endif // Handle manual zoom in and out (sniper, farsight and horizon scanner) if (canmanualzoom && g_Vars.currentplayer->insightaimmode) { diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index 45120d8b3..b364cfe4d 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -1280,7 +1280,7 @@ void bwalkUpdatePrevPos(void) void bwalkHandleActivate(void) { if (g_Vars.currentplayer->walkinitmove) { - g_Vars.currentplayer->bondactivateorreload = 0; + // g_Vars.currentplayer->bondactivateorreload = 0; } } diff --git a/src/game/menu.c b/src/game/menu.c index cc88cc78d..e95c69c68 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -4607,6 +4607,17 @@ void menuProcessInput(void) inputs.select = 1; } + #ifndef PLATFORM_N64 + // this seems sensible to achieve 1964 parity + if (buttonsnow & BUTTON_RADIAL) { + inputs.select = 1; + } + // this will naturally feel nice w/ a switch layout + // with the default mapping for weapon-back + if (buttonsnow & BUTTON_WPNBACK) { + inputs.select = 1; + } + #endif if (buttonsnow & B_BUTTON) { inputs.back = 1; } From 077a091f7d3a4ca854b106c3fdaff9ac1c611383 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sun, 20 Aug 2023 23:10:38 -0700 Subject: [PATCH 04/11] fixup camspy bindings --- port/src/input.c | 4 ++-- src/game/bondeyespy.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index eb3c6d87e..2e57c2770 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -78,8 +78,8 @@ void inputSetDefaultKeyBinds(void) }; static const u32 joybinds[][2] = { - { CK_B, SDL_CONTROLLER_BUTTON_A }, - { CK_A, SDL_CONTROLLER_BUTTON_B }, + { CK_A, SDL_CONTROLLER_BUTTON_A }, + // { CK_A, SDL_CONTROLLER_BUTTON_B }, { CK_X, SDL_CONTROLLER_BUTTON_X }, { CK_Y, SDL_CONTROLLER_BUTTON_Y }, { CK_DPAD_L, SDL_CONTROLLER_BUTTON_B, }, diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index 8ffe51e9a..e6f23fd10 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -741,8 +741,13 @@ void eyespyProcessInput(bool allowbuttons) } else if (controlmode <= CONTROLMODE_14) { aimpressed = c1buttons & (R_TRIG); shootpressed = c1buttons & Z_TRIG; - exitpressed = c1buttons & A_BUTTON; - activatepressed = c1buttons & B_BUTTON; + #ifdef PLATFORM_N64 + exitpressed = (c1buttons | c2buttons) & A_BUTTON; + activatepressed = (c1buttons | c2buttons) & B_BUTTON; + #else + exitpressed = (c1buttons | c2buttons) & (BUTTON_WPNBACK | BUTTON_RADIAL); + activatepressed = (c1buttons | c2buttons) & (BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE); + #endif } else { if (controlmode >= CONTROLMODE_23) { aimpressed = c1buttons & Z_TRIG; @@ -752,13 +757,8 @@ void eyespyProcessInput(bool allowbuttons) shootpressed = c1buttons & Z_TRIG; } - #ifdef PLATFORM_N64 exitpressed = (c1buttons | c2buttons) & A_BUTTON; activatepressed = (c1buttons | c2buttons) & B_BUTTON; - #else - exitpressed = (c1buttons | c2buttons) & BUTTON_ACCEPT_USE; - activatepressed = (c1buttons | c2buttons) & BUTTON_CANCEL_USE; - #endif } // Apply safe zone for c1stickx From 10844e7a52776f45f5ee3f3b22beca19fbd2d0c7 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sun, 20 Aug 2023 23:17:57 -0700 Subject: [PATCH 05/11] fixup controller use buttons --- port/src/input.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index 2e57c2770..0a2e0e164 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -78,8 +78,7 @@ void inputSetDefaultKeyBinds(void) }; static const u32 joybinds[][2] = { - { CK_A, SDL_CONTROLLER_BUTTON_A }, - // { CK_A, SDL_CONTROLLER_BUTTON_B }, + { CK_B, SDL_CONTROLLER_BUTTON_A }, { CK_X, SDL_CONTROLLER_BUTTON_X }, { CK_Y, SDL_CONTROLLER_BUTTON_Y }, { CK_DPAD_L, SDL_CONTROLLER_BUTTON_B, }, From e95c7f144e575fdf40e479ece7a6d7c114b424ee Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sun, 20 Aug 2023 23:59:02 -0700 Subject: [PATCH 06/11] fixes AB remote detonation --- src/game/bondmove.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index d1cc1c8dd..ce17e4b3c 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1543,6 +1543,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } // Handle mine detonation + #ifdef PLATFORM_N64 if ((((c1buttons & invbuttons) && (c1buttonsthisframe & B_BUTTON)) || ((c1buttons & B_BUTTON) && (c1buttonsthisframe & invbuttons))) && weaponnum == WEAPON_REMOTEMINE) { @@ -1553,6 +1554,30 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i g_Vars.currentplayer->invdowntime = -2; g_Vars.currentplayer->usedowntime = -2; } + #else + if ((((c1buttons & BUTTON_RADIAL) && (c1buttonsthisframe & BUTTON_CANCEL_USE)) + || ((c1buttons & BUTTON_CANCEL_USE) && (c1buttonsthisframe & BUTTON_RADIAL))) + && weaponnum == WEAPON_REMOTEMINE) { + movedata.detonating = true; + movedata.weaponbackoffset = 0; + movedata.weaponforwardoffset = 0; + movedata.btapcount = 0; + amClose(); + g_Vars.currentplayer->invdowntime = -2; + g_Vars.currentplayer->usedowntime = -2; + g_Vars.currentplayer->amdowntime = 0; + } + if ((((c1buttons & BUTTON_WPNBACK) && (c1buttonsthisframe & BUTTON_CANCEL_USE)) + || ((c1buttons & BUTTON_CANCEL_USE) && (c1buttonsthisframe & BUTTON_WPNBACK))) + && weaponnum == WEAPON_REMOTEMINE) { + movedata.detonating = true; + movedata.weaponbackoffset = 0; + movedata.weaponforwardoffset = 0; + movedata.btapcount = 0; + g_Vars.currentplayer->invdowntime = -2; + g_Vars.currentplayer->usedowntime = -2; + } + #endif } movedata.aiming = g_Vars.currentplayer->insightaimmode; From 0d7bd746ac4272fa5692df33c143a1f2b2ef9afb Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Mon, 21 Aug 2023 20:27:49 -0700 Subject: [PATCH 07/11] move abstracted n64 buttons to contants.h --- include/PR/os_cont.h | 30 ------------------------------ src/include/constants.h | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h index d176c7701..5d81bab62 100644 --- a/include/PR/os_cont.h +++ b/include/PR/os_cont.h @@ -171,36 +171,6 @@ typedef struct { #define CONT_ERR_VOICE_NO_RESPONSE 15 - - -#ifdef PLATFORM_N64 - -#define BUTTON_ACCEPT_WPNFORWARD CONT_A -#define BUTTON_CANCEL_USE CONT_B - -#define BUTTON_USE BUTTON_CANCEL_USE -#define BUTTON_CANCEL BUTTON_CANCEL_USE -#define BUTTON_RELOAD BUTTON_USE -#define BUTTON_ACCEPT BUTTON_ACCEPT_WPNFORWARD -#define BUTTON_WPNFORWARD BUTTON_ACCEPT_WPNFORWARD - -#else - -// xbla behavior -#define BUTTON_ACCEPT_USE A_BUTTON -// 1964 behavior -#define BUTTON_CANCEL_USE B_BUTTON - -#define BUTTON_RELOAD X_BUTTON -// dedicated button for mousewheel / xbla parity -#define BUTTON_WPNBACK L_JPAD -// dedicated button for mousewheel / xbla parity -#define BUTTON_WPNFORWARD Y_BUTTON -#define BUTTON_RADIAL D_JPAD -#define BUTTON_ALTMODE L_TRIG -#endif - - #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) /************************************************************************** diff --git a/src/include/constants.h b/src/include/constants.h index e5fc90f8c..7e96a2f68 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -4626,7 +4626,35 @@ enum weaponnum { #define BODY_DARK_LEATHER 0x95 #define BODY_DARK_NEGOTIATOR 0x96 -#endif - #define JO_ACTION_ACTIVATE 0x0001 #define JO_ACTION_RELOAD 0x0002 + + +#ifdef PLATFORM_N64 + +#define BUTTON_ACCEPT_WPNFORWARD CONT_A +#define BUTTON_CANCEL_USE CONT_B + +#define BUTTON_USE BUTTON_CANCEL_USE +#define BUTTON_CANCEL BUTTON_CANCEL_USE +#define BUTTON_RELOAD BUTTON_USE +#define BUTTON_ACCEPT BUTTON_ACCEPT_WPNFORWARD +#define BUTTON_WPNFORWARD BUTTON_ACCEPT_WPNFORWARD + +#else + +// xbla behavior +#define BUTTON_ACCEPT_USE A_BUTTON +// 1964 behavior +#define BUTTON_CANCEL_USE B_BUTTON + +#define BUTTON_RELOAD X_BUTTON +// dedicated button for mousewheel / xbla parity +#define BUTTON_WPNBACK L_JPAD +// dedicated button for mousewheel / xbla parity +#define BUTTON_WPNFORWARD Y_BUTTON +#define BUTTON_RADIAL D_JPAD +#define BUTTON_ALTMODE L_TRIG +#endif + +#endif From df8c1139a1c9ec1808b748236204bb94296f9eac Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sat, 26 Aug 2023 16:27:41 -0700 Subject: [PATCH 08/11] fix: sniper crouching --- src/game/bondmove.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index ce17e4b3c..db6a05ae9 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1421,6 +1421,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } g_Vars.currentplayer->altdowntime = 0; + bgun0f0a8c50(); } } From 8ec0feb49b511a053adbc3b972c70a1769685383 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sat, 26 Aug 2023 17:16:41 -0700 Subject: [PATCH 09/11] fix: grabbable --- src/game/bondbike.c | 2 +- src/game/bondgrab.c | 4 ++-- src/game/bondmove.c | 35 +++++++++++------------------------ src/game/bondwalk.c | 2 +- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/game/bondbike.c b/src/game/bondbike.c index b08e91856..ce29b43f5 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -192,7 +192,7 @@ void bbikeHandleActivate(void) bmoveSetMode(MOVEMODE_WALK); } - // g_Vars.currentplayer->bondactivateorreload = 0; + g_Vars.currentplayer->bondactivateorreload = 0; } } diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index a7ebbbb96..cfca0b60f 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -891,9 +891,9 @@ void bgrabUpdateVertical(void) void bgrabHandleActivate(void) { if (currentPlayerTryMountHoverbike(g_Vars.currentplayer->grabbedprop)) { - // g_Vars.currentplayer->bondactivateorreload = 0; + g_Vars.currentplayer->bondactivateorreload = 0; } else { - // g_Vars.currentplayer->bondactivateorreload = 0; + g_Vars.currentplayer->bondactivateorreload = 0; bmoveSetMode(MOVEMODE_WALK); } } diff --git a/src/game/bondmove.c b/src/game/bondmove.c index db6a05ae9..3aa4f17f1 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1328,21 +1328,21 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } - #ifdef PLATFORM_N64 // Handle B button if (allowc1buttons) { for (i = 0; i < numsamples; i++) { - if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & B_BUTTON)) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & (B_BUTTON | BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE))) { if (g_Vars.currentplayer->usedowntime >= -1) { - if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) - && g_Vars.currentplayer->usedowntime >= 0 - && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) { - g_Vars.currentplayer->usedowntime = -3; - } + // if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) + // && g_Vars.currentplayer->usedowntime >= 0 + // && 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, 0); + // s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); + s32 result = USETIMER_CONTINUE; if (result == USETIMER_STOP) { g_Vars.currentplayer->usedowntime = -1; @@ -1356,9 +1356,9 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } } else { - if (g_Vars.currentplayer->usedowntime >= -2) { - bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); - } + // if (g_Vars.currentplayer->usedowntime >= -2) { + // bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); + // } } } else { // Released B @@ -1371,23 +1371,10 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } } - #endif #ifndef PLATFORM_N64 if (allowc1buttons) { - // handle B / A: cancel_use - for (i = 0; i < numsamples; i++) { - if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & (BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE))) { - g_Vars.currentplayer->usedowntime++; - } else { - if (g_Vars.currentplayer->usedowntime > 0) { - movedata.btapcount++; - g_Vars.currentplayer->usedowntime = 0; - } - } - - } // handle L button : alt switching for (i = 0; i< numsamples; i++) { if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & BUTTON_ALTMODE)) { diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index b364cfe4d..45120d8b3 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -1280,7 +1280,7 @@ void bwalkUpdatePrevPos(void) void bwalkHandleActivate(void) { if (g_Vars.currentplayer->walkinitmove) { - // g_Vars.currentplayer->bondactivateorreload = 0; + g_Vars.currentplayer->bondactivateorreload = 0; } } From 2a78f6902d71ff0005a9440aca7a7b4d625af5f0 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sat, 26 Aug 2023 17:56:36 -0700 Subject: [PATCH 10/11] handle b button differently if N64 platform --- src/game/bondmove.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 3aa4f17f1..ce7d29e58 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1328,21 +1328,26 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } - // Handle B button + // Handle B and use-like button if (allowc1buttons) { for (i = 0; i < numsamples; i++) { if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & (B_BUTTON | BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE))) { if (g_Vars.currentplayer->usedowntime >= -1) { - // if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) - // && g_Vars.currentplayer->usedowntime >= 0 - // && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) { - // g_Vars.currentplayer->usedowntime = -3; - // } + #ifdef PLATFORM_N64 + if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) + && g_Vars.currentplayer->usedowntime >= 0 + && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) { + g_Vars.currentplayer->usedowntime = -3; + } + #endif if (g_Vars.currentplayer->usedowntime >= 0) { if (g_Vars.currentplayer->usedowntime > TICKS(25)) { - // s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); + #ifdef PLATFORM_N64 + s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); + #else s32 result = USETIMER_CONTINUE; + #endif if (result == USETIMER_STOP) { g_Vars.currentplayer->usedowntime = -1; @@ -1356,9 +1361,11 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } } else { - // if (g_Vars.currentplayer->usedowntime >= -2) { - // bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); - // } + #ifdef PLATFORM_N64 + if (g_Vars.currentplayer->usedowntime >= -2) { + bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); + } + #endif } } else { // Released B From aa8e08e4d0110f4a2aca673dc1f966261378e19d Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sat, 26 Aug 2023 18:35:07 -0700 Subject: [PATCH 11/11] Update readme --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 508e4c34e..669c27007 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,25 @@ You must already have a Perfect Dark ROM to run the game, as specified above. 2. Put your Perfect Dark ROM named `pd.ntsc-final.z64` into it. 3. Run `pd.exe`. + +## Bindings + +1964-style and Xbox-style bindings are partially implemented. + +N64 controller literal X and Y refer to the RESERVED buttons which was previously leveraged by 1964. + + +| Action | keyboard | xbox | N64 literal | +|- | - | - | - | +| Use / Cancel Menu | e | n/a | b | +| Use / Accept Menu | n/a | a | a | +| reload | r | x | x `(0x40)` | +| weapon-back | Mousewheel-Forward | b | D-Left | +| weapon-forward | Mousewheel-Back | y | y `(0x80)` | +| radial menu | q | LB | D-Down | +| alt mode | f | RB | L-trigger | +| quick-detonate | e + q | a + b | a + D-Left | + ## Building ### Windows