mirror of
https://github.com/libretro/RetroArch.git
synced 2024-06-02 19:57:24 -04:00
Add scaling to pointer input (#12213)
So far, if display is scaled, overlays gets correctly drawn but touch input is not correctly scaled, resulting in an unusable overlay. This happens for touches in menu too. This commit aims to introduce this scaling factor adding it to the config file, eg: input_touch_scale = "2"
This commit is contained in:
parent
cbec423413
commit
5c6cd1b48a
|
@ -62,6 +62,8 @@
|
|||
#define DEFAULT_MOUSE_SCALE 1
|
||||
#endif
|
||||
|
||||
#define DEFAULT_TOUCH_SCALE 1
|
||||
|
||||
#if defined(RARCH_MOBILE) || defined(HAVE_LIBNX) || defined(__WINRT__)
|
||||
#define DEFAULT_POINTER_ENABLE true
|
||||
#else
|
||||
|
|
|
@ -1888,6 +1888,7 @@ static struct config_uint_setting *populate_settings_uint(
|
|||
#ifdef GEKKO
|
||||
SETTING_UINT("input_mouse_scale", &settings->uints.input_mouse_scale, true, DEFAULT_MOUSE_SCALE, false);
|
||||
#endif
|
||||
SETTING_UINT("input_touch_scale", &settings->uints.input_touch_scale, true, DEFAULT_TOUCH_SCALE, false);
|
||||
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
|
||||
SETTING_UINT("input_dingux_rumble_gain", &settings->uints.input_dingux_rumble_gain, true, DEFAULT_DINGUX_RUMBLE_GAIN, false);
|
||||
#endif
|
||||
|
|
|
@ -151,6 +151,7 @@ typedef struct settings
|
|||
#ifdef GEKKO
|
||||
unsigned input_mouse_scale;
|
||||
#endif
|
||||
unsigned input_touch_scale;
|
||||
unsigned input_hotkey_block_delay;
|
||||
unsigned input_menu_toggle_gamepad_combo;
|
||||
unsigned input_keyboard_gamepad_mapping_type;
|
||||
|
|
|
@ -217,6 +217,7 @@ typedef struct
|
|||
float y_separation_portrait;
|
||||
float x_offset_portrait;
|
||||
float y_offset_portrait;
|
||||
float touch_scale;
|
||||
bool auto_scale;
|
||||
} overlay_layout_desc_t;
|
||||
|
||||
|
|
|
@ -1410,6 +1410,10 @@ MSG_HASH(
|
|||
"input_mouse_scale"
|
||||
)
|
||||
#endif
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_TOUCH_SCALE,
|
||||
"input_touch_scale"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_BIND_MODE,
|
||||
"input_bind_mode"
|
||||
|
|
|
@ -12207,6 +12207,14 @@ MSG_HASH(
|
|||
"Adjust x/y scale for Wiimote light gun speed."
|
||||
)
|
||||
#endif
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_TOUCH_SCALE,
|
||||
"Touch Scale"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_TOUCH_SCALE,
|
||||
"Adjust x/y scale of touchscreen coordinates to accommodate OS-level display scaling."
|
||||
)
|
||||
#ifdef HAVE_ODROIDGO2
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_VIDEO_RGA_SCALING,
|
||||
|
|
|
@ -343,6 +343,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_sync, MENU_
|
|||
#if defined(GEKKO)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_mouse_scale, MENU_ENUM_SUBLABEL_INPUT_MOUSE_SCALE)
|
||||
#endif
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_touch_scale, MENU_ENUM_SUBLABEL_INPUT_TOUCH_SCALE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_axis_threshold, MENU_ENUM_SUBLABEL_INPUT_BUTTON_AXIS_THRESHOLD)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_period, MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_duty_cycle, MENU_ENUM_SUBLABEL_INPUT_DUTY_CYCLE)
|
||||
|
@ -3398,6 +3399,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
|||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_mouse_scale);
|
||||
break;
|
||||
#endif
|
||||
case MENU_ENUM_LABEL_INPUT_TOUCH_SCALE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_touch_scale);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_AUDIO_SYNC:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_sync);
|
||||
break;
|
||||
|
|
|
@ -6128,6 +6128,10 @@ unsigned menu_displaylist_build_list(
|
|||
PARSE_ONLY_UINT, false) == 0)
|
||||
count++;
|
||||
#endif
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_TOUCH_SCALE,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
count++;
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_ANALOG_DEADZONE,
|
||||
PARSE_ONLY_FLOAT, false) == 0)
|
||||
|
|
|
@ -6388,6 +6388,13 @@ static void setting_get_string_representation_poll_type_behavior(
|
|||
}
|
||||
}
|
||||
|
||||
static void setting_get_string_representation_input_touch_scale(rarch_setting_t *setting,
|
||||
char *s, size_t len)
|
||||
{
|
||||
if (setting)
|
||||
snprintf(s, len, "x%d", *setting->value.target.unsigned_integer);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LANGEXTRA
|
||||
static void setting_get_string_representation_uint_user_language(
|
||||
rarch_setting_t *setting,
|
||||
|
@ -12051,6 +12058,23 @@ static bool setting_append_list(
|
|||
menu_settings_list_current_add_range(list, list_info, 1, 4, 1, true, true);
|
||||
#endif
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.input_touch_scale,
|
||||
MENU_ENUM_LABEL_INPUT_TOUCH_SCALE,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_TOUCH_SCALE,
|
||||
DEFAULT_TOUCH_SCALE,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
(*list)[list_info->index - 1].get_string_representation =
|
||||
&setting_get_string_representation_input_touch_scale;
|
||||
(*list)[list_info->index - 1].offset_by = 1;
|
||||
menu_settings_list_current_add_range(list, list_info, 1, 4, 1, true, true);
|
||||
|
||||
#ifdef VITA
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
|
|
|
@ -953,6 +953,7 @@ enum msg_hash_enums
|
|||
#if defined(GEKKO)
|
||||
MENU_LABEL(INPUT_MOUSE_SCALE),
|
||||
#endif
|
||||
MENU_LABEL(INPUT_TOUCH_SCALE),
|
||||
MENU_LABEL(INPUT_ANALOG_DEADZONE),
|
||||
MENU_LABEL(INPUT_ANALOG_SENSITIVITY),
|
||||
MENU_LABEL(INPUT_BIND_TIMEOUT),
|
||||
|
|
19
retroarch.c
19
retroarch.c
|
@ -13981,6 +13981,7 @@ bool command_event(enum event_command cmd, void *data)
|
|||
layout_desc.y_separation_portrait = settings->floats.input_overlay_y_separation_portrait;
|
||||
layout_desc.x_offset_portrait = settings->floats.input_overlay_x_offset_portrait;
|
||||
layout_desc.y_offset_portrait = settings->floats.input_overlay_y_offset_portrait;
|
||||
layout_desc.touch_scale = (float)settings->uints.input_touch_scale;
|
||||
layout_desc.auto_scale = settings->bools.input_overlay_auto_scale;
|
||||
|
||||
input_overlay_set_scale_factor(p_rarch, p_rarch->overlay_ptr, &layout_desc);
|
||||
|
@ -21077,7 +21078,7 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y)
|
|||
static void input_overlay_poll(
|
||||
input_overlay_t *ol,
|
||||
input_overlay_state_t *out,
|
||||
int16_t norm_x, int16_t norm_y)
|
||||
int16_t norm_x, int16_t norm_y, float touch_scale)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -21091,6 +21092,9 @@ static void input_overlay_poll(
|
|||
x /= ol->active->mod_w;
|
||||
y /= ol->active->mod_h;
|
||||
|
||||
x *= touch_scale;
|
||||
y *= touch_scale;
|
||||
|
||||
for (i = 0; i < ol->active->size; i++)
|
||||
{
|
||||
float x_dist, y_dist;
|
||||
|
@ -21404,6 +21408,7 @@ static void input_poll_overlay(
|
|||
settings_t *settings = p_rarch->configuration_settings;
|
||||
bool input_overlay_show_physical_inputs = settings->bools.input_overlay_show_physical_inputs;
|
||||
unsigned input_overlay_show_physical_inputs_port = settings->uints.input_overlay_show_physical_inputs_port;
|
||||
float touch_scale = (float)settings->uints.input_touch_scale;
|
||||
|
||||
if (!ol_state)
|
||||
return;
|
||||
|
@ -21471,7 +21476,7 @@ static void input_poll_overlay(
|
|||
memset(&polled_data, 0, sizeof(struct input_overlay_state));
|
||||
|
||||
if (ol->enable)
|
||||
input_overlay_poll(ol, &polled_data, x, y);
|
||||
input_overlay_poll(ol, &polled_data, x, y, touch_scale);
|
||||
else
|
||||
ol->blocked = false;
|
||||
|
||||
|
@ -21605,6 +21610,8 @@ static void retroarch_overlay_init(struct rarch_state *p_rarch)
|
|||
float overlay_y_separation_portrait = settings->floats.input_overlay_y_separation_portrait;
|
||||
float overlay_x_offset_portrait = settings->floats.input_overlay_x_offset_portrait;
|
||||
float overlay_y_offset_portrait = settings->floats.input_overlay_y_offset_portrait;
|
||||
float overlay_touch_scale = (float)settings->uints.input_touch_scale;
|
||||
|
||||
bool load_enabled = input_overlay_enable;
|
||||
#ifdef HAVE_MENU
|
||||
bool overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu;
|
||||
|
@ -21649,6 +21656,7 @@ static void retroarch_overlay_init(struct rarch_state *p_rarch)
|
|||
layout_desc.y_separation_portrait = overlay_y_separation_portrait;
|
||||
layout_desc.x_offset_portrait = overlay_x_offset_portrait;
|
||||
layout_desc.y_offset_portrait = overlay_y_offset_portrait;
|
||||
layout_desc.touch_scale = overlay_touch_scale;
|
||||
layout_desc.auto_scale = input_overlay_auto_scale;
|
||||
|
||||
task_push_overlay_load_default(input_overlay_loaded,
|
||||
|
@ -23007,6 +23015,7 @@ static void menu_input_get_touchscreen_hw_state(
|
|||
static bool last_cancel_pressed = false;
|
||||
bool overlay_active = false;
|
||||
bool pointer_enabled = settings->bools.menu_pointer_enable;
|
||||
unsigned input_touch_scale = settings->uints.input_touch_scale;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
|
@ -23066,7 +23075,8 @@ static void menu_input_get_touchscreen_hw_state(
|
|||
p_rarch->keyboard_mapping_blocked,
|
||||
0, pointer_device,
|
||||
0, RETRO_DEVICE_ID_POINTER_X);
|
||||
hw_state->x = ((pointer_x + 0x7fff) * (int)fb_width) / 0xFFFF;
|
||||
hw_state->x = ((pointer_x + 0x7fff) * (int)fb_width) / 0xFFFF;
|
||||
hw_state->x *= input_touch_scale;
|
||||
|
||||
/* > An annoyance - we get different starting positions
|
||||
* depending upon whether pointer_device is
|
||||
|
@ -23096,7 +23106,8 @@ static void menu_input_get_touchscreen_hw_state(
|
|||
p_rarch->keyboard_mapping_blocked,
|
||||
0, pointer_device,
|
||||
0, RETRO_DEVICE_ID_POINTER_Y);
|
||||
hw_state->y = ((pointer_y + 0x7fff) * (int)fb_height) / 0xFFFF;
|
||||
hw_state->y = ((pointer_y + 0x7fff) * (int)fb_height) / 0xFFFF;
|
||||
hw_state->y *= input_touch_scale;
|
||||
|
||||
if (pointer_device == RARCH_DEVICE_POINTER_SCREEN)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue