Fixed #657: controller config file would not get fully read sometimes
The process would stop at the first empty line
This commit is contained in:
parent
746f09938e
commit
3bd052eb95
1 changed files with 87 additions and 78 deletions
|
@ -483,52 +483,55 @@ int find_retroarch(const TCHAR* find_setting, char* retroarch_file, host_input_b
|
||||||
auto tempbutton = -1;
|
auto tempbutton = -1;
|
||||||
|
|
||||||
// read each line in
|
// read each line in
|
||||||
while (std::getline(readFile, line) && line.length() > 1)
|
while (std::getline(readFile, line))
|
||||||
{
|
{
|
||||||
if (strncmp(find_setting, "count_hats", 10) == 0)
|
if (line.length() > 1)
|
||||||
{
|
{
|
||||||
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
if (strncmp(find_setting, "count_hats", 10) == 0)
|
||||||
// remove leading "
|
|
||||||
if (param.at(0) == '"')
|
|
||||||
param.erase(0, 1);
|
|
||||||
// remove trailing "
|
|
||||||
if (param.at(param.length() - 1) == '"')
|
|
||||||
param.erase(param.length() - 1, 1);
|
|
||||||
|
|
||||||
if (param.find('h') == 0)
|
|
||||||
{
|
{
|
||||||
tempbutton = 1;
|
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
||||||
break;
|
// remove leading "
|
||||||
|
if (param.at(0) == '"')
|
||||||
|
param.erase(0, 1);
|
||||||
|
// remove trailing "
|
||||||
|
if (param.at(param.length() - 1) == '"')
|
||||||
|
param.erase(param.length() - 1, 1);
|
||||||
|
|
||||||
|
if (param.find('h') == 0)
|
||||||
|
{
|
||||||
|
tempbutton = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
const auto option = line.substr(0, line.find(delimiter));
|
||||||
|
// exit if we got no result from splitting the string
|
||||||
const auto option = line.substr(0, line.find(delimiter));
|
if (option != line)
|
||||||
// exit if we got no result from splitting the string
|
|
||||||
if (option != line)
|
|
||||||
{
|
|
||||||
if (option != find_setting)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// using the " = " to work out which is the option, and which is the parameter.
|
|
||||||
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
|
||||||
|
|
||||||
// remove leading "
|
|
||||||
if (param.at(0) == '"')
|
|
||||||
param.erase(0, 1);
|
|
||||||
|
|
||||||
// remove trailing "
|
|
||||||
if (param.at(param.length() - 1) == '"')
|
|
||||||
param.erase(param.length() - 1, 1);
|
|
||||||
|
|
||||||
// time to get the output number
|
|
||||||
if (param.find('h') != 0) // check it isn't some kind of hat starting 'h' (so if D-pad uses buttons)
|
|
||||||
{
|
{
|
||||||
tempbutton = abs(atol(param.c_str()));
|
if (option != find_setting)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
if (option == find_setting)
|
// using the " = " to work out which is the option, and which is the parameter.
|
||||||
break;
|
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
||||||
|
|
||||||
|
// remove leading "
|
||||||
|
if (param.at(0) == '"')
|
||||||
|
param.erase(0, 1);
|
||||||
|
|
||||||
|
// remove trailing "
|
||||||
|
if (param.at(param.length() - 1) == '"')
|
||||||
|
param.erase(param.length() - 1, 1);
|
||||||
|
|
||||||
|
// time to get the output number
|
||||||
|
if (param.find('h') != 0) // check it isn't some kind of hat starting 'h' (so if D-pad uses buttons)
|
||||||
|
{
|
||||||
|
tempbutton = abs(atol(param.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option == find_setting)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write_log("Controller Detection: %s : %d\n", find_setting, tempbutton);
|
write_log("Controller Detection: %s : %d\n", find_setting, tempbutton);
|
||||||
|
@ -545,32 +548,35 @@ bool find_retroarch_polarity(const TCHAR* find_setting, char* retroarch_file)
|
||||||
auto tempbutton = false;
|
auto tempbutton = false;
|
||||||
|
|
||||||
// read each line in
|
// read each line in
|
||||||
while (std::getline(readFile, line) && line.length() > 1)
|
while (std::getline(readFile, line))
|
||||||
{
|
{
|
||||||
const auto option = line.substr(0, line.find(delimiter));
|
if (line.length() > 1)
|
||||||
|
|
||||||
if (option != line) // exit if we got no result from splitting the string
|
|
||||||
{
|
{
|
||||||
// using the " = " to work out which is the option, and which is the parameter.
|
const auto option = line.substr(0, line.find(delimiter));
|
||||||
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
|
||||||
|
|
||||||
// remove leading "
|
if (option != line) // exit if we got no result from splitting the string
|
||||||
if (param.at(0) == '"')
|
|
||||||
param.erase(0, 1);
|
|
||||||
|
|
||||||
// remove trailing "
|
|
||||||
if (param.at(param.length() - 1) == '"')
|
|
||||||
param.erase(param.length() - 1, 1);
|
|
||||||
|
|
||||||
// ok, this is the 'normal' storing of values
|
|
||||||
if (option == find_setting)
|
|
||||||
{
|
{
|
||||||
// time to get the output value
|
// using the " = " to work out which is the option, and which is the parameter.
|
||||||
if (param.at(0) == '-')
|
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
||||||
|
|
||||||
|
// remove leading "
|
||||||
|
if (param.at(0) == '"')
|
||||||
|
param.erase(0, 1);
|
||||||
|
|
||||||
|
// remove trailing "
|
||||||
|
if (param.at(param.length() - 1) == '"')
|
||||||
|
param.erase(param.length() - 1, 1);
|
||||||
|
|
||||||
|
// ok, this is the 'normal' storing of values
|
||||||
|
if (option == find_setting)
|
||||||
{
|
{
|
||||||
tempbutton = true;
|
// time to get the output value
|
||||||
|
if (param.at(0) == '-')
|
||||||
|
{
|
||||||
|
tempbutton = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,32 +603,35 @@ const TCHAR* find_retroarch_key(const TCHAR* find_setting_prefix, int player, co
|
||||||
}
|
}
|
||||||
|
|
||||||
// read each line in
|
// read each line in
|
||||||
while (std::getline(read_file, line) && line.length() > 1)
|
while (std::getline(read_file, line))
|
||||||
{
|
{
|
||||||
const auto option = line.substr(0, line.find(delimiter));
|
if (line.length() > 1)
|
||||||
|
|
||||||
if (option != line) // exit if we got no result from splitting the string
|
|
||||||
{
|
{
|
||||||
// using the " = " to work out which is the option, and which is the parameter.
|
const auto option = line.substr(0, line.find(delimiter));
|
||||||
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
|
||||||
|
|
||||||
if (!param.empty())
|
if (option != line) // exit if we got no result from splitting the string
|
||||||
{
|
{
|
||||||
// remove leading "
|
// using the " = " to work out which is the option, and which is the parameter.
|
||||||
if (param.at(0) == '"')
|
auto param = line.substr(line.find(delimiter) + delimiter.length(), line.length());
|
||||||
param.erase(0, 1);
|
|
||||||
|
|
||||||
// remove trailing "
|
if (!param.empty())
|
||||||
if (param.at(param.length() - 1) == '"')
|
{
|
||||||
param.erase(param.length() - 1, 1);
|
// remove leading "
|
||||||
|
if (param.at(0) == '"')
|
||||||
|
param.erase(0, 1);
|
||||||
|
|
||||||
output = ¶m[0U];
|
// remove trailing "
|
||||||
|
if (param.at(param.length() - 1) == '"')
|
||||||
|
param.erase(param.length() - 1, 1);
|
||||||
|
|
||||||
// ok, this is the 'normal' storing of values
|
output = ¶m[0U];
|
||||||
if (option == find_setting)
|
|
||||||
break;
|
|
||||||
|
|
||||||
output = "nul";
|
// ok, this is the 'normal' storing of values
|
||||||
|
if (option == find_setting)
|
||||||
|
break;
|
||||||
|
|
||||||
|
output = "nul";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,7 +676,7 @@ static bool init_kb_from_retroarch(int index, char* retroarch_file)
|
||||||
struct host_keyboard_button temp_keyboard_buttons{};
|
struct host_keyboard_button temp_keyboard_buttons{};
|
||||||
auto player = index + 1;
|
auto player = index + 1;
|
||||||
|
|
||||||
auto tempkey = find_retroarch_key("input_player", player, "y", retroarch_file);
|
const auto* tempkey = find_retroarch_key("input_player", player, "y", retroarch_file);
|
||||||
auto x = find_string_in_array(remap_key_map_list_strings, remap_key_map_list_size, tempkey);
|
auto x = find_string_in_array(remap_key_map_list_strings, remap_key_map_list_size, tempkey);
|
||||||
temp_keyboard_buttons.north_button = remap_key_map_list[x];
|
temp_keyboard_buttons.north_button = remap_key_map_list[x];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue