vulp  2.2.2
vulp::observation::sources::Joystick Class Reference

Source 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. More...
 
bool present () const noexcept
 Check if the device file was opened successfully. More...
 
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 vulp::observation::Source
virtual ~Source ()
 Destructor is virtual to deallocate lists of observers properly. More...
 

Detailed Description

Source for a joystick controller.

Axes are the same for PS4 and Xbox controllers, but buttons differ slightly. See comments in read for the exact mapping.

Note
This source only works on Linux.

Definition at line 27 of file Joystick.h.

Constructor & Destructor Documentation

◆ Joystick()

vulp::observation::sources::Joystick::Joystick ( const std::string &  device_path = "/dev/input/js0")

Open the device file.

Parameters
[in]device_pathPath to the joystick device file.

Definition at line 8 of file Joystick.cpp.

◆ ~Joystick()

vulp::observation::sources::Joystick::~Joystick ( )
override

Close device file.

Definition at line 16 of file Joystick.cpp.

Member Function Documentation

◆ prefix()

std::string vulp::observation::sources::Joystick::prefix ( ) const
inlinefinalvirtualnoexcept

Prefix of output in the observation dictionary.

Reimplemented from vulp::observation::Source.

Definition at line 42 of file Joystick.h.

◆ present()

bool vulp::observation::sources::Joystick::present ( ) const
inlinenoexcept

Check if the device file was opened successfully.

Definition at line 39 of file Joystick.h.

◆ write()

void vulp::observation::sources::Joystick::write ( Dictionary &  output)
finalvirtual

Write output to a dictionary.

Parameters
[out]outputDictionary to write observations to.

Reimplemented from vulp::observation::Source.

Definition at line 115 of file Joystick.cpp.


The documentation for this class was generated from the following files: