Atlas - SDL_hidapihaptic_c.h

Home / ext / SDL / src / haptic / hidapi Lines: 1 | Size: 4176 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 2025 Katharine Chui <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21 22#ifndef SDL_hidapihaptic_c_h_ 23#define SDL_hidapihaptic_c_h_ 24 25#include "SDL3/SDL_haptic.h" 26#include "SDL3/SDL_joystick.h" 27#include "../SDL_syshaptic.h" 28#include "../../joystick/SDL_joystick_c.h" // accessing _SDL_JoystickDriver 29#include "../../joystick/SDL_sysjoystick.h" // accessing _SDL_Joystick 30 31#define SDL_HAPTIC_HIDAPI_LG4FF 32 33typedef struct SDL_HIDAPI_HapticDriver SDL_HIDAPI_HapticDriver; 34typedef struct SDL_HIDAPI_HapticDevice 35{ 36 SDL_Haptic *haptic; /* related haptic ref */ 37 SDL_Joystick *joystick; /* related hidapi joystick */ 38 SDL_HIDAPI_HapticDriver *driver; /* driver to use */ 39 void *ctx; /* driver specific context */ 40} SDL_HIDAPI_HapticDevice; 41 42struct SDL_HIDAPI_HapticDriver 43{ 44 bool (*JoystickSupported)(SDL_Joystick *joystick); /* return true if haptic can be opened from the joystick */ 45 void *(*Open)(SDL_Joystick *joystick); /* returns a driver context allocated with SDL_malloc, or null if it cannot be allocated */ 46 47 /* functions below need to handle the possibility of a null joystick instance, indicating the absence of the joystick */ 48 void (*Close)(SDL_HIDAPI_HapticDevice *device); /* cleanup resources allocated during Open, do NOT free driver context created in Open */ 49 50 /* below mirror SDL_haptic.h effect interfaces */ 51 int (*NumEffects)(SDL_HIDAPI_HapticDevice *device); /* returns supported number of effects the device can store */ 52 int (*NumEffectsPlaying)(SDL_HIDAPI_HapticDevice *device); /* returns supported number of effects the device can play concurrently */ 53 Uint32 (*GetFeatures)(SDL_HIDAPI_HapticDevice *device); /* returns supported effects in a bitmask */ 54 int (*NumAxes)(SDL_HIDAPI_HapticDevice *device); /* returns the number of haptic axes */ 55 SDL_HapticEffectID (*CreateEffect)(SDL_HIDAPI_HapticDevice *device, const SDL_HapticEffect *data); /* returns effect id if created correctly, negative number on error */ 56 bool (*UpdateEffect)(SDL_HIDAPI_HapticDevice *device, SDL_HapticEffectID id, const SDL_HapticEffect *data); /* returns true on success, false on error */ 57 bool (*RunEffect)(SDL_HIDAPI_HapticDevice *device, SDL_HapticEffectID id, Uint32 iterations); /* returns true on success, false on error */ 58 bool (*StopEffect)(SDL_HIDAPI_HapticDevice *device, SDL_HapticEffectID id); /* returns true on success, false on error */ 59 void (*DestroyEffect)(SDL_HIDAPI_HapticDevice *device, SDL_HapticEffectID id); 60 bool (*GetEffectStatus)(SDL_HIDAPI_HapticDevice *device, SDL_HapticEffectID id); /* returns true if playing, false if not playing or on error */ 61 bool (*SetGain)(SDL_HIDAPI_HapticDevice *device, int gain); /* gain 0 - 100, returns true on success, false on error */ 62 bool (*SetAutocenter)(SDL_HIDAPI_HapticDevice *device, int autocenter); /* autocenter 0 - 100, returns true on success, false on error */ 63 bool (*Pause)(SDL_HIDAPI_HapticDevice *device); /* returns true on success, false on error */ 64 bool (*Resume)(SDL_HIDAPI_HapticDevice *device); /* returns true on success, false on error */ 65 bool (*StopEffects)(SDL_HIDAPI_HapticDevice *device); /* returns true on success, false on error */ 66}; 67 68extern SDL_HIDAPI_HapticDriver SDL_HIDAPI_HapticDriverLg4ff; 69 70#endif //SDL_joystick_c_h_ 71
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.