Atlas - SDL_utils_c.h

Home / ext / SDL / src Lines: 1 | Size: 3346 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 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// This is included in SDL_internal.h 22//#include "SDL_internal.h" 23 24#ifndef SDL_utils_h_ 25#define SDL_utils_h_ 26 27// Common utility functions that aren't in the public API 28 29// Return the smallest power of 2 greater than or equal to 'x' 30extern int SDL_powerof2(int x); 31 32extern Uint32 SDL_CalculateGCD(Uint32 a, Uint32 b); 33extern void SDL_CalculateFraction(float x, int *numerator, int *denominator); 34 35extern bool SDL_startswith(const char *string, const char *prefix); 36extern bool SDL_endswith(const char *string, const char *suffix); 37 38/** Convert URI to a local filename, stripping the "file://" 39 * preamble and hostname if present, and writes the result 40 * to the dst buffer. Since URI-encoded characters take 41 * three times the space of normal characters, src and dst 42 * can safely point to the same buffer for in situ conversion. 43 * 44 * Returns the number of decoded bytes that wound up in 45 * the destination buffer, excluding the terminating NULL byte. 46 * 47 * On error, -1 is returned. 48 */ 49extern int SDL_URIToLocal(const char *src, char *dst); 50 51typedef enum 52{ 53 SDL_OBJECT_TYPE_UNKNOWN, 54 SDL_OBJECT_TYPE_WINDOW, 55 SDL_OBJECT_TYPE_RENDERER, 56 SDL_OBJECT_TYPE_TEXTURE, 57 SDL_OBJECT_TYPE_JOYSTICK, 58 SDL_OBJECT_TYPE_GAMEPAD, 59 SDL_OBJECT_TYPE_HAPTIC, 60 SDL_OBJECT_TYPE_SENSOR, 61 SDL_OBJECT_TYPE_HIDAPI_DEVICE, 62 SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, 63 SDL_OBJECT_TYPE_THREAD, 64 SDL_OBJECT_TYPE_TRAY, 65 66} SDL_ObjectType; 67 68extern Uint32 SDL_GetNextObjectID(void); 69extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid); 70extern bool SDL_FindObject(void *object, SDL_ObjectType type); 71extern int SDL_GetObjects(SDL_ObjectType type, void **objects, int count); 72extern void SDL_SetObjectsInvalid(void); 73 74extern bool SDL_object_validation; 75 76SDL_FORCE_INLINE bool SDL_ObjectValid(void *object, SDL_ObjectType type) 77{ 78 if (!object) { 79 return false; 80 } 81 82 if (!SDL_object_validation) { 83 return true; 84 } 85 86 return SDL_FindObject(object, type); 87} 88 89extern const char *SDL_GetPersistentString(const char *string); 90 91extern char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name, const char *default_name); 92 93// Log what backend a subsystem chose, if a hint was set to do so. Useful for debugging. 94extern void SDL_DebugLogBackend(const char *subsystem, const char *backend); 95 96#endif // SDL_utils_h_ 97
[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.