From 3a998763125441004bc61b79c2e1c24dc3c11b0a Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 21 May 2025 00:48:28 +0300 Subject: [PATCH] frontend: improve sdl gamepad support notaz/pcsx_rearmed#379 --- frontend/libpicofe | 2 +- frontend/menu.c | 11 +++++++++++ frontend/plat_sdl.c | 10 ++++++++++ frontend/plugin_lib.c | 8 +++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/frontend/libpicofe b/frontend/libpicofe index ab0990ab..5d8d9079 160000 --- a/frontend/libpicofe +++ b/frontend/libpicofe @@ -1 +1 @@ -Subproject commit ab0990ab434971e1ab1f7ebda61ce368bb7a4d11 +Subproject commit 5d8d9079236d022e7f0db795aa18616856d24451 diff --git a/frontend/menu.c b/frontend/menu.c index 0c4ebcea..851d3a81 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -436,6 +436,10 @@ static const struct { CE_INTVAL(memcard2_sel), CE_INTVAL(g_autostateld_opt), CE_INTVAL(cd_buf_count), + CE_INTVAL_N("adev0_axis0", in_adev_axis[0][0]), + CE_INTVAL_N("adev0_axis1", in_adev_axis[0][1]), + CE_INTVAL_N("adev1_axis0", in_adev_axis[1][0]), + CE_INTVAL_N("adev1_axis1", in_adev_axis[1][1]), CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]), CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]), CE_INTVAL_V(frameskip, 4), @@ -1113,6 +1117,10 @@ static void keys_load_all(const char *cfg) static int key_config_loop_wrap(int id, int keys) { + int d; + + for (d = 0; d < IN_MAX_DEVS; d++) + in_set_config_int(d, IN_CFG_ANALOG_MAP_ULDR, 0); switch (id) { case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, array_size(me_ctrl_actions) - 1, 0); @@ -1126,6 +1134,9 @@ static int key_config_loop_wrap(int id, int keys) default: break; } + for (d = 0; d < IN_MAX_DEVS; d++) + in_set_config_int(d, IN_CFG_ANALOG_MAP_ULDR, 1); + return 0; } diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index f207d2ae..00273147 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -660,6 +660,8 @@ void plat_gvideo_close(void) void plat_video_menu_enter(int is_rom_loaded) { + int d; + in_menu = 1; /* surface will be lost, must adjust pl_vout_buf for menu bg */ @@ -688,6 +690,9 @@ void plat_video_menu_enter(int is_rom_loaded) else overlay_or_gl_check_enable(); centered_clear(); + + for (d = 0; d < IN_MAX_DEVS; d++) + in_set_config_int(d, IN_CFG_ANALOG_MAP_ULDR, 1); } void plat_video_menu_begin(void) @@ -749,6 +754,8 @@ void plat_video_menu_end(void) void plat_video_menu_leave(void) { + int d; + in_menu = 0; if (plat_sdl_overlay != NULL || plat_sdl_gl_active) memset(shadow_fb, 0, g_menuscreen_w * g_menuscreen_h * 2); @@ -758,6 +765,9 @@ void plat_video_menu_leave(void) else overlay_or_gl_check_enable(); centered_clear(); + + for (d = 0; d < IN_MAX_DEVS; d++) + in_set_config_int(d, IN_CFG_ANALOG_MAP_ULDR, 0); } void *plat_prepare_screenshot(int *w, int *h, int *bpp) diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 81998d5b..324fede5 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -45,7 +45,13 @@ int multitap1; int multitap2; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; -int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }}; +int in_adev[2] = { -1, -1 }; +int in_adev_axis[2][2] = +#ifdef PANDORA + {{ 0, 1 }, { 0, 1 }}; +#else + {{ 0, 1 }, { 2, 3 }}; +#endif int in_adev_is_nublike[2]; unsigned short in_keystate[8]; int in_mouse[8][2]; -- 2.39.5