Skip to content

Commit 911d09d

Browse files
committed
overlay: allow touch mouse/lightgun to still work when controller is connected
1 parent 77a1634 commit 911d09d

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

input/input_driver.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3075,6 +3075,9 @@ void input_overlay_set_alpha_mod(
30753075
if (!ol)
30763076
return;
30773077

3078+
if (ol->flags & INPUT_OVERLAY_GAMEPAD_HIDDEN)
3079+
mod = 0.0f;
3080+
30783081
for (i = 0; i < ol->active->load_images_size; i++)
30793082
{
30803083
if (input_overlay_get_visibility(visibility, i)
@@ -3776,6 +3779,7 @@ static void input_poll_overlay(
37763779
/* Check hitboxes only if this touch pointer
37773780
* is not controlling a pointing device */
37783781
if ( ol->flags & INPUT_OVERLAY_ENABLE
3782+
&& !(ol->flags & INPUT_OVERLAY_GAMEPAD_HIDDEN)
37793783
&& !BIT16_GET(ptrdev_touch_mask, i))
37803784
hitbox_pressed = input_overlay_poll(
37813785
ol, &polled_data, i, old_i,
@@ -5561,7 +5565,8 @@ static bool input_overlay_want_hidden(void)
55615565
if (settings->bools.input_overlay_hide_in_menu)
55625566
hide = (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE) != 0;
55635567
#endif
5564-
if (settings->bools.input_overlay_hide_when_gamepad_connected)
5568+
if (settings->bools.input_overlay_hide_when_gamepad_connected
5569+
&& !settings->bools.input_overlay_pointer_enable)
55655570
hide = hide || (input_config_get_device_name(0) != NULL);
55665571

55675572
return hide;
@@ -5661,6 +5666,16 @@ static void input_overlay_loaded(retro_task_t *task,
56615666
if (!enable_overlay)
56625667
input_overlay_unload();
56635668

5669+
/* Soft-hide when gamepad connected but pointer input enabled */
5670+
{
5671+
settings_t *settings = config_get_ptr();
5672+
if (enable_overlay
5673+
&& settings->bools.input_overlay_hide_when_gamepad_connected
5674+
&& settings->bools.input_overlay_pointer_enable
5675+
&& input_config_get_device_name(0) != NULL)
5676+
ol->flags |= INPUT_OVERLAY_GAMEPAD_HIDDEN;
5677+
}
5678+
56645679
input_overlay_set_eightway_diagonal_sensitivity();
56655680

56665681
/* Trigger viewport recalculation - overlay may have viewport override */

input/input_overlay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ enum INPUT_OVERLAY_FLAGS
119119
INPUT_OVERLAY_ENABLE = (1 << 0),
120120
INPUT_OVERLAY_ALIVE = (1 << 1),
121121
INPUT_OVERLAY_BLOCKED = (1 << 2),
122-
INPUT_OVERLAY_IS_OSK = (1 << 3)
122+
INPUT_OVERLAY_IS_OSK = (1 << 3),
123+
INPUT_OVERLAY_GAMEPAD_HIDDEN = (1 << 4)
123124
};
124125

125126
enum OVERLAY_FLAGS

runloop.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5727,15 +5727,26 @@ static enum runloop_state_enum runloop_check_state(
57275727
static bool last_controller_connected = false;
57285728
bool controller_connected = (input_config_get_device_name(0) != NULL);
57295729

5730-
if (controller_connected != last_controller_connected)
5730+
/* When pointer input is enabled, soft-hide instead of
5731+
* unloading so mouse/lightgun input remains functional.
5732+
* Level-triggered: enforce flag state every frame. */
5733+
if ( settings->bools.input_overlay_pointer_enable
5734+
&& input_st->overlay_ptr)
5735+
{
5736+
if (controller_connected)
5737+
input_st->overlay_ptr->flags |= INPUT_OVERLAY_GAMEPAD_HIDDEN;
5738+
else
5739+
input_st->overlay_ptr->flags &= ~INPUT_OVERLAY_GAMEPAD_HIDDEN;
5740+
}
5741+
else if (controller_connected != last_controller_connected)
57315742
{
57325743
if (controller_connected)
57335744
input_overlay_unload();
57345745
else
57355746
input_overlay_init();
5736-
5737-
last_controller_connected = controller_connected;
57385747
}
5748+
5749+
last_controller_connected = controller_connected;
57395750
}
57405751

57415752
/* Check next overlay hotkey */

tasks/task_overlay.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,22 @@ static bool task_overlay_load_desc(
375375
for (; tmp; tmp = strtok_r(NULL, "|", &save))
376376
{
377377
if (!string_is_equal(tmp, "nul"))
378-
BIT256_SET(desc->button_mask, input_config_translate_str_to_bind_id(tmp));
378+
{
379+
unsigned bind_id = input_config_translate_str_to_bind_id(tmp);
380+
/* Retry without "_enable" suffix for overlay compat */
381+
if (bind_id == RARCH_BIND_LIST_END)
382+
{
383+
size_t len = strlen(tmp);
384+
if (len > 7 && string_is_equal(tmp + len - 7, "_enable"))
385+
{
386+
char stripped[64];
387+
strlcpy(stripped, tmp, len - 7 + 1 < sizeof(stripped)
388+
? len - 7 + 1 : sizeof(stripped));
389+
bind_id = input_config_translate_str_to_bind_id(stripped);
390+
}
391+
}
392+
BIT256_SET(desc->button_mask, bind_id);
393+
}
379394
}
380395

381396
if (BIT256_GET(desc->button_mask, RARCH_OVERLAY_NEXT))

0 commit comments

Comments
 (0)