forked from Ports/perfect_dark
port: add hold crouch
This commit is contained in:
1 parent
3328e147eb
commit
e43d29f357
6 files changed
+70
-41
No files matched your search
+1
-1
@@ -160,6 +160,6 @@ PD_CONSTRUCTOR static void gameConfigInit(void)
|
||||
configRegisterFloat(strFmt("Game.Player%d.MouseAimSpeedY", i), &g_PlayerExtCfg[j].mouseaimspeedy, 0.f, 10.f);
|
||||
configRegisterFloat(strFmt("Game.Player%d.RadialMenuSpeed", i), &g_PlayerExtCfg[j].radialmenuspeed, 0.f, 10.f);
|
||||
configRegisterFloat(strFmt("Game.Player%d.CrosshairSway", i), &g_PlayerExtCfg[j].crosshairsway, 0.f, 10.f);
|
||||
configRegisterInt(strFmt("Game.Player%d.ClassicCrouch", i), &g_PlayerExtCfg[j].classiccrouch, 0, 1);
|
||||
configRegisterInt(strFmt("Game.Player%d.CrouchMode", i), &g_PlayerExtCfg[j].crouchmode, 0, CROUCHMODE_TOGGLE_ANALOG);
|
||||
}
|
||||
}
|
||||
+28
-16
@@ -723,6 +723,31 @@ struct menudialogdef g_ExtendedVideoMenuDialog = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static MenuItemHandlerResult menuhandlerCrouchMode(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
static const char *opts[] = {
|
||||
"Hold",
|
||||
"Analog",
|
||||
"Toggle",
|
||||
"Toggle + Analog"
|
||||
};
|
||||
|
||||
switch (operation) {
|
||||
case MENUOP_GETOPTIONCOUNT:
|
||||
data->dropdown.value = ARRAYCOUNT(opts);
|
||||
break;
|
||||
case MENUOP_GETOPTIONTEXT:
|
||||
return (intptr_t)opts[data->dropdown.value];
|
||||
case MENUOP_SET:
|
||||
g_PlayerExtCfg[g_ExtMenuPlayer].crouchmode = data->dropdown.value;
|
||||
break;
|
||||
case MENUOP_GETSELECTEDINDEX:
|
||||
data->dropdown.value = g_PlayerExtCfg[g_ExtMenuPlayer].crouchmode;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MenuItemHandlerResult menuhandlerFieldOfView(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
switch (operation) {
|
||||
@@ -742,19 +767,6 @@ static MenuItemHandlerResult menuhandlerFieldOfView(s32 operation, struct menuit
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MenuItemHandlerResult menuhandlerClassicCrouch(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
switch (operation) {
|
||||
case MENUOP_GET:
|
||||
return g_PlayerExtCfg[g_ExtMenuPlayer].classiccrouch;
|
||||
case MENUOP_SET:
|
||||
g_PlayerExtCfg[g_ExtMenuPlayer].classiccrouch = data->checkbox.value;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MenuItemHandlerResult menuhandlerCrosshairSway(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
switch (operation) {
|
||||
@@ -771,12 +783,12 @@ static MenuItemHandlerResult menuhandlerCrosshairSway(s32 operation, struct menu
|
||||
|
||||
struct menuitem g_ExtendedGameMenuItems[] = {
|
||||
{
|
||||
MENUITEMTYPE_CHECKBOX,
|
||||
MENUITEMTYPE_DROPDOWN,
|
||||
0,
|
||||
MENUITEMFLAG_LITERAL_TEXT,
|
||||
(uintptr_t)"Allow Classic Crouch",
|
||||
(uintptr_t)"Crouch Mode",
|
||||
0,
|
||||
menuhandlerClassicCrouch,
|
||||
menuhandlerCrouchMode,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SLIDER,
|
||||
|
||||
+34
-22
@@ -1565,31 +1565,43 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
|
||||
// Handle xbla-style crouch cycling
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
s32 crouchsample = joyGetButtonsPressedOnSample(i, contpad1, 0xffffffff) & BUTTON_CROUCH_CYCLE;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos <= 0) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_STAND;
|
||||
} else {
|
||||
g_Vars.currentplayer->crouchpos--;
|
||||
}
|
||||
}
|
||||
|
||||
// handle 1964GEPD style crouch setting
|
||||
crouchsample = joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons) & BUTTON_HALF_CROUCH;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos == CROUCHPOS_DUCK) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_STAND;
|
||||
} else {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_DUCK;
|
||||
s32 crouchsample;
|
||||
if (PLAYER_EXTCFG().crouchmode & CROUCHMODE_TOGGLE) {
|
||||
// press to toggle crouch position
|
||||
crouchsample = joyGetButtonsPressedOnSample(i, contpad1, 0xffffffff) & BUTTON_CROUCH_CYCLE;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos <= 0) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_STAND;
|
||||
} else {
|
||||
g_Vars.currentplayer->crouchpos--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
crouchsample = joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons) & BUTTON_FULL_CROUCH;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos == CROUCHPOS_SQUAT) {
|
||||
crouchsample = joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons) & BUTTON_HALF_CROUCH;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos == CROUCHPOS_DUCK) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_STAND;
|
||||
} else {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_DUCK;
|
||||
}
|
||||
}
|
||||
crouchsample = joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons) & BUTTON_FULL_CROUCH;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos == CROUCHPOS_SQUAT) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_STAND;
|
||||
} else {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_SQUAT;
|
||||
}
|
||||
}
|
||||
} else if (PLAYER_EXTCFG().crouchmode == CROUCHMODE_HOLD) {
|
||||
// hold to crouch
|
||||
crouchsample = joyGetButtonsOnSample(i, contpad1, c1allowedbuttons) & (BUTTON_FULL_CROUCH | BUTTON_HALF_CROUCH);
|
||||
if (!crouchsample) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_STAND;
|
||||
} else {
|
||||
} else if (crouchsample & BUTTON_FULL_CROUCH) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_SQUAT;
|
||||
} else if (crouchsample & BUTTON_HALF_CROUCH) {
|
||||
g_Vars.currentplayer->crouchpos = CROUCHPOS_DUCK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1657,7 +1669,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
#endif
|
||||
|
||||
// Handle C-button and analog crouch and uncrouch, if enabled
|
||||
if (PLAYER_EXTCFG().classiccrouch && allowc1buttons) {
|
||||
if ((PLAYER_EXTCFG().crouchmode & CROUCHMODE_ANALOG) && allowc1buttons) {
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
if (!canmanualzoom && aimonhist[i]) {
|
||||
bool goUp = joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & (U_CBUTTONS));
|
||||
|
||||
@@ -120,7 +120,7 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
|
||||
.mouseaimspeedy = 0.7f, \
|
||||
.radialmenuspeed = 4.f, \
|
||||
.crosshairsway = 1.f, \
|
||||
.classiccrouch = true, \
|
||||
.crouchmode = CROUCHMODE_TOGGLE_ANALOG, \
|
||||
}
|
||||
|
||||
struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS] = {
|
||||
|
||||
@@ -4701,6 +4701,11 @@ enum weaponnum {
|
||||
#define MOUSEAIM_CLASSIC 0 // crosshair moves around the screen in aim mode
|
||||
#define MOUSEAIM_LOCKED 1 // crosshair locked to the center of the screen in aim mode
|
||||
|
||||
#define CROUCHMODE_HOLD 0 // hold the crouch buttons to keep crouching
|
||||
#define CROUCHMODE_ANALOG 1 // analog crouch like on n64
|
||||
#define CROUCHMODE_TOGGLE 2 // press the crouch buttons to toggle stance
|
||||
#define CROUCHMODE_TOGGLE_ANALOG (CROUCHMODE_ANALOG | CROUCHMODE_TOGGLE)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -6132,7 +6132,7 @@ struct extplayerconfig {
|
||||
s32 mouseaimmode;
|
||||
f32 mouseaimspeedx;
|
||||
f32 mouseaimspeedy;
|
||||
s32 classiccrouch;
|
||||
s32 crouchmode;
|
||||
f32 radialmenuspeed;
|
||||
f32 crosshairsway;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user