Skip to content

Commit

Permalink
Fixed parsing of integers
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Apr 4, 2024
1 parent 776afe4 commit 336e7d4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/devices/keyboard-joypad/KeyboardJoypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static bool parseInt(yarp::os::Searchable& cfg, const std::string& key, int min_
return true;
}

if (!cfg.find(key).isInt64())
if (!cfg.find(key).isInt64() && !cfg.find(key).isInt32())
{
yCError(KEYBOARDJOYPAD) << "The value of " << key << " is not an integer";
return false;
Expand Down Expand Up @@ -343,13 +343,23 @@ class yarp::dev::KeyboardJoypad::Impl
int col = 0;
for (size_t i = 0; i < buttons_list->size(); i++)
{
std::string button_with_alias;
if (!buttons_list->get(i).isString())
{
yCError(KEYBOARDJOYPAD) << "The value at index" << i << "of the buttons list is not a string.";
return false;
if (buttons_list->get(i).isInt64() || buttons_list->get(i).isInt32())
{
button_with_alias = std::to_string(buttons_list->get(i).asInt64());
}
else
{
yCError(KEYBOARDJOYPAD) << "The value at index" << i << "of the buttons list is not a string.";
return false;
}
}
else
{
button_with_alias = buttons_list->get(i).asString();
}

std::string button_with_alias = buttons_list->get(i).asString();

if (button_with_alias == "" || button_with_alias == "none")
{
Expand Down

0 comments on commit 336e7d4

Please sign in to comment.