Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BoBRobotics::Viz::JoystickKeyboard more configurable #143

Open
neworderofjamie opened this issue Aug 8, 2019 · 0 comments
Open

Make BoBRobotics::Viz::JoystickKeyboard more configurable #143

neworderofjamie opened this issue Aug 8, 2019 · 0 comments

Comments

@neworderofjamie
Copy link
Collaborator

neworderofjamie commented Aug 8, 2019

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 << "}";
}
@neworderofjamie neworderofjamie changed the title Make BoBRobotics::HID::JoystickGLFWKeyboard more configurable Make BoBRobotics::Viz::JoystickKeyboard more configurable Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant