BoB robotics
The Brains on Board robotics library
BoBRobotics::HID::JoystickLinux Class Reference

Class for reading from joysticks on Linux. More...

#include <joystick_linux.h>

Inheritance diagram for BoBRobotics::HID::JoystickLinux:
BoBRobotics::HID::JoystickBase< JAxisLinux, JButtonLinux > BoBRobotics::Threadable

Public Member Functions

 JoystickLinux (float deadZone=0.0f)
 Open default joystick device with (optionally) specified dead zone.
 
virtual ~JoystickLinux () override
 Close connection to controller.
 
- Public Member Functions inherited from BoBRobotics::HID::JoystickBase< JAxisLinux, JButtonLinux >
bool update ()
 Try to read from the joystick. More...
 
void addHandler (AxisHandler handler)
 Add a function to handle joystick axis events.
 
void addHandler (ButtonHandler handler)
 Add a function to handle joystick button events.
 
float getState (JAxisLinux axis) const
 Get the current value for a specified joystick axis.
 
unsigned char getState (JButtonLinux button) const
 Get the current state for a specified joystick button. More...
 
bool isDown (JButtonLinux button) const
 Whether button is currently being pressed.
 
bool isPressed (JButtonLinux button) const
 Whether button has been pressed since last update()
 
bool isReleased (JButtonLinux button) const
 Whether button has been released since last update()
 
- Public Member Functions inherited from BoBRobotics::Threadable
virtual void run ()
 Run on the current thread, blocking until process ends.
 
virtual bool isRunning ()
 Check if the run() function has been called.
 
virtual void runInBackground ()
 Run the process on a background thread.
 
virtual void stop ()
 Stop the background thread.
 

Protected Member Functions

virtual bool updateState () override
 
- Protected Member Functions inherited from BoBRobotics::HID::JoystickBase< JAxisLinux, JButtonLinux >
 JoystickBase (float deadZone=0.0f)
 
virtual bool updateState ()=0
 
virtual void runInternal () override
 
void setPressed (JButtonLinux button, bool isInitial)
 
void setReleased (JButtonLinux button, bool isInitial)
 
void setState (JButtonLinux button, uint8_t state, bool isInitial)
 
void setState (JAxisLinux axis, float value, bool isInitial)
 
virtual void runInternal ()=0
 

Additional Inherited Members

- Static Public Member Functions inherited from BoBRobotics::HID::JoystickBase< JAxisLinux, JButtonLinux >
static std::string getName (JAxisLinux axis)
 Get the name of a specified joystick axis.
 
static std::string getName (JButtonLinux button)
 Get the name of a specified joystick button.
 
- Static Protected Member Functions inherited from BoBRobotics::HID::JoystickBase< JAxisLinux, JButtonLinux >
static constexpr size_t toIndex (T value)
 
static constexpr JAxisLinux toAxis (T value)
 
static constexpr JButtonLinux toButton (T value)
 
static constexpr float int16_maxf ()
 
static constexpr float int16_absminf ()
 

Detailed Description

Class for reading from joysticks on Linux.

NOTE: This class should not be used directly; see example in joystick_test.

Member Function Documentation

◆ updateState()

virtual bool BoBRobotics::HID::JoystickLinux::updateState ( )
overrideprotectedvirtual

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