aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Albrieux <jonathan.albrieux@gmail.com>2021-04-09 10:16:35 +0200
committerRasmus Thomsen <oss@cogitri.dev>2021-04-15 07:38:18 +0000
commit5e3d9a873827594a6858af09c7003dde9aed6460 (patch)
tree21dd50b8915cff81a7040fa54976414e46bb92a4
parent0415a4d96733c407e4f5780af868dc83f2653bde (diff)
downloadaports-5e3d9a873827594a6858af09c7003dde9aed6460.tar.gz
aports-5e3d9a873827594a6858af09c7003dde9aed6460.tar.bz2
aports-5e3d9a873827594a6858af09c7003dde9aed6460.tar.xz
community/retroarch: add touch scale patch
-rw-r--r--community/retroarch/APKBUILD9
-rw-r--r--community/retroarch/touch_scale.patch271
2 files changed, 277 insertions, 3 deletions
diff --git a/community/retroarch/APKBUILD b/community/retroarch/APKBUILD
index 3227cc15db..99e29d73a1 100644
--- a/community/retroarch/APKBUILD
+++ b/community/retroarch/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=retroarch
pkgver=1.9.1
-pkgrel=0
+pkgrel=1
arch="all !mips !mips64"
url="https://retroarch.com"
pkgdesc="Reference frontend for the libretro API"
@@ -12,7 +12,9 @@ makedepends="linux-headers mesa-dev qt5-qtbase-dev wayland-dev wayland-protocols
zlib-dev alsa-lib-dev pulseaudio-dev sdl2-dev flac-dev mbedtls-dev libusb-dev
ffmpeg-dev libxkbcommon-dev eudev-dev vulkan-loader-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/libretro/retroarch/archive/v$pkgver.tar.gz
- config.patch"
+ config.patch
+ touch_scale.patch
+ "
subpackages="$pkgname-doc"
builddir="$srcdir/RetroArch-$pkgver"
options="!check" # No tests
@@ -37,4 +39,5 @@ package() {
}
sha512sums="c0db73e287da3a3c5b73ae3e596b1bd8fe1d3d72326dda7a9090d7dd8eb8d92e1e76d2cae57b29035c26a498a2e9c03116033bf86c185d77a77feb5a49a6759d retroarch-1.9.1.tar.gz
-0b3a8e1fe318d783a5a34606da187d086f8ad9b543cc496c9c6d527dca40d0078a66a6ccb11b1aaf3519a37ac93c8790af0d916c628ae9286066c0a84308fa15 config.patch"
+0b3a8e1fe318d783a5a34606da187d086f8ad9b543cc496c9c6d527dca40d0078a66a6ccb11b1aaf3519a37ac93c8790af0d916c628ae9286066c0a84308fa15 config.patch
+f6fefe8921ff00fbe426b4c934ba8cf83d95eed1d75e1585600dcd1de9e54725a7ac7326bfc760e6b739d048ca66340cf81614f7bb743e17d4912a40fabe40c5 touch_scale.patch"
diff --git a/community/retroarch/touch_scale.patch b/community/retroarch/touch_scale.patch
new file mode 100644
index 0000000000..23ce96a17f
--- /dev/null
+++ b/community/retroarch/touch_scale.patch
@@ -0,0 +1,271 @@
+v1.9.1 doesn't include a recently merged patch to properly handle touch scale on devices with scaled screen.
+The original patch can be found here https://github.com/libretro/RetroArch/pull/12213.
+This commit aims to introduce this patch.
+
+diff --git a/config.def.h b/config.def.h
+index 4f199f3..c20a434 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -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
+diff --git a/configuration.c b/configuration.c
+index 82f2c32..f6a94d0 100644
+--- a/configuration.c
++++ b/configuration.c
+@@ -1887,6 +1887,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
+diff --git a/configuration.h b/configuration.h
+index 660d2db..8c51156 100644
+--- a/configuration.h
++++ b/configuration.h
+@@ -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;
+diff --git a/input/input_overlay.h b/input/input_overlay.h
+index d9ae163..3f9052a 100644
+--- a/input/input_overlay.h
++++ b/input/input_overlay.h
+@@ -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;
+
+diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h
+index 709f1d7..8808a8f 100644
+--- a/intl/msg_hash_lbl.h
++++ b/intl/msg_hash_lbl.h
+@@ -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"
+diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h
+index 2e0df9d..cb8cb98 100644
+--- a/intl/msg_hash_us.h
++++ b/intl/msg_hash_us.h
+@@ -12191,6 +12191,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,
+diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c
+index 9875942..3453f83 100644
+--- a/menu/cbs/menu_cbs_sublabel.c
++++ b/menu/cbs/menu_cbs_sublabel.c
+@@ -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)
+@@ -3393,6 +3394,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;
+diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c
+index 32d6890..2ac43d3 100644
+--- a/menu/menu_displaylist.c
++++ b/menu/menu_displaylist.c
+@@ -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)
+diff --git a/menu/menu_setting.c b/menu/menu_setting.c
+index 7d966e5..0d4e667 100644
+--- a/menu/menu_setting.c
++++ b/menu/menu_setting.c
+@@ -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,
+@@ -12028,6 +12035,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,
+diff --git a/msg_hash.h b/msg_hash.h
+index 811c01e..d4bfca6 100644
+--- a/msg_hash.h
++++ b/msg_hash.h
+@@ -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),
+diff --git a/retroarch.c b/retroarch.c
+index 77fa18a..9238cb6 100644
+--- a/retroarch.c
++++ b/retroarch.c
+@@ -14329,6 +14329,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);
+@@ -21451,7 +21452,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;
+
+@@ -21465,6 +21466,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;
+@@ -21778,6 +21782,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;
+@@ -21845,7 +21850,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;
+
+@@ -21979,6 +21984,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;
+@@ -22023,6 +22030,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,
+@@ -23395,6 +23403,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;
+@@ -23454,7 +23463,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
+@@ -23484,7 +23494,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)
+ {