SDL_guid.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_guid.h
  20. *
  21. * Include file for handling ::SDL_GUID values.
  22. */
  23. #ifndef SDL_guid_h_
  24. #define SDL_guid_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/SDL_error.h>
  27. #include <SDL3/SDL_begin_code.h>
  28. /* Set up for C function definitions, even when using C++ */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /**
  33. * An SDL_GUID is a 128-bit identifier for an input device that identifies
  34. * that device across runs of SDL programs on the same platform.
  35. *
  36. * If the device is detached and then re-attached to a different port, or if
  37. * the base system is rebooted, the device should still report the same GUID.
  38. *
  39. * GUIDs are as precise as possible but are not guaranteed to distinguish
  40. * physically distinct but equivalent devices. For example, two game
  41. * controllers from the same vendor with the same product ID and revision may
  42. * have the same GUID.
  43. *
  44. * GUIDs may be platform-dependent (i.e., the same device may report different
  45. * GUIDs on different operating systems).
  46. *
  47. * \since This struct is available since SDL 3.0.0.
  48. */
  49. typedef struct SDL_GUID {
  50. Uint8 data[16];
  51. } SDL_GUID;
  52. /* Function prototypes */
  53. /**
  54. * Get an ASCII string representation for a given ::SDL_GUID.
  55. *
  56. * You should supply at least 33 bytes for pszGUID.
  57. *
  58. * \param guid the ::SDL_GUID you wish to convert to string
  59. * \param pszGUID buffer in which to write the ASCII string
  60. * \param cbGUID the size of pszGUID
  61. * \returns 0 on success or a negative error code on failure; call
  62. * SDL_GetError() for more information.
  63. *
  64. * \since This function is available since SDL 3.0.0.
  65. *
  66. * \sa SDL_GUIDFromString
  67. */
  68. extern DECLSPEC int SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
  69. /**
  70. * Convert a GUID string into a ::SDL_GUID structure.
  71. *
  72. * Performs no error checking. If this function is given a string containing
  73. * an invalid GUID, the function will silently succeed, but the GUID generated
  74. * will not be useful.
  75. *
  76. * \param pchGUID string containing an ASCII representation of a GUID
  77. * \returns a ::SDL_GUID structure.
  78. *
  79. * \since This function is available since SDL 3.0.0.
  80. *
  81. * \sa SDL_GUIDToString
  82. */
  83. extern DECLSPEC SDL_GUID SDLCALL SDL_GUIDFromString(const char *pchGUID);
  84. /* Ends C function definitions when using C++ */
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #include <SDL3/SDL_close_code.h>
  89. #endif /* SDL_guid_h_ */