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

Semi-safe reference for Haptic.

Inheritance diagram for SDL::HapticRef:
Inheritance graph
[legend]
Collaboration diagram for SDL::HapticRef:
Collaboration graph
[legend]

Public Member Functions

 HapticRef (HapticParam resource) noexcept
 Constructs from HapticParam. More...
 
 HapticRef (HapticRaw resource) noexcept
 Constructs from HapticParam. More...
 
constexpr HapticRef (const HapticRef &other) noexcept=default
 Copy constructor.
 
 ~HapticRef ()
 Destructor.
 
constexpr Haptic (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Haptic (const HapticRaw resource) noexcept
 Constructs from HapticParam. More...
 
constexpr Haptic (const Haptic &other) noexcept=default
 Copy constructor.
 
constexpr Haptic (Haptic &&other) noexcept
 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...
 
- Public Member Functions inherited from SDL::Haptic
constexpr Haptic (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Haptic (const HapticRaw resource) noexcept
 Constructs from HapticParam. More...
 
constexpr Haptic (Haptic &&other) noexcept
 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.
 
constexpr Hapticoperator= (Haptic &&other) noexcept
 Assignment operator.
 
constexpr HapticRaw get () const noexcept
 Retrieves underlying HapticRaw.
 
constexpr HapticRaw release () noexcept
 Retrieves underlying HapticRaw and clear this.
 
constexpr auto operator<=> (const Haptic &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
constexpr operator HapticParam () const noexcept
 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...
 
HapticEffectID CreateEffect (const HapticEffect &effect)
 Create a new haptic effect on a specified device. More...
 
void UpdateEffect (HapticEffectID effect, const HapticEffect &data)
 Update the properties of an effect. More...
 
void RunEffect (HapticEffectID effect, Uint32 iterations)
 Run the haptic effect on its associated haptic device. More...
 
void StopEffect (HapticEffectID effect)
 Stop the haptic effect on its associated haptic device. More...
 
void DestroyEffect (HapticEffectID effect)
 Destroy a haptic effect on the device. More...
 
bool GetEffectStatus (HapticEffectID 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from SDL::Haptic
static Haptic OpenFromMouse ()
 Try to open a haptic device from the current mouse. More...
 
- Protected Member Functions inherited from SDL::Haptic
constexpr Haptic (const Haptic &other) noexcept=default
 Copy constructor.
 
constexpr Hapticoperator= (const Haptic &other) noexcept=default
 Assignment operator.
 

Constructor & Destructor Documentation

◆ HapticRef() [1/2]

SDL::HapticRef::HapticRef ( HapticParam  resource)
inlinenoexcept
Parameters
resourcea HapticRaw or Haptic.

This does not takes ownership!

◆ HapticRef() [2/2]

SDL::HapticRef::HapticRef ( HapticRaw  resource)
inlinenoexcept
Parameters
resourcea HapticRaw or Haptic.

This does not takes ownership!

Member Function Documentation

◆ Haptic() [1/3]

constexpr SDL::Haptic::Haptic ( const HapticRaw  resource)
inlineexplicitconstexprnoexcept
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 struct was generated from the following file: