upkie 6.1.0
Open-source wheeled biped robots
|
Sensor for a joystick controller. More...
#include <Joystick.h>
Public Member Functions | |
Joystick (const std::string &device_path="/dev/input/js0") | |
Open the device file. More... | |
~Joystick () override | |
Close device file. | |
bool | present () const noexcept |
Check if the device file was opened successfully. | |
std::string | prefix () const noexcept final |
Prefix of output in the observation dictionary. More... | |
void | write (Dictionary &output) final |
Write output to a dictionary. More... | |
Public Member Functions inherited from upkie::cpp::sensors::Sensor | |
virtual | ~Sensor () |
Destructor is virtual to deallocate lists of observers properly. | |
virtual std::string | prefix () const noexcept |
Prefix of output in the observation dictionary. More... | |
virtual void | write (Dictionary &observation) |
Write output to a dictionary. More... | |
Sensor for a joystick controller.
Axes are the same for PS4 and Xbox controllers, but buttons differ slightly. See comments in the C++ code of the class for the exact mapping.
upkie::cpp::sensors::Joystick::Joystick | ( | const std::string & | device_path = "/dev/input/js0" | ) |
Open the device file.
[in] | device_path | Path to the joystick device file. |
|
inlinefinalvirtualnoexcept |
Prefix of output in the observation dictionary.
Reimplemented from upkie::cpp::sensors::Sensor.
|
finalvirtual |
Write output to a dictionary.
[out] | output | Dictionary to write observations to. |
Reimplemented from upkie::cpp::sensors::Sensor.