mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 17:50:56 +00:00
Autoconfig extension with alternative name/vid/pid (#16990)
Some checks failed
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI 3DS / build (push) Failing after 0s
CI Android / build (push) Failing after 0s
CI DOS/DJGPP / build (push) Failing after 0s
CI Emscripten / build (push) Failing after 0s
CI GameCube / build (push) Failing after 0s
CI Linux (i686) / build (push) Failing after 0s
CI Miyoo ARM32 / build (push) Failing after 0s
CI PS2 / build (push) Failing after 0s
CI PS4/ORBIS / build (push) Failing after 0s
CI PSP / build (push) Failing after 0s
CI PSVita / build (push) Failing after 0s
CI RS90 Odbeta MIPS32 / build (push) Failing after 0s
CI RetroFW MIPS32 / build (push) Failing after 0s
CI Switch/libnx / build (push) Failing after 0s
CI Wii / build (push) Failing after 0s
CI WiiU / build (push) Failing after 0s
CI Windows i686 (MXE) / build (push) Failing after 0s
CI Windows x64 (MXE) / build (push) Failing after 0s
RetroArch CI / linux-c89 (push) Failing after 0s
CI webOS / build (push) Failing after 0s
Crowdin Daily Workflow / sync (push) Failing after 0s
Some checks failed
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI 3DS / build (push) Failing after 0s
CI Android / build (push) Failing after 0s
CI DOS/DJGPP / build (push) Failing after 0s
CI Emscripten / build (push) Failing after 0s
CI GameCube / build (push) Failing after 0s
CI Linux (i686) / build (push) Failing after 0s
CI Miyoo ARM32 / build (push) Failing after 0s
CI PS2 / build (push) Failing after 0s
CI PS4/ORBIS / build (push) Failing after 0s
CI PSP / build (push) Failing after 0s
CI PSVita / build (push) Failing after 0s
CI RS90 Odbeta MIPS32 / build (push) Failing after 0s
CI RetroFW MIPS32 / build (push) Failing after 0s
CI Switch/libnx / build (push) Failing after 0s
CI Wii / build (push) Failing after 0s
CI WiiU / build (push) Failing after 0s
CI Windows i686 (MXE) / build (push) Failing after 0s
CI Windows x64 (MXE) / build (push) Failing after 0s
RetroArch CI / linux-c89 (push) Failing after 0s
CI webOS / build (push) Failing after 0s
Crowdin Daily Workflow / sync (push) Failing after 0s
If there are several variants of a controller, but their button layout is exactly the same, allow alternative identifiers, e.g.: input_device_alt1 input_vendor_id_alt3 input_product_id_alt9
This commit is contained in:
parent
be7645024c
commit
05844c649f
@ -112,51 +112,77 @@ static unsigned input_autoconfigure_get_config_file_affinity(
|
|||||||
autoconfig_handle_t *autoconfig_handle,
|
autoconfig_handle_t *autoconfig_handle,
|
||||||
config_file_t *config)
|
config_file_t *config)
|
||||||
{
|
{
|
||||||
int tmp_int = 0;
|
int i, tmp_int;
|
||||||
uint16_t config_vid = 0;
|
uint16_t config_vid;
|
||||||
uint16_t config_pid = 0;
|
uint16_t config_pid;
|
||||||
bool pid_match = false;
|
bool pid_match = false;
|
||||||
unsigned affinity = 0;
|
unsigned affinity;
|
||||||
struct config_entry_list
|
unsigned max_affinity = 0;
|
||||||
*entry = NULL;
|
struct config_entry_list *entry = NULL;
|
||||||
|
char config_key[30];
|
||||||
|
char config_key_postfix[7];
|
||||||
|
|
||||||
/* Parse config file */
|
/* One main entry and up to 9 alternatives */
|
||||||
if (config_get_int(config, "input_vendor_id", &tmp_int))
|
for (i=0 ; i < 10; i++)
|
||||||
config_vid = (uint16_t)tmp_int;
|
{
|
||||||
|
config_vid = 0;
|
||||||
|
config_pid = 0;
|
||||||
|
tmp_int = 0;
|
||||||
|
affinity = 0;
|
||||||
|
|
||||||
if (config_get_int(config, "input_product_id", &tmp_int))
|
if (i == 0)
|
||||||
config_pid = (uint16_t)tmp_int;
|
config_key_postfix[0] = '\0';
|
||||||
|
else
|
||||||
|
snprintf(config_key_postfix, sizeof(config_key_postfix),
|
||||||
|
"_alt%d",i);
|
||||||
|
|
||||||
|
/* Parse config file */
|
||||||
|
snprintf(config_key, sizeof(config_key),
|
||||||
|
"input_vendor_id%s",config_key_postfix);
|
||||||
|
if (config_get_int(config, config_key, &tmp_int))
|
||||||
|
config_vid = (uint16_t)tmp_int;
|
||||||
|
|
||||||
|
snprintf(config_key, sizeof(config_key),
|
||||||
|
"input_product_id%s",config_key_postfix);
|
||||||
|
if (config_get_int(config, config_key, &tmp_int))
|
||||||
|
config_pid = (uint16_t)tmp_int;
|
||||||
|
|
||||||
/* > Bliss-Box shenanigans... */
|
/* > Bliss-Box shenanigans... */
|
||||||
#ifdef HAVE_BLISSBOX
|
#ifdef HAVE_BLISSBOX
|
||||||
if (autoconfig_handle->device_info.vid == BLISSBOX_VID)
|
if (autoconfig_handle->device_info.vid == BLISSBOX_VID)
|
||||||
config_pid = BLISSBOX_PID;
|
config_pid = BLISSBOX_PID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for matching VID+PID */
|
/* Check for matching VID+PID */
|
||||||
pid_match = (autoconfig_handle->device_info.vid == config_vid)
|
pid_match = (autoconfig_handle->device_info.vid == config_vid)
|
||||||
&& (autoconfig_handle->device_info.pid == config_pid)
|
&& (autoconfig_handle->device_info.pid == config_pid)
|
||||||
&& (autoconfig_handle->device_info.vid != 0)
|
&& (autoconfig_handle->device_info.vid != 0)
|
||||||
&& (autoconfig_handle->device_info.pid != 0);
|
&& (autoconfig_handle->device_info.pid != 0);
|
||||||
|
|
||||||
/* > More Bliss-Box shenanigans... */
|
/* > More Bliss-Box shenanigans... */
|
||||||
#ifdef HAVE_BLISSBOX
|
#ifdef HAVE_BLISSBOX
|
||||||
pid_match = pid_match
|
pid_match = pid_match
|
||||||
&& (autoconfig_handle->device_info.vid != BLISSBOX_VID)
|
&& (autoconfig_handle->device_info.vid != BLISSBOX_VID)
|
||||||
&& (autoconfig_handle->device_info.pid != BLISSBOX_PID);
|
&& (autoconfig_handle->device_info.pid != BLISSBOX_PID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pid_match)
|
if (pid_match)
|
||||||
affinity += 3;
|
affinity += 3;
|
||||||
|
|
||||||
/* Check for matching device name */
|
/* Check for matching device name */
|
||||||
if ( (entry = config_get_entry(config, "input_device"))
|
snprintf(config_key, sizeof(config_key),
|
||||||
&& !string_is_empty(entry->value)
|
"input_device%s",config_key_postfix);
|
||||||
&& string_is_equal(entry->value,
|
if ( (entry = config_get_entry(config, config_key))
|
||||||
autoconfig_handle->device_info.name))
|
&& !string_is_empty(entry->value)
|
||||||
affinity += 2;
|
&& string_is_equal(entry->value,
|
||||||
|
autoconfig_handle->device_info.name))
|
||||||
|
affinity += 2;
|
||||||
|
|
||||||
return affinity;
|
if (max_affinity < affinity)
|
||||||
|
max_affinity = affinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return max_affinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 'Attaches' specified autoconfig file to autoconfig
|
/* 'Attaches' specified autoconfig file to autoconfig
|
||||||
|
34
tests-other/autoconf/TestpadD_alternative.cfg
Normal file
34
tests-other/autoconf/TestpadD_alternative.cfg
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
input_driver = "test"
|
||||||
|
input_device = "Test joypad device D"
|
||||||
|
input_vendor_id = 1
|
||||||
|
input_product_id = 2
|
||||||
|
input_device_alt1 = "Test joypad device E"
|
||||||
|
input_device_alt8 = "Test joypad device F"
|
||||||
|
input_vendor_id_alt8 = 21
|
||||||
|
input_product_id_alt8 = 22
|
||||||
|
input_device_display_name = "Test joypad device D/E/F"
|
||||||
|
input_b_btn = "0"
|
||||||
|
input_y_btn = "1"
|
||||||
|
input_select_btn = "2"
|
||||||
|
input_start_btn = "3"
|
||||||
|
input_up_btn = "4"
|
||||||
|
input_down_btn = "5"
|
||||||
|
input_left_btn = "6"
|
||||||
|
input_right_btn = "7"
|
||||||
|
input_a_btn = "8"
|
||||||
|
input_x_btn = "9"
|
||||||
|
input_l_btn = "10"
|
||||||
|
input_r_btn = "11"
|
||||||
|
input_l2_btn = "12"
|
||||||
|
input_r2_btn = "13"
|
||||||
|
input_l3_btn = "14"
|
||||||
|
input_r3_btn = "15"
|
||||||
|
input_l_x_plus_axis = "+0"
|
||||||
|
input_l_x_minus_axis = "-0"
|
||||||
|
input_l_y_plus_axis = "+1"
|
||||||
|
input_l_y_minus_axis = "-1"
|
||||||
|
input_r_x_plus_axis = "+2"
|
||||||
|
input_r_x_minus_axis = "-2"
|
||||||
|
input_r_y_plus_axis = "+3"
|
||||||
|
input_r_y_minus_axis = "-3"
|
||||||
|
|
18
tests-other/test_input_joypad_alternative_autoconfig.ratst
Normal file
18
tests-other/test_input_joypad_alternative_autoconfig.ratst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"action": 1,
|
||||||
|
"param_num": 0,
|
||||||
|
"param_str": "(0001:0002) Test joypad device D",
|
||||||
|
"frame": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": 1,
|
||||||
|
"param_num": 1,
|
||||||
|
"param_str": "(0003:0004) Test joypad device E"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": 1,
|
||||||
|
"param_num": 2,
|
||||||
|
"param_str": "(0015:0016) Test joypad device X"
|
||||||
|
}
|
||||||
|
]
|
19
tests-other/testinput_alternative_autoconfig.cfg
Normal file
19
tests-other/testinput_alternative_autoconfig.cfg
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Test configuration file to be used with --appendconfig.
|
||||||
|
# Sets up joypad driver, test input file for the joypad driver,
|
||||||
|
# logging and autoconfig dir, and prevents saving.
|
||||||
|
# Usage:
|
||||||
|
# retroarch --appendconfig tests-other/testinput_alternative_autoconfig.cfg\|tests-other/all_binds_empty.cfg
|
||||||
|
|
||||||
|
# Test scenario:
|
||||||
|
# - A device is connected with autoconfig profile
|
||||||
|
# - A second device is connected which matches autoconfig profile alt1
|
||||||
|
# - A third device is connected which matches autoconfig profile alt8 (only by vid/pid)
|
||||||
|
# - VALIDATE: check that Player 1..3 have "Test joypad D/E/F" configured
|
||||||
|
|
||||||
|
input_joypad_driver = "test"
|
||||||
|
test_input_file_joypad = "tests-other/test_input_joypad_alternative_autoconfig.ratst"
|
||||||
|
joypad_autoconfig_dir = "tests-other/autoconf"
|
||||||
|
frontend_log_level = "0"
|
||||||
|
libretro_log_level = "0"
|
||||||
|
log_verbosity = "true"
|
||||||
|
config_save_on_exit = "false"
|
Loading…
Reference in New Issue
Block a user