Path: blob/master/thirdparty/sdl/haptic/SDL_syshaptic.h
9905 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021#include "SDL_internal.h"2223#ifndef SDL_syshaptic_h_24#define SDL_syshaptic_h_2526// Set up for C function definitions, even when using C++27#ifdef __cplusplus28extern "C" {29#endif3031struct haptic_effect32{33SDL_HapticEffect effect; // The current event34struct haptic_hweffect *hweffect; // The hardware behind the event35};3637/*38* The real SDL_Haptic struct.39*/40struct SDL_Haptic41{42SDL_HapticID instance_id; // Device instance, monotonically increasing from 043char *name; // Device name - system dependent4445struct haptic_effect *effects; // Allocated effects46int neffects; // Maximum amount of effects47int nplaying; // Maximum amount of effects to play at the same time48Uint32 supported; // Supported effects and features49int naxes; // Number of axes on the device.5051struct haptic_hwdata *hwdata; // Driver dependent52int ref_count; // Count for multiple opens5354int rumble_id; // ID of rumble effect for simple rumble API.55SDL_HapticEffect rumble_effect; // Rumble effect.56struct SDL_Haptic *next; // pointer to next haptic we have allocated57};5859/*60* Scans the system for haptic devices.61*62* Returns number of devices on success, -1 on error.63*/64extern bool SDL_SYS_HapticInit(void);6566// Function to return the number of haptic devices plugged in right now67extern int SDL_SYS_NumHaptics(void);6869/*70* Gets the instance ID of the haptic device71*/72extern SDL_HapticID SDL_SYS_HapticInstanceID(int index);7374/*75* Gets the device dependent name of the haptic device76*/77extern const char *SDL_SYS_HapticName(int index);7879/*80* Opens the haptic device for usage. The haptic device should have81* the index value set previously.82*/83extern bool SDL_SYS_HapticOpen(SDL_Haptic *haptic);8485/*86* Returns the index of the haptic core pointer or -1 if none is found.87*/88extern int SDL_SYS_HapticMouse(void);8990/*91* Checks to see if the joystick has haptic capabilities.92*/93extern bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick);9495/*96* Opens the haptic device for usage using the same device as97* the joystick.98*/99extern bool SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic,100SDL_Joystick *joystick);101/*102* Checks to see if haptic device and joystick device are the same.103*104* Returns true if they are the same, false if they aren't.105*/106extern bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic,107SDL_Joystick *joystick);108109/*110* Closes a haptic device after usage.111*/112extern void SDL_SYS_HapticClose(SDL_Haptic *haptic);113114/*115* Performs a cleanup on the haptic subsystem.116*/117extern void SDL_SYS_HapticQuit(void);118119/*120* Creates a new haptic effect on the haptic device using base121* as a template for the effect.122*/123extern bool SDL_SYS_HapticNewEffect(SDL_Haptic *haptic,124struct haptic_effect *effect,125const SDL_HapticEffect *base);126127/*128* Updates the haptic effect on the haptic device using data129* as a template.130*/131extern bool SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,132struct haptic_effect *effect,133const SDL_HapticEffect *data);134135/*136* Runs the effect on the haptic device.137*/138extern bool SDL_SYS_HapticRunEffect(SDL_Haptic *haptic,139struct haptic_effect *effect,140Uint32 iterations);141142/*143* Stops the effect on the haptic device.144*/145extern bool SDL_SYS_HapticStopEffect(SDL_Haptic *haptic,146struct haptic_effect *effect);147148/*149* Cleanups up the effect on the haptic device.150*/151extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic *haptic,152struct haptic_effect *effect);153154/*155* Queries the device for the status of effect.156*157* Returns 0 if device is stopped, >0 if device is playing and158* -1 on error.159*/160extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,161struct haptic_effect *effect);162163/*164* Sets the global gain of the haptic device.165*/166extern bool SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain);167168/*169* Sets the autocenter feature of the haptic device.170*/171extern bool SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter);172173/*174* Pauses the haptic device.175*/176extern bool SDL_SYS_HapticPause(SDL_Haptic *haptic);177178/*179* Unpauses the haptic device.180*/181extern bool SDL_SYS_HapticResume(SDL_Haptic *haptic);182183/*184* Stops all the currently playing haptic effects on the device.185*/186extern bool SDL_SYS_HapticStopAll(SDL_Haptic *haptic);187188// Ends C function definitions when using C++189#ifdef __cplusplus190}191#endif192193#endif // SDL_syshaptic_h_194195196