Skip to content

Commit

Permalink
Merge pull request #879 from ichee/master
Browse files Browse the repository at this point in the history
Adds configurable hold delay for analog toggle
  • Loading branch information
LibretroAdmin committed Mar 24, 2023
2 parents 409c4a0 + d5bf156 commit 4d8558a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
29 changes: 29 additions & 0 deletions libretro.cpp
Expand Up @@ -3140,6 +3140,7 @@ static bool has_new_geometry = false;
static bool has_new_timing = false;

uint8_t analog_combo[2] = {0};
uint8_t HOLD = {0};

extern void PSXDitherApply(bool);

Expand Down Expand Up @@ -3692,6 +3693,34 @@ static void check_variables(bool startup)
}
}

var.key = BEETLE_OPT(analog_toggle_hold);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "0") == 0)
{
HOLD = 0;
}
else if (strcmp(var.value, "1") == 0)
{
HOLD = 1;
}
else if (strcmp(var.value, "2") == 0)
{
HOLD = 2;
}
else if (strcmp(var.value, "3") == 0)
{
HOLD = 3;
}
else if (strcmp(var.value, "4") == 0)
{
HOLD = 4;
}
else if (strcmp(var.value, "5") == 0)
{
HOLD = 5;
}
}
var.key = BEETLE_OPT(crosshair_color_p1);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
Expand Down
20 changes: 19 additions & 1 deletion libretro_core_options.h
Expand Up @@ -416,7 +416,25 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "l3+r3", "L3 + R3" },
{ NULL, NULL },
},
"l1+l2+r1+r2+start+select"
"l1+r1+select"
},
{
BEETLE_OPT(analog_toggle_hold),
"DualShock Analog Mode Combo Hold Delay",
NULL,
"Sets the hold time for the analog mode combo buttons. Only works when 'Enable DualShock Analog Mode Toggle' is enabled.",
NULL,
"input",
{
{ "0", "0 Second Delay" },
{ "1", "1 Second Delay" },
{ "2", "2 Second Delay" },
{ "3", "3 Second Delay" },
{ "4", "4 Second Delay" },
{ "5", "5 Second Delay" },
{ NULL, NULL },
},
"1"
},
{
BEETLE_OPT(enable_multitap_port1),
Expand Down
2 changes: 1 addition & 1 deletion mednafen/psx/input/dualshock.cpp
Expand Up @@ -178,7 +178,7 @@ void InputDevice_DualShock::CheckManualAnaModeChange(void)
{
if(combo_anatoggle_counter == -1)
combo_anatoggle_counter = 0;
else if(combo_anatoggle_counter >= (44100 * 768))
else if(combo_anatoggle_counter >= (44100 * (768 * HOLD)))
{
need_mode_toggle = true;
combo_anatoggle_counter = -2;
Expand Down
2 changes: 2 additions & 0 deletions mednafen/psx/psx.h
Expand Up @@ -136,4 +136,6 @@ extern unsigned psx_gpu_overclock_shift;

extern uint8_t analog_combo[2];

extern uint8_t HOLD;

#endif

0 comments on commit 4d8558a

Please sign in to comment.