Skip to content

Commit

Permalink
Add Overlay Mouse, Lightgun, and Pointer (libretro#16343)
Browse files Browse the repository at this point in the history
- When enabled, any touch inputs not in a hitbox are used to create pointing device input for the core.
- Mouse: 1-, 2-, 3-touch inputs are LMB, RMB, and MMB
- Lightgun: allows input from overlay buttons or multi-touch mappings
  • Loading branch information
neil4 authored Mar 16, 2024
1 parent 99aadc8 commit cc97df7
Show file tree
Hide file tree
Showing 19 changed files with 1,427 additions and 26 deletions.
18 changes: 18 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,24 @@
#define DEFAULT_INPUT_OVERLAY_AUTO_SCALE false
#endif

#if defined(RARCH_MOBILE)
#define DEFAULT_INPUT_OVERLAY_POINTER_ENABLE true
#else
#define DEFAULT_INPUT_OVERLAY_POINTER_ENABLE false
#endif

#define DEFAULT_INPUT_OVERLAY_LIGHTGUN_PORT -1
#define DEFAULT_INPUT_OVERLAY_LIGHTGUN_TRIGGER_ON_TOUCH true
#define DEFAULT_INPUT_OVERLAY_LIGHTGUN_TRIGGER_DELAY 1
#define DEFAULT_INPUT_OVERLAY_LIGHTGUN_MULTI_TOUCH_INPUT 0
#define DEFAULT_INPUT_OVERLAY_LIGHTGUN_ALLOW_OFFSCREEN true
#define DEFAULT_INPUT_OVERLAY_MOUSE_SPEED 1.0f
#define DEFAULT_INPUT_OVERLAY_MOUSE_HOLD_TO_DRAG true
#define DEFAULT_INPUT_OVERLAY_MOUSE_HOLD_MSEC 200
#define DEFAULT_INPUT_OVERLAY_MOUSE_DTAP_TO_DRAG false
#define DEFAULT_INPUT_OVERLAY_MOUSE_DTAP_MSEC 200
#define DEFAULT_INPUT_OVERLAY_MOUSE_SWIPE_THRESHOLD 1.0f

#ifdef UDEV_TOUCH_SUPPORT
#define DEFAULT_INPUT_TOUCH_VMOUSE_POINTER true
#define DEFAULT_INPUT_TOUCH_VMOUSE_MOUSE true
Expand Down
20 changes: 20 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,11 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("input_overlay_auto_rotate", &settings->bools.input_overlay_auto_rotate, true, DEFAULT_OVERLAY_AUTO_ROTATE, false);
SETTING_BOOL("input_overlay_auto_scale", &settings->bools.input_overlay_auto_scale, true, DEFAULT_INPUT_OVERLAY_AUTO_SCALE, false);
SETTING_BOOL("input_osk_overlay_auto_scale", &settings->bools.input_osk_overlay_auto_scale, true, DEFAULT_INPUT_OVERLAY_AUTO_SCALE, false);
SETTING_BOOL("input_overlay_pointer_enable", &settings->bools.input_overlay_pointer_enable, true, DEFAULT_INPUT_OVERLAY_POINTER_ENABLE, false);
SETTING_BOOL("input_overlay_lightgun_trigger_on_touch", &settings->bools.input_overlay_lightgun_trigger_on_touch, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_TRIGGER_ON_TOUCH, false);
SETTING_BOOL("input_overlay_lightgun_allow_offscreen", &settings->bools.input_overlay_lightgun_allow_offscreen, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_ALLOW_OFFSCREEN, false);
SETTING_BOOL("input_overlay_mouse_hold_to_drag", &settings->bools.input_overlay_mouse_hold_to_drag, true, DEFAULT_INPUT_OVERLAY_MOUSE_HOLD_TO_DRAG, false);
SETTING_BOOL("input_overlay_mouse_dtap_to_drag", &settings->bools.input_overlay_mouse_dtap_to_drag, true, DEFAULT_INPUT_OVERLAY_MOUSE_DTAP_TO_DRAG, false);
#endif
#ifdef UDEV_TOUCH_SUPPORT
SETTING_BOOL("input_touch_vmouse_pointer", &settings->bools.input_touch_vmouse_pointer, true, DEFAULT_INPUT_TOUCH_VMOUSE_POINTER, false);
Expand Down Expand Up @@ -2249,6 +2254,8 @@ static struct config_float_setting *populate_settings_float(
SETTING_FLOAT("input_overlay_y_separation_portrait", &settings->floats.input_overlay_y_separation_portrait, true, DEFAULT_INPUT_OVERLAY_Y_SEPARATION_PORTRAIT, false);
SETTING_FLOAT("input_overlay_x_offset_portrait", &settings->floats.input_overlay_x_offset_portrait, true, DEFAULT_INPUT_OVERLAY_X_OFFSET_PORTRAIT, false);
SETTING_FLOAT("input_overlay_y_offset_portrait", &settings->floats.input_overlay_y_offset_portrait, true, DEFAULT_INPUT_OVERLAY_Y_OFFSET_PORTRAIT, false);
SETTING_FLOAT("input_overlay_mouse_speed", &settings->floats.input_overlay_mouse_speed, true, DEFAULT_INPUT_OVERLAY_MOUSE_SPEED, false);
SETTING_FLOAT("input_overlay_mouse_swipe_threshold", &settings->floats.input_overlay_mouse_swipe_threshold, true, DEFAULT_INPUT_OVERLAY_MOUSE_SWIPE_THRESHOLD, false);
#endif

#ifdef _3DS
Expand Down Expand Up @@ -2528,6 +2535,15 @@ static struct config_uint_setting *populate_settings_uint(
SETTING_UINT("steam_rich_presence_format", &settings->uints.steam_rich_presence_format, true, DEFAULT_STEAM_RICH_PRESENCE_FORMAT, false);
#endif

#ifdef HAVE_OVERLAY
SETTING_UINT("input_overlay_lightgun_trigger_delay", &settings->uints.input_overlay_lightgun_trigger_delay, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_TRIGGER_DELAY, false);
SETTING_UINT("input_overlay_lightgun_two_touch_input", &settings->uints.input_overlay_lightgun_two_touch_input, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_MULTI_TOUCH_INPUT, false);
SETTING_UINT("input_overlay_lightgun_three_touch_input", &settings->uints.input_overlay_lightgun_three_touch_input, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_MULTI_TOUCH_INPUT, false);
SETTING_UINT("input_overlay_lightgun_four_touch_input", &settings->uints.input_overlay_lightgun_four_touch_input, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_MULTI_TOUCH_INPUT, false);
SETTING_UINT("input_overlay_mouse_hold_msec", &settings->uints.input_overlay_mouse_hold_msec, true, DEFAULT_INPUT_OVERLAY_MOUSE_HOLD_MSEC, false);
SETTING_UINT("input_overlay_mouse_dtap_msec", &settings->uints.input_overlay_mouse_dtap_msec, true, DEFAULT_INPUT_OVERLAY_MOUSE_DTAP_MSEC, false);
#endif

*size = count;

return tmp;
Expand Down Expand Up @@ -2599,6 +2615,10 @@ static struct config_int_setting *populate_settings_int(
SETTING_INT("bottom_font_color_opacity", &settings->ints.bottom_font_color_opacity, true, DEFAULT_BOTTOM_FONT_COLOR, false);
#endif

#ifdef HAVE_OVERLAY
SETTING_INT("input_overlay_lightgun_port", &settings->ints.input_overlay_lightgun_port, true, DEFAULT_INPUT_OVERLAY_LIGHTGUN_PORT, false);
#endif

*size = count;

return tmp;
Expand Down
17 changes: 17 additions & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ typedef struct settings
#ifdef HAVE_XMB
int menu_xmb_title_margin;
int menu_xmb_title_margin_horizontal_offset;
#endif
#ifdef HAVE_OVERLAY
int input_overlay_lightgun_port;
#endif
} ints;

Expand Down Expand Up @@ -319,6 +322,12 @@ typedef struct settings
unsigned input_overlay_show_inputs_port;
unsigned input_overlay_dpad_diagonal_sensitivity;
unsigned input_overlay_abxy_diagonal_sensitivity;
unsigned input_overlay_lightgun_trigger_delay;
unsigned input_overlay_lightgun_two_touch_input;
unsigned input_overlay_lightgun_three_touch_input;
unsigned input_overlay_lightgun_four_touch_input;
unsigned input_overlay_mouse_hold_msec;
unsigned input_overlay_mouse_dtap_msec;
#endif

unsigned run_ahead_frames;
Expand Down Expand Up @@ -418,6 +427,9 @@ typedef struct settings
float input_overlay_x_offset_portrait;
float input_overlay_y_offset_portrait;

float input_overlay_mouse_speed;
float input_overlay_mouse_swipe_threshold;

float slowmotion_ratio;
float fastforward_ratio;
float input_analog_deadzone;
Expand Down Expand Up @@ -664,6 +676,11 @@ typedef struct settings
bool input_overlay_auto_rotate;
bool input_overlay_auto_scale;
bool input_osk_overlay_auto_scale;
bool input_overlay_pointer_enable;
bool input_overlay_lightgun_trigger_on_touch;
bool input_overlay_lightgun_allow_offscreen;
bool input_overlay_mouse_hold_to_drag;
bool input_overlay_mouse_dtap_to_drag;
bool input_descriptor_label_show;
bool input_descriptor_hide_unbound;
bool input_all_users_control_menu;
Expand Down
Loading

0 comments on commit cc97df7

Please sign in to comment.