Fawkes API  Fawkes Development Version
JoystickForceFeedback Class Reference

#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 ()
 
bool can_rumble ()
 
bool can_periodic ()
 
bool can_constant ()
 
bool can_spring ()
 
bool can_friction ()
 
bool can_damper ()
 
bool can_inertia ()
 
bool can_ramp ()
 
bool can_square ()
 
bool can_triangle ()
 
bool can_sine ()
 
bool can_saw_up ()
 
bool can_saw_down ()
 
bool can_custom ()
 

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 30 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 40 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 227 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 75 of file force_feedback.h.

Referenced by 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 130 of file force_feedback.h.

◆ can_damper()

bool JoystickForceFeedback::can_damper ( )
inline

Check if damper effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 90 of file force_feedback.h.

Referenced by 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 85 of file force_feedback.h.

Referenced by 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 95 of file force_feedback.h.

Referenced by 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 70 of file force_feedback.h.

Referenced by 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 100 of file force_feedback.h.

Referenced by 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 65 of file force_feedback.h.

Referenced by 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 125 of file force_feedback.h.

◆ 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 120 of file force_feedback.h.

◆ can_sine()

bool JoystickForceFeedback::can_sine ( )
inline

Check if sine effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 115 of file force_feedback.h.

◆ can_spring()

bool JoystickForceFeedback::can_spring ( )
inline

Check if spring effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 80 of file force_feedback.h.

Referenced by 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 105 of file force_feedback.h.

◆ can_triangle()

bool JoystickForceFeedback::can_triangle ( )
inline

Check if triangle effect is supported.

Returns
true if effect is supported, false otherwise

Definition at line 110 of file force_feedback.h.

◆ is_rumbling()

bool JoystickForceFeedback::is_rumbling ( )
inline

Check if rumbling effect is active.

Returns
true if effect is active, false otherwise

Definition at line 60 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 246 of file force_feedback.cpp.

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

◆ stop_all()

void JoystickForceFeedback::stop_all ( )

Stop all current effects.

Definition at line 291 of file force_feedback.cpp.

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

◆ stop_rumble()

void JoystickForceFeedback::stop_rumble ( )

Stop rumbling.

Definition at line 279 of file force_feedback.cpp.

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


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