Atlas - SDL_sysjoystick.h

Home / ext / SDL2 / src / joystick Lines: 1 | Size: 5999 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2018 Sam Lantinga <[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#include "../SDL_internal.h" 22 23#ifndef SDL_sysjoystick_h_ 24#define SDL_sysjoystick_h_ 25 26/* This is the system specific header for the SDL joystick API */ 27 28#include "SDL_joystick.h" 29#include "SDL_joystick_c.h" 30 31/* The SDL joystick structure */ 32typedef struct _SDL_JoystickAxisInfo 33{ 34 Sint16 initial_value; /* Initial axis state */ 35 Sint16 value; /* Current axis state */ 36 Sint16 zero; /* Zero point on the axis (-32768 for triggers) */ 37 SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */ 38 SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */ 39} SDL_JoystickAxisInfo; 40 41struct _SDL_Joystick 42{ 43 SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */ 44 char *name; /* Joystick name - system dependent */ 45 SDL_JoystickGUID guid; /* Joystick guid */ 46 47 int naxes; /* Number of axis controls on the joystick */ 48 SDL_JoystickAxisInfo *axes; 49 50 int nhats; /* Number of hats on the joystick */ 51 Uint8 *hats; /* Current hat states */ 52 53 int nballs; /* Number of trackballs on the joystick */ 54 struct balldelta { 55 int dx; 56 int dy; 57 } *balls; /* Current ball motion deltas */ 58 59 int nbuttons; /* Number of buttons on the joystick */ 60 Uint8 *buttons; /* Current button states */ 61 62 SDL_bool attached; 63 SDL_bool is_game_controller; 64 SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */ 65 SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */ 66 SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */ 67 struct _SDL_JoystickDriver *driver; 68 69 struct joystick_hwdata *hwdata; /* Driver dependent information */ 70 71 int ref_count; /* Reference count for multiple opens */ 72 73 struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */ 74}; 75 76#if defined(__IPHONEOS__) || defined(__ANDROID__) 77#define HAVE_STEAMCONTROLLERS 78#define USE_STEAMCONTROLLER_HIDAPI 79#elif defined(__LINUX__) 80#define HAVE_STEAMCONTROLLERS 81#define USE_STEAMCONTROLLER_LINUX 82#endif 83 84/* Device bus definitions */ 85#define SDL_HARDWARE_BUS_USB 0x03 86#define SDL_HARDWARE_BUS_BLUETOOTH 0x05 87 88/* Macro to combine a USB vendor ID and product ID into a single Uint32 value */ 89#define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID)) 90 91typedef struct _SDL_JoystickDriver 92{ 93 /* Function to scan the system for joysticks. 94 * Joystick 0 should be the system default joystick. 95 * This function should return 0, or -1 on an unrecoverable error. 96 */ 97 int (*Init)(void); 98 99 /* Function to return the number of joystick devices plugged in right now */ 100 int (*GetCount)(void); 101 102 /* Function to cause any queued joystick insertions to be processed */ 103 void (*Detect)(void); 104 105 /* Function to get the device-dependent name of a joystick */ 106 const char *(*GetDeviceName)(int device_index); 107 108 /* Function to return the stable GUID for a plugged in device */ 109 SDL_JoystickGUID (*GetDeviceGUID)(int device_index); 110 111 /* Function to get the current instance id of the joystick located at device_index */ 112 SDL_JoystickID (*GetDeviceInstanceID)(int device_index); 113 114 /* Function to open a joystick for use. 115 The joystick to open is specified by the device index. 116 This should fill the nbuttons and naxes fields of the joystick structure. 117 It returns 0, or -1 if there is an error. 118 */ 119 int (*Open)(SDL_Joystick * joystick, int device_index); 120 121 /* Rumble functionality */ 122 int (*Rumble)(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); 123 124 /* Function to update the state of a joystick - called as a device poll. 125 * This function shouldn't update the joystick structure directly, 126 * but instead should call SDL_PrivateJoystick*() to deliver events 127 * and update joystick device state. 128 */ 129 void (*Update)(SDL_Joystick * joystick); 130 131 /* Function to close a joystick after use */ 132 void (*Close)(SDL_Joystick * joystick); 133 134 /* Function to perform any system-specific joystick related cleanup */ 135 void (*Quit)(void); 136 137} SDL_JoystickDriver; 138 139/* The available joystick drivers */ 140extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver; 141extern SDL_JoystickDriver SDL_BSD_JoystickDriver; 142extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver; 143extern SDL_JoystickDriver SDL_DUMMY_JoystickDriver; 144extern SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver; 145extern SDL_JoystickDriver SDL_HAIKU_JoystickDriver; 146extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver; 147extern SDL_JoystickDriver SDL_IOS_JoystickDriver; 148extern SDL_JoystickDriver SDL_LINUX_JoystickDriver; 149extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver; 150 151#endif /* SDL_sysjoystick_h_ */ 152 153/* vi: set ts=4 sw=4 expandtab: */ 154
[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.