SDL_guid.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  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. /* WIKI CATEGORY: GUID */
  19. /**
  20. * # CategoryGUID
  21. *
  22. * A GUID is a 128-bit value that represents something that is uniquely
  23. * identifiable by this value: "globally unique."
  24. *
  25. * SDL provides functions to convert a GUID to/from a string.
  26. */
  27. #ifndef SDL_guid_h_
  28. #define SDL_guid_h_
  29. #include <SDL3/SDL_stdinc.h>
  30. #include <SDL3/SDL_begin_code.h>
  31. /* Set up for C function definitions, even when using C++ */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. * An SDL_GUID is a 128-bit identifier for an input device that identifies
  37. * that device across runs of SDL programs on the same platform.
  38. *
  39. * If the device is detached and then re-attached to a different port, or if
  40. * the base system is rebooted, the device should still report the same GUID.
  41. *
  42. * GUIDs are as precise as possible but are not guaranteed to distinguish
  43. * physically distinct but equivalent devices. For example, two game
  44. * controllers from the same vendor with the same product ID and revision may
  45. * have the same GUID.
  46. *
  47. * GUIDs may be platform-dependent (i.e., the same device may report different
  48. * GUIDs on different operating systems).
  49. *
  50. * \since This struct is available since SDL 3.1.3.
  51. */
  52. typedef struct SDL_GUID {
  53. Uint8 data[16];
  54. } SDL_GUID;
  55. /* Function prototypes */
  56. /**
  57. * Get an ASCII string representation for a given SDL_GUID.
  58. *
  59. * \param guid the SDL_GUID you wish to convert to string.
  60. * \param pszGUID buffer in which to write the ASCII string.
  61. * \param cbGUID the size of pszGUID, should be at least 33 bytes.
  62. *
  63. * \since This function is available since SDL 3.1.3.
  64. *
  65. * \sa SDL_StringToGUID
  66. */
  67. extern SDL_DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
  68. /**
  69. * Convert a GUID string into a SDL_GUID structure.
  70. *
  71. * Performs no error checking. If this function is given a string containing
  72. * an invalid GUID, the function will silently succeed, but the GUID generated
  73. * will not be useful.
  74. *
  75. * \param pchGUID string containing an ASCII representation of a GUID.
  76. * \returns a SDL_GUID structure.
  77. *
  78. * \since This function is available since SDL 3.1.3.
  79. *
  80. * \sa SDL_GUIDToString
  81. */
  82. extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_StringToGUID(const char *pchGUID);
  83. /* Ends C function definitions when using C++ */
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #include <SDL3/SDL_close_code.h>
  88. #endif /* SDL_guid_h_ */