mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 03:40:24 +00:00
Merge pull request #12438 from jdgleaver/overlay-show-inputs-redux
Add option to select between 'touched' elements and physical controller inputs when showing inputs on overlays
This commit is contained in:
commit
3c6ac487d0
@ -742,7 +742,13 @@ static const unsigned input_backtouch_toggle = false;
|
||||
|
||||
#define DEFAULT_OVERLAY_ENABLE_AUTOPREFERRED true
|
||||
|
||||
#define DEFAULT_SHOW_PHYSICAL_INPUTS true
|
||||
#if defined(RARCH_MOBILE)
|
||||
#define DEFAULT_OVERLAY_SHOW_INPUTS OVERLAY_SHOW_INPUT_TOUCHED
|
||||
#else
|
||||
#define DEFAULT_OVERLAY_SHOW_INPUTS OVERLAY_SHOW_INPUT_PHYSICAL
|
||||
#endif
|
||||
|
||||
#define DEFAULT_OVERLAY_SHOW_INPUTS_PORT 0
|
||||
|
||||
#define DEFAULT_ALL_USERS_CONTROL_MENU false
|
||||
|
||||
|
@ -1749,7 +1749,6 @@ static struct config_bool_setting *populate_settings_bool(
|
||||
#ifdef HAVE_OVERLAY
|
||||
SETTING_BOOL("input_overlay_enable", &settings->bools.input_overlay_enable, true, config_overlay_enable_default(), false);
|
||||
SETTING_BOOL("input_overlay_enable_autopreferred", &settings->bools.input_overlay_enable_autopreferred, true, DEFAULT_OVERLAY_ENABLE_AUTOPREFERRED, false);
|
||||
SETTING_BOOL("input_overlay_show_physical_inputs", &settings->bools.input_overlay_show_physical_inputs, true, DEFAULT_SHOW_PHYSICAL_INPUTS, false);
|
||||
SETTING_BOOL("input_overlay_hide_in_menu", &settings->bools.input_overlay_hide_in_menu, true, DEFAULT_OVERLAY_HIDE_IN_MENU, false);
|
||||
SETTING_BOOL("input_overlay_hide_when_gamepad_connected", &settings->bools.input_overlay_hide_when_gamepad_connected, true, DEFAULT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED, false);
|
||||
SETTING_BOOL("input_overlay_show_mouse_cursor", &settings->bools.input_overlay_show_mouse_cursor, true, DEFAULT_OVERLAY_SHOW_MOUSE_CURSOR, false);
|
||||
@ -2074,7 +2073,12 @@ static struct config_uint_setting *populate_settings_uint(
|
||||
SETTING_UINT("bundle_assets_extract_version_current", &settings->uints.bundle_assets_extract_version_current, true, 0, false);
|
||||
#endif
|
||||
SETTING_UINT("bundle_assets_extract_last_version", &settings->uints.bundle_assets_extract_last_version, true, 0, false);
|
||||
SETTING_UINT("input_overlay_show_physical_inputs_port", &settings->uints.input_overlay_show_physical_inputs_port, true, 0, false);
|
||||
|
||||
#if defined(HAVE_OVERLAY)
|
||||
SETTING_UINT("input_overlay_show_inputs", &settings->uints.input_overlay_show_inputs, true, DEFAULT_OVERLAY_SHOW_INPUTS, false);
|
||||
SETTING_UINT("input_overlay_show_inputs_port", &settings->uints.input_overlay_show_inputs_port, true, DEFAULT_OVERLAY_SHOW_INPUTS_PORT, false);
|
||||
#endif
|
||||
|
||||
SETTING_UINT("video_msg_bgcolor_red", &settings->uints.video_msg_bgcolor_red, true, message_bgcolor_red, false);
|
||||
SETTING_UINT("video_msg_bgcolor_green", &settings->uints.video_msg_bgcolor_green, true, message_bgcolor_green, false);
|
||||
SETTING_UINT("video_msg_bgcolor_blue", &settings->uints.video_msg_bgcolor_blue, true, message_bgcolor_blue, false);
|
||||
|
@ -266,7 +266,8 @@ typedef struct settings
|
||||
unsigned camera_width;
|
||||
unsigned camera_height;
|
||||
|
||||
unsigned input_overlay_show_physical_inputs_port;
|
||||
unsigned input_overlay_show_inputs;
|
||||
unsigned input_overlay_show_inputs_port;
|
||||
|
||||
unsigned run_ahead_frames;
|
||||
|
||||
@ -542,7 +543,6 @@ typedef struct settings
|
||||
bool input_overlay_enable_autopreferred;
|
||||
bool input_overlay_hide_in_menu;
|
||||
bool input_overlay_hide_when_gamepad_connected;
|
||||
bool input_overlay_show_physical_inputs;
|
||||
bool input_overlay_show_mouse_cursor;
|
||||
bool input_overlay_auto_rotate;
|
||||
bool input_overlay_auto_scale;
|
||||
|
@ -1511,12 +1511,12 @@ MSG_HASH(
|
||||
"overlay_hide_when_gamepad_connected"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
"overlay_show_physical_inputs"
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS,
|
||||
"input_overlay_show_inputs"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
|
||||
"overlay_show_physical_inputs_port"
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT,
|
||||
"input_overlay_show_inputs_port"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR,
|
||||
|
@ -3437,20 +3437,28 @@ MSG_HASH(
|
||||
)
|
||||
#endif
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS,
|
||||
"Show Inputs on Overlay"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
"Show keyboard/controller inputs on the on-screen overlay."
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_INPUTS,
|
||||
"Show registered inputs on the on-screen overlay. 'Touched' highlights overlay elements that are pressed/clicked. 'Physical (Controller)' highlights actual input passed to cores, typically from a connected controller/keyboard."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
|
||||
"Show Inputs Listen Port"
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_TOUCHED,
|
||||
"Touched"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
|
||||
"Select the port for the overlay to listen to if 'Show Inputs On Overlay' is enabled."
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_PHYSICAL,
|
||||
"Physical (Controller)"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_PORT,
|
||||
"Show Inputs From Port"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT,
|
||||
"Select the port of the input device to monitor when 'Show Inputs on Overlay' is set to 'Physical (Controller)'."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_MOUSE_CURSOR,
|
||||
|
@ -628,9 +628,8 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_savefiles_by_content_enable,
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_savestates_by_content_enable, MENU_ENUM_SUBLABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_screenshots_by_content_enable, MENU_ENUM_SUBLABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_updater_buildbot_url, MENU_ENUM_SUBLABEL_CORE_UPDATER_BUILDBOT_URL)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_physical_inputs, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_physical_inputs_port,
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_inputs, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_INPUTS)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_inputs_port, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_updater_buildbot_assets_url, MENU_ENUM_SUBLABEL_BUILDBOT_ASSETS_URL)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_updater_auto_extract_archive, MENU_ENUM_SUBLABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_updater_show_experimental_cores, MENU_ENUM_SUBLABEL_CORE_UPDATER_SHOW_EXPERIMENTAL_CORES)
|
||||
@ -3242,11 +3241,11 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_hide_when_gamepad_connected);
|
||||
#endif
|
||||
break;
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_physical_inputs);
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_inputs);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_physical_inputs_port);
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_inputs_port);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_mouse_cursor);
|
||||
|
@ -416,6 +416,13 @@ enum quit_on_close_content_type
|
||||
QUIT_ON_CLOSE_CONTENT_LAST
|
||||
};
|
||||
|
||||
enum overlay_show_input_type
|
||||
{
|
||||
OVERLAY_SHOW_INPUT_NONE = 0,
|
||||
OVERLAY_SHOW_INPUT_TOUCHED,
|
||||
OVERLAY_SHOW_INPUT_PHYSICAL,
|
||||
OVERLAY_SHOW_INPUT_LAST
|
||||
};
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -7935,15 +7935,18 @@ unsigned menu_displaylist_build_list(
|
||||
break;
|
||||
case DISPLAYLIST_ONSCREEN_OVERLAY_SETTINGS_LIST:
|
||||
{
|
||||
bool input_overlay_enable = settings->bools.input_overlay_enable;
|
||||
bool input_overlay_auto_scale = settings->bools.input_overlay_auto_scale;
|
||||
bool input_overlay_enable = settings->bools.input_overlay_enable;
|
||||
bool input_overlay_auto_scale = settings->bools.input_overlay_auto_scale;
|
||||
enum overlay_show_input_type
|
||||
input_overlay_show_inputs = (enum overlay_show_input_type)
|
||||
settings->uints.input_overlay_show_inputs;
|
||||
|
||||
menu_displaylist_build_info_selective_t build_list[] = {
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_ENABLE, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS, PARSE_ONLY_UINT, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT, PARSE_ONLY_UINT, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_AUTO_ROTATE, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_AUTO_SCALE, PARSE_ONLY_BOOL, false },
|
||||
@ -7969,8 +7972,7 @@ unsigned menu_displaylist_build_list(
|
||||
{
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_AUTO_ROTATE:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_AUTO_SCALE:
|
||||
@ -7979,6 +7981,11 @@ unsigned menu_displaylist_build_list(
|
||||
if (input_overlay_enable)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT:
|
||||
if (input_overlay_enable &&
|
||||
(input_overlay_show_inputs == OVERLAY_SHOW_INPUT_PHYSICAL))
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_OVERLAY_SCALE_LANDSCAPE:
|
||||
case MENU_ENUM_LABEL_OVERLAY_ASPECT_ADJUST_LANDSCAPE:
|
||||
case MENU_ENUM_LABEL_OVERLAY_X_SEPARATION_LANDSCAPE:
|
||||
|
@ -5227,6 +5227,45 @@ static void setting_get_string_representation_uint_input_auto_game_focus(
|
||||
}
|
||||
}
|
||||
|
||||
static void setting_get_string_representation_uint_input_overlay_show_inputs(
|
||||
rarch_setting_t *setting,
|
||||
char *s, size_t len)
|
||||
{
|
||||
if (!setting)
|
||||
return;
|
||||
|
||||
switch (*setting->value.target.unsigned_integer)
|
||||
{
|
||||
case OVERLAY_SHOW_INPUT_NONE:
|
||||
strlcpy(s,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_OFF),
|
||||
len);
|
||||
break;
|
||||
case OVERLAY_SHOW_INPUT_TOUCHED:
|
||||
strlcpy(s,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_TOUCHED),
|
||||
len);
|
||||
break;
|
||||
case OVERLAY_SHOW_INPUT_PHYSICAL:
|
||||
strlcpy(s,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_PHYSICAL),
|
||||
len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void setting_get_string_representation_uint_input_overlay_show_inputs_port(
|
||||
rarch_setting_t *setting,
|
||||
char *s, size_t len)
|
||||
{
|
||||
if (setting)
|
||||
snprintf(s, len, "%u",
|
||||
*setting->value.target.unsigned_integer + 1);
|
||||
}
|
||||
|
||||
/* A protected driver is such that the user cannot set to "null" using the UI.
|
||||
* Can prevent the user from locking him/herself out of the program. */
|
||||
static bool setting_is_protected_driver(rarch_setting_t *setting)
|
||||
@ -13857,35 +13896,40 @@ static bool setting_append_list(
|
||||
);
|
||||
(*list)[list_info->index - 1].change_handler = overlay_enable_toggle_change_handler;
|
||||
|
||||
CONFIG_BOOL(
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->bools.input_overlay_show_physical_inputs,
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
DEFAULT_SHOW_PHYSICAL_INPUTS,
|
||||
MENU_ENUM_LABEL_VALUE_OFF,
|
||||
MENU_ENUM_LABEL_VALUE_ON,
|
||||
&settings->uints.input_overlay_show_inputs,
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS,
|
||||
DEFAULT_OVERLAY_SHOW_INPUTS,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler,
|
||||
SD_FLAG_NONE
|
||||
general_read_handler
|
||||
);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
(*list)[list_info->index - 1].action_left = &setting_uint_action_left_with_refresh;
|
||||
(*list)[list_info->index - 1].action_right = &setting_uint_action_right_with_refresh;
|
||||
(*list)[list_info->index - 1].get_string_representation =
|
||||
&setting_get_string_representation_uint_input_overlay_show_inputs;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, OVERLAY_SHOW_INPUT_LAST-1, 1, true, true);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.input_overlay_show_physical_inputs_port,
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
|
||||
0,
|
||||
&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,
|
||||
&settings->uints.input_overlay_show_inputs_port,
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_INPUTS_PORT,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_PORT,
|
||||
DEFAULT_OVERLAY_SHOW_INPUTS_PORT,
|
||||
&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_uint_input_overlay_show_inputs_port;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, MAX_USERS - 1, 1, true, true);
|
||||
|
||||
CONFIG_BOOL(
|
||||
|
11
msg_hash.h
11
msg_hash.h
@ -970,8 +970,19 @@ enum msg_hash_enums
|
||||
#if defined(ANDROID)
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED_ANDROID,
|
||||
#endif
|
||||
|
||||
/* Legacy enums - no longer needed, but cannot
|
||||
* delete because they are used by Crowdin
|
||||
* translations... */
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS),
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT),
|
||||
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_INPUTS),
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_INPUTS_PORT),
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_NONE,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_TOUCHED,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_INPUTS_PHYSICAL,
|
||||
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_MOUSE_CURSOR),
|
||||
MENU_LABEL(INPUT_OVERLAY_AUTO_ROTATE),
|
||||
MENU_LABEL(INPUT_OVERLAY_AUTO_SCALE),
|
||||
|
118
retroarch.c
118
retroarch.c
@ -20024,14 +20024,20 @@ static bool video_driver_overlay_interface(
|
||||
|
||||
/**
|
||||
* input_overlay_add_inputs:
|
||||
* @ol : pointer to overlay
|
||||
* @port : the user to show the inputs of
|
||||
* @desc : pointer to overlay description
|
||||
* @ol_state : pointer to overlay state. If valid, inputs
|
||||
* that are actually 'touched' on the overlay
|
||||
* itself will displayed. If NULL, inputs from
|
||||
* the device connected to 'port' will be displayed.
|
||||
* @port : when ol_state is NULL, specifies the port of
|
||||
* the input device from which input will be
|
||||
* displayed.
|
||||
*
|
||||
* Adds inputs from current_input to the overlay, so it's displayed
|
||||
* returns true if an input that is pressed will change the overlay
|
||||
*/
|
||||
static bool input_overlay_add_inputs_inner(overlay_desc_t *desc,
|
||||
unsigned port, unsigned analog_dpad_mode)
|
||||
input_overlay_state_t *ol_state, unsigned port)
|
||||
{
|
||||
switch(desc->type)
|
||||
{
|
||||
@ -20040,22 +20046,24 @@ static bool input_overlay_add_inputs_inner(overlay_desc_t *desc,
|
||||
unsigned i;
|
||||
bool all_buttons_pressed = false;
|
||||
|
||||
/*Check each bank of the mask*/
|
||||
/* Check each bank of the mask */
|
||||
for (i = 0; i < ARRAY_SIZE(desc->button_mask.data); ++i)
|
||||
{
|
||||
/*Get bank*/
|
||||
/* Get bank */
|
||||
uint32_t bank_mask = BITS_GET_ELEM(desc->button_mask,i);
|
||||
unsigned id = i * 32;
|
||||
|
||||
/*Worth pursuing? Have we got any bits left in here?*/
|
||||
/* Worth pursuing? Have we got any bits left in here? */
|
||||
while (bank_mask)
|
||||
{
|
||||
/*If this bit is set then we need to query the pad
|
||||
*The button must be pressed.*/
|
||||
/* If this bit is set then we need to query the pad.
|
||||
* The button must be pressed.*/
|
||||
if (bank_mask & 1)
|
||||
{
|
||||
/* Light up the button if pressed */
|
||||
if (!input_state(port, RETRO_DEVICE_JOYPAD, 0, id))
|
||||
if (ol_state ?
|
||||
!BIT256_GET(ol_state->buttons, id) :
|
||||
!input_state(port, RETRO_DEVICE_JOYPAD, 0, id))
|
||||
{
|
||||
/* We need ALL of the inputs to be active,
|
||||
* abort. */
|
||||
@ -20078,29 +20086,53 @@ static bool input_overlay_add_inputs_inner(overlay_desc_t *desc,
|
||||
case OVERLAY_TYPE_ANALOG_LEFT:
|
||||
case OVERLAY_TYPE_ANALOG_RIGHT:
|
||||
{
|
||||
unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
|
||||
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
|
||||
float analog_x;
|
||||
float analog_y;
|
||||
float dx;
|
||||
float dy;
|
||||
|
||||
float analog_x = input_state(port, RETRO_DEVICE_ANALOG,
|
||||
index, RETRO_DEVICE_ID_ANALOG_X);
|
||||
float analog_y = input_state(port, RETRO_DEVICE_ANALOG,
|
||||
index, RETRO_DEVICE_ID_ANALOG_Y);
|
||||
float dx = (analog_x/0x8000)*(desc->range_x/2);
|
||||
float dy = (analog_y/0x8000)*(desc->range_y/2);
|
||||
if (ol_state)
|
||||
{
|
||||
unsigned index_offset = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? 2 : 0;
|
||||
analog_x = (float)ol_state->analog[index_offset];
|
||||
analog_y = (float)ol_state->analog[index_offset + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
|
||||
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
|
||||
|
||||
desc->delta_x = dx;
|
||||
desc->delta_y = dy;
|
||||
analog_x = input_state(port, RETRO_DEVICE_ANALOG,
|
||||
index, RETRO_DEVICE_ID_ANALOG_X);
|
||||
analog_y = input_state(port, RETRO_DEVICE_ANALOG,
|
||||
index, RETRO_DEVICE_ID_ANALOG_Y);
|
||||
}
|
||||
|
||||
/*Maybe use some option here instead of 0, only display
|
||||
changes greater than some magnitude.
|
||||
*/
|
||||
if ((dx * dx) > 0 || (dy*dy) > 0)
|
||||
dx = (analog_x / (float)0x8000) * (desc->range_x / 2.0f);
|
||||
dy = (analog_y / (float)0x8000) * (desc->range_y / 2.0f);
|
||||
|
||||
/* Only modify overlay delta_x/delta_y values
|
||||
* if we are monitoring input from a physical
|
||||
* controller (breaks analog touchscreen input,
|
||||
* but it is the only way to show analog stick
|
||||
* motion) */
|
||||
if (!ol_state)
|
||||
{
|
||||
desc->delta_x = dx;
|
||||
desc->delta_y = dy;
|
||||
}
|
||||
|
||||
/* Maybe use some option here instead of 0, only display
|
||||
* changes greater than some magnitude */
|
||||
if ((dx * dx) > 0 || (dy * dy) > 0)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case OVERLAY_TYPE_KEYBOARD:
|
||||
if (input_state(port, RETRO_DEVICE_KEYBOARD, 0, desc->retro_key_idx))
|
||||
if (ol_state ?
|
||||
OVERLAY_GET_KEY(ol_state, desc->retro_key_idx) :
|
||||
input_state(port, RETRO_DEVICE_KEYBOARD, 0, desc->retro_key_idx))
|
||||
{
|
||||
desc->updated = true;
|
||||
return true;
|
||||
@ -20115,7 +20147,7 @@ static bool input_overlay_add_inputs_inner(overlay_desc_t *desc,
|
||||
}
|
||||
|
||||
static bool input_overlay_add_inputs(input_overlay_t *ol,
|
||||
unsigned port, unsigned analog_dpad_mode)
|
||||
bool show_touched, unsigned port)
|
||||
{
|
||||
unsigned i;
|
||||
bool button_pressed = false;
|
||||
@ -20128,7 +20160,7 @@ static bool input_overlay_add_inputs(input_overlay_t *ol,
|
||||
{
|
||||
overlay_desc_t *desc = &(ol->active->descs[i]);
|
||||
button_pressed |= input_overlay_add_inputs_inner(desc,
|
||||
port, analog_dpad_mode);
|
||||
show_touched ? ol_state : NULL, port);
|
||||
}
|
||||
|
||||
return button_pressed;
|
||||
@ -20699,8 +20731,8 @@ static void input_overlay_update_desc_geom(input_overlay_t *ol,
|
||||
* and alpha mods.
|
||||
**/
|
||||
static void input_overlay_post_poll(
|
||||
struct rarch_state *p_rarch,
|
||||
input_overlay_t *ol, float opacity)
|
||||
struct rarch_state *p_rarch, input_overlay_t *ol,
|
||||
bool show_input, float opacity)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@ -20719,7 +20751,7 @@ static void input_overlay_post_poll(
|
||||
desc->range_x_mod *= desc->range_mod;
|
||||
desc->range_y_mod *= desc->range_mod;
|
||||
|
||||
if (desc->image.pixels)
|
||||
if (show_input && desc->image.pixels)
|
||||
{
|
||||
if (ol->iface->set_alpha)
|
||||
ol->iface->set_alpha(ol->iface_data, desc->image_index,
|
||||
@ -20914,15 +20946,17 @@ static void input_poll_overlay(
|
||||
{
|
||||
input_overlay_state_t old_key_state;
|
||||
unsigned i, j;
|
||||
uint16_t key_mod = 0;
|
||||
bool polled = false;
|
||||
bool button_pressed = false;
|
||||
void *input_data = p_rarch->current_input_data;
|
||||
input_overlay_state_t *ol_state = &ol->overlay_state;
|
||||
input_driver_t *current_input = p_rarch->current_input;
|
||||
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;
|
||||
uint16_t key_mod = 0;
|
||||
bool polled = false;
|
||||
bool button_pressed = false;
|
||||
void *input_data = p_rarch->current_input_data;
|
||||
input_overlay_state_t *ol_state = &ol->overlay_state;
|
||||
input_driver_t *current_input = p_rarch->current_input;
|
||||
enum overlay_show_input_type
|
||||
input_overlay_show_inputs = (enum overlay_show_input_type)
|
||||
settings->uints.input_overlay_show_inputs;
|
||||
unsigned input_overlay_show_inputs_port = settings->uints.input_overlay_show_inputs_port;
|
||||
float touch_scale = (float)settings->uints.input_touch_scale;
|
||||
|
||||
if (!ol_state)
|
||||
return;
|
||||
@ -21088,13 +21122,13 @@ static void input_poll_overlay(
|
||||
break;
|
||||
}
|
||||
|
||||
if (input_overlay_show_physical_inputs)
|
||||
if (input_overlay_show_inputs != OVERLAY_SHOW_INPUT_NONE)
|
||||
button_pressed = input_overlay_add_inputs(ol,
|
||||
input_overlay_show_physical_inputs_port,
|
||||
analog_dpad_mode);
|
||||
(input_overlay_show_inputs == OVERLAY_SHOW_INPUT_TOUCHED),
|
||||
input_overlay_show_inputs_port);
|
||||
|
||||
if (button_pressed || polled)
|
||||
input_overlay_post_poll(p_rarch, ol, opacity);
|
||||
input_overlay_post_poll(p_rarch, ol, button_pressed, opacity);
|
||||
else
|
||||
input_overlay_poll_clear(p_rarch, ol, opacity);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user