Skip to content

Commit

Permalink
New in-game menu button action: "Quick menu" + fix quitting RetroArch…
Browse files Browse the repository at this point in the history
… from arcade games (#1620)

## Changes
- Add option in Tweaks:
  - In-game: Menu button - ... < Quick menu >
  - Toggles RetroArch's quick menu
- Use UDP protocol to exit RetroArch
  - Fixes issues with exiting from arcade games

## Try it

Test patch available here:
[Onion_v4.3.1-1__menu_button_UDP_actions.zip](https://github.com/user-attachments/files/15973842/Onion_v4.3.1-1__menu_button_UDP_actions.zip)
  • Loading branch information
Aemiii91 authored Dec 22, 2024
1 parent fb7eb75 commit d40c76a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
23 changes: 16 additions & 7 deletions src/keymon/menuButtonAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool terminate_retroarch(void)
// send signal
kill(pid, SIGCONT);
usleep(100000);
kill(pid, SIGTERM);
system("sendUDP QUIT");
// wait for terminate
sprintf(fname, "/proc/%d", pid);

Expand All @@ -105,11 +105,12 @@ bool terminate_drastic(void)

if (pid) {
// If swap L<>L2 is on, the off button combo becomes 1 + 15 instead of 1 + 18
if(temp_flag_get("drastic_swap_l1l2")) {
if (temp_flag_get("drastic_swap_l1l2")) {
system("sendkeys 1 1, 15 1");
usleep(200000); // 0.2s
system("sendkeys 1 0, 15 0");
} else {
}
else {
system("sendkeys 1 1, 18 1");
usleep(200000); // 0.2s
system("sendkeys 1 0, 18 0");
Expand Down Expand Up @@ -157,13 +158,15 @@ void action_MainUI_resumeGame(void)

void action_RA_gameSwitcher(void)
{
temp_flag_set(".displaySavingMessage", true);
screenshot_system();
set_gameSwitcher();
terminate_retroarch();
}

void action_RA_exitToMenu(void)
{
temp_flag_set(".displaySavingMessage", true);
screenshot_system();
terminate_retroarch();
}
Expand All @@ -175,15 +178,22 @@ void action_RA_quickSwitch(void)
terminate_retroarch();
}

void action_RA_toggleMenu(void)
{
system("sendUDP MENU_TOGGLE");
}

void action_drastic_gameSwitcher(void)
{
temp_flag_set(".displaySavingMessage", true);
screenshot_system();
set_gameSwitcher();
terminate_drastic();
}

void action_drastic_exitToMenu(void)
{
temp_flag_set(".displaySavingMessage", true);
screenshot_system();
terminate_drastic();
}
Expand Down Expand Up @@ -221,6 +231,9 @@ void activate_RA_action(int action_id)
case 3:
action_RA_quickSwitch();
break;
case 4:
action_RA_toggleMenu();
break;
default:
break;
}
Expand Down Expand Up @@ -250,11 +263,9 @@ void menuButtonEvent_singlePress(void)
activate_MainUI_action(settings.mainui_single_press);
break;
case MODE_GAME:
temp_flag_set(".displaySavingMessage", true);
activate_RA_action(settings.ingame_single_press);
break;
case MODE_DRASTIC:
temp_flag_set(".displaySavingMessage", true);
activate_drastic_action(settings.ingame_single_press);
break;
default:
Expand All @@ -272,13 +283,11 @@ void menuButtonEvent_longPress(void)
case MODE_GAME:
if (settings.ingame_long_press != 0)
short_pulse();
temp_flag_set(".displaySavingMessage", true);
activate_RA_action(settings.ingame_long_press);
break;
case MODE_DRASTIC:
if (settings.ingame_long_press != 0)
short_pulse();
temp_flag_set(".displaySavingMessage", true);
activate_drastic_action(settings.ingame_long_press);
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions src/tweaks/formatters.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
{ \
"Context menu", "GameSwitcher", "Resume game" \
}
#define BUTTON_INGAME_LABELS \
{ \
"Off", "GameSwitcher", "Exit to menu", "Quick switch" \
#define BUTTON_INGAME_LABELS \
{ \
"Off", "GameSwitcher", "Exit to menu", "Quick switch", "Quick menu" \
}

#define THEME_TOGGLE_LABELS \
Expand Down
6 changes: 3 additions & 3 deletions src/tweaks/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void menu_buttonActionInGameMenu(void *_)
(ListItem){
.label = "Single press",
.item_type = MULTIVALUE,
.value_max = 3,
.value_max = 4,
.value_labels = BUTTON_INGAME_LABELS,
.value = settings.ingame_single_press,
.action_id = 3,
Expand All @@ -283,7 +283,7 @@ void menu_buttonActionInGameMenu(void *_)
(ListItem){
.label = "Long press",
.item_type = MULTIVALUE,
.value_max = 3,
.value_max = 4,
.value_labels = BUTTON_INGAME_LABELS,
.value = settings.ingame_long_press,
.action_id = 4,
Expand All @@ -294,7 +294,7 @@ void menu_buttonActionInGameMenu(void *_)
(ListItem){
.label = "Double press",
.item_type = MULTIVALUE,
.value_max = 3,
.value_max = 4,
.value_labels = BUTTON_INGAME_LABELS,
.value = settings.ingame_double_press,
.action_id = 5,
Expand Down

0 comments on commit d40c76a

Please sign in to comment.