SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SDL::Haptic Class Reference

The haptic structure used to identify an SDL haptic. More...

Inheritance diagram for SDL::Haptic:
Inheritance graph
[legend]

Public Member Functions

constexpr Haptic ()=default
 Default ctor.
 
constexpr Haptic (const HapticRaw resource)
 Constructs from HapticParam. More...
 
constexpr Haptic (const Haptic &other)=delete
 Copy constructor.
 
constexpr Haptic (Haptic &&other)
 Move constructor.
 
constexpr Haptic (const HapticRef &other)=delete
 
constexpr Haptic (HapticRef &&other)=delete
 
 Haptic (HapticID instance_id)
 Open a haptic device for use. More...
 
 Haptic (JoystickParam joystick)
 Open a haptic device for use from a joystick device. More...
 
 ~Haptic ()
 Destructor.
 
Hapticoperator= (Haptic other)
 Assignment operator.
 
constexpr HapticRaw get () const
 Retrieves underlying HapticRaw.
 
constexpr HapticRaw release ()
 Retrieves underlying HapticRaw and clear this.
 
constexpr auto operator<=> (const Haptic &other) const =default
 Comparison.
 
constexpr bool operator== (std::nullptr_t _) const
 Comparison.
 
constexpr operator bool () const
 Converts to bool.
 
constexpr operator HapticParam () const
 Converts to HapticParam.
 
void Close ()
 Close a haptic device previously opened with Haptic.Haptic(). More...
 
HapticID GetID ()
 Get the instance ID of an opened haptic device. More...
 
const char * GetName ()
 Get the implementation dependent name of a haptic device. More...
 
int GetMaxEffects ()
 Get the number of effects a haptic device can store. More...
 
int GetMaxEffectsPlaying ()
 Get the number of effects a haptic device can play at the same time. More...
 
Uint32 GetFeatures ()
 Get the haptic device's supported features in bitwise manner. More...
 
int GetNumAxes ()
 Get the number of haptic axes the device has. More...
 
bool EffectSupported (const HapticEffect &effect)
 Check to see if an effect is supported by a haptic device. More...
 
int CreateEffect (const HapticEffect &effect)
 Create a new haptic effect on a specified device. More...
 
void UpdateEffect (int effect, const HapticEffect &data)
 Update the properties of an effect. More...
 
void RunEffect (int effect, Uint32 iterations)
 Run the haptic effect on its associated haptic device. More...
 
void StopEffect (int effect)
 Stop the haptic effect on its associated haptic device. More...
 
void DestroyEffect (int effect)
 Destroy a haptic effect on the device. More...
 
bool GetEffectStatus (int effect)
 Get the status of the current effect on the specified haptic device. More...
 
void SetGain (int gain)
 Set the global gain of the specified haptic device. More...
 
void SetAutocenter (int autocenter)
 Set the global autocenter of the device. More...
 
void Pause ()
 Pause a haptic device. More...
 
void Resume ()
 Resume a haptic device. More...
 
void StopEffects ()
 Stop all the currently playing effects on a haptic device. More...
 
bool RumbleSupported ()
 Check whether rumble is supported on a haptic device. More...
 
void InitRumble ()
 Initialize a haptic device for simple rumble playback. More...
 
void PlayRumble (float strength, Uint32 length)
 Run a simple rumble effect on a haptic device. More...
 
void StopRumble ()
 Stop the simple rumble on a haptic device. More...
 

Static Public Member Functions

static Haptic OpenFromMouse ()
 Try to open a haptic device from the current mouse. More...
 

Detailed Description

Since
This struct is available since SDL 3.2.0.
See also
Haptic.Haptic
Haptic.Haptic
Haptic.Close
Category:
Resource

Constructor & Destructor Documentation

◆ Haptic() [1/3]

constexpr SDL::Haptic::Haptic ( const HapticRaw  resource)
inlineexplicitconstexpr
Parameters
resourcea HapticRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ Haptic() [2/3]

SDL::Haptic::Haptic ( HapticID  instance_id)
inline

The index passed as an argument refers to the N'th haptic device on this system.

When opening a haptic device, its gain will be set to maximum and autocenter will be disabled. To modify these values use Haptic.SetGain() and Haptic.SetAutocenter().

Parameters
instance_idthe haptic device instance ID.
Postcondition
the device identifier or nullptr on failure; call GetError() for more information.
Since
This function is available since SDL 3.2.0.
See also
Haptic.Close
GetHaptics
Haptic.Haptic
Haptic.OpenFromMouse
Haptic.SetAutocenter
Haptic.SetGain

◆ Haptic() [3/3]

SDL::Haptic::Haptic ( JoystickParam  joystick)
inline

You must still close the haptic device separately. It will not be closed with the joystick.

When opened from a joystick you should first close the haptic device before closing the joystick device. If not, on some implementations the haptic device will also get unallocated and you'll be unable to use force feedback on that device.

Parameters
joystickthe Joystick to create a haptic device from.
Postcondition
a valid haptic device identifier on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
Haptic.Close
IsJoystickHaptic

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