BrainsOnBoard/bob_robotics

Make ``BoBRobotics::Viz::JoystickKeyboard`` more configurable

Open

#143 opened on Aug 8, 2019

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C++ (6 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (2 stars)
PR merge metrics
 (PR metrics pending)

Description

It would be nice if the mapping of SFML keys to axis, currently hard-coded here, could be configurable - probably via a YAML file. You could implement this in the constructor of JoystickKeyboard something like this:

// Read config values from file
{
    cv::FileStorage configFile(configFilename, cv::FileStorage::READ);
    if(configFile.isOpened()) {
        auto &configNode = configFile["config"];
        cv::read(configNode["leftStickVertical"], m_AxisKeys[HID::JAxis::LeftStickVertical], m_AxisKeys[HID::JAxis::LeftStickVertical]);
        // **TODO** other buttons and axes, ideally saving typing with loops!
    }
}

// Re-write config file
{
    cv::FileStorage configFile(configFilename, cv::FileStorage::WRITE)
    configFile << "config" << "{";
    configFile << "leftStickVertical" << m_AxisKeys[HID::JAxis::LeftStickVertical];
    // **TODO** other buttons and axes, ideally saving typing with loops!
    configFile << "}";
}

Contributor guide