Fawkes API  Fawkes Development Version
JoystickForceFeedback Class Reference

Cause force feedback on a joystick. More...

#include "force_feedback.h"

Public Types

enum  Direction { DIRECTION_DOWN = 0x0000, DIRECTION_LEFT = 0x4000, DIRECTION_UP = 0x8000, DIRECTION_RIGHT = 0xC000 }
 Direction of the effect. More...
 

Public Member Functions

 JoystickForceFeedback (const char *device_name)
 Constructor. More...
 
 ~JoystickForceFeedback ()
 Destructor. More...
 
void rumble (uint16_t strong_magnitude, uint16_t weak_magnitude, Direction direction=DIRECTION_DOWN, uint16_t length=0, uint16_t delay=0)
 Rumble the joystick. More...
 
void stop_all ()
 Stop all current effects. More...
 
void stop_rumble ()
 Stop rumbling. More...
 
bool is_rumbling ()
 Check if rumbling effect is active. More...
 
bool can_rumble ()
 Check if rumbling effect is supported. More...
 
bool can_periodic ()
 Check if periodic effect is supported. More...
 
bool can_constant ()
 Check if constant effect is supported. More...
 
bool can_spring ()
 Check if spring effect is supported. More...
 
bool can_friction ()
 Check if friction effect is supported. More...
 
bool can_damper ()
 Check if damper effect is supported. More...
 
bool can_inertia ()
 Check if inertia effect is supported. More...
 
bool can_ramp ()
 Check if ramp effect is supported. More...
 
bool can_square ()
 Check if square effect is supported. More...
 
bool can_triangle ()
 Check if triangle effect is supported. More...
 
bool can_sine ()
 Check if sine effect is supported. More...
 
bool can_saw_up ()
 Check if upward saw effect is supported. More...
 
bool can_saw_down ()
 Check if downward saw effect is supported. More...
 
bool can_custom ()
 Check if custom effect is supported. More...
 

Detailed Description

Cause force feedback on a joystick.

An instance of this class opens an input device which belongs to the given device name. It searches all input devices to find the correct device file. Once opened, it detects the available features of the joystick and provides conventient access to it allowing for rumbling effects, for instance.

Author
Tim Niemueller

Definition at line 29 of file force_feedback.h.

Member Enumeration Documentation

◆ Direction

Direction of the effect.

Enumerator
DIRECTION_DOWN 

Downward effect direction.

DIRECTION_LEFT 

Left effect direction.

DIRECTION_UP 

Upward effect direction.

DIRECTION_RIGHT 

Right effect direction.

Definition at line 33 of file force_feedback.h.

Constructor & Destructor Documentation

◆ JoystickForceFeedback()

JoystickForceFeedback::JoystickForceFeedback ( const char *  device_name)

Constructor.

Parameters
device_namedevice name, note that this is not the device file, but rather the event files are tried and the device name is compared.

Definition at line 123 of file force_feedback.cpp.

◆ ~JoystickForceFeedback()

JoystickForceFeedback::~JoystickForceFeedback ( )

Destructor.

Definition at line 228 of file force_feedback.cpp.

Member Function Documentation

◆ can_constant()

bool JoystickForceFeedback::can_constant ( )
inline

Check if constant effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 53 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_custom()

bool JoystickForceFeedback::can_custom ( )
inline

Check if custom effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 64 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init().

◆ can_damper()

bool JoystickForceFeedback::can_damper ( )
inline

Check if damper effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 56 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_friction()

bool JoystickForceFeedback::can_friction ( )
inline

Check if friction effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 55 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_inertia()

bool JoystickForceFeedback::can_inertia ( )
inline

Check if inertia effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 57 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_periodic()

bool JoystickForceFeedback::can_periodic ( )
inline

Check if periodic effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 52 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_ramp()

bool JoystickForceFeedback::can_ramp ( )
inline

Check if ramp effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 58 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_rumble()

bool JoystickForceFeedback::can_rumble ( )
inline

Check if rumbling effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 51 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_saw_down()

bool JoystickForceFeedback::can_saw_down ( )
inline

Check if downward saw effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 63 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init().

◆ can_saw_up()

bool JoystickForceFeedback::can_saw_up ( )
inline

Check if upward saw effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 62 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init().

◆ can_sine()

bool JoystickForceFeedback::can_sine ( )
inline

Check if sine effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 61 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init().

◆ can_spring()

bool JoystickForceFeedback::can_spring ( )
inline

Check if spring effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 54 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init(), and JoystickActThread::MessageProcessor::process().

◆ can_square()

bool JoystickForceFeedback::can_square ( )
inline

Check if square effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 59 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init().

◆ can_triangle()

bool JoystickForceFeedback::can_triangle ( )
inline

Check if triangle effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 60 of file force_feedback.h.

Referenced by JoystickAcquisitionThread::init().

◆ is_rumbling()

bool JoystickForceFeedback::is_rumbling ( )
inline

Check if rumbling effect is active.

Returns
true if effect is active, false otherwise

Definition at line 50 of file force_feedback.h.

◆ rumble()

void JoystickForceFeedback::rumble ( uint16_t  strong_magnitude,
uint16_t  weak_magnitude,
Direction  direction = DIRECTION_DOWN,
uint16_t  length = 0,
uint16_t  delay = 0 
)

Rumble the joystick.

This is the most basic force feedback for example in force feedback joypads. Often such joysticks provide two effect magnitudes, a strong heavier motor for larger effects, and a smaller one for vibrating effects.

Parameters
strong_magnitudemagnitude to use on the larger motor
weak_magnitudemagnitude to use on the smaller motor
directiondirection of the effect, meaningful on joysticks (rather than joypads)
lengthlength of the effect in ms
delaydelay before the effect starts in ms

Definition at line 248 of file force_feedback.cpp.

Referenced by JoystickActThread::MessageProcessor::process_message().

◆ stop_all()

void JoystickForceFeedback::stop_all ( )

Stop all current effects.

Definition at line 296 of file force_feedback.cpp.

Referenced by JoystickActThread::MessageProcessor::process_message().

◆ stop_rumble()

void JoystickForceFeedback::stop_rumble ( )

Stop rumbling.

Definition at line 283 of file force_feedback.cpp.

Referenced by JoystickActThread::MessageProcessor::process_message().


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