SDL_touch.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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_touch.h
  20. *
  21. * Include file for SDL touch event handling.
  22. */
  23. #ifndef SDL_touch_h_
  24. #define SDL_touch_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/SDL_error.h>
  27. #include <SDL3/SDL_video.h>
  28. #include <SDL3/SDL_begin_code.h>
  29. /* Set up for C function definitions, even when using C++ */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. typedef Uint64 SDL_TouchID;
  34. typedef Uint64 SDL_FingerID;
  35. typedef enum
  36. {
  37. SDL_TOUCH_DEVICE_INVALID = -1,
  38. SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */
  39. SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */
  40. SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */
  41. } SDL_TouchDeviceType;
  42. typedef struct SDL_Finger
  43. {
  44. SDL_FingerID id;
  45. float x;
  46. float y;
  47. float pressure;
  48. } SDL_Finger;
  49. /* Used as the device ID for mouse events simulated with touch input */
  50. #define SDL_TOUCH_MOUSEID ((Uint32)-1)
  51. /* Used as the SDL_TouchID for touch events simulated with mouse input */
  52. #define SDL_MOUSE_TOUCHID ((Uint64)-1)
  53. /**
  54. * Get a list of registered touch devices.
  55. *
  56. * On some platforms SDL first sees the touch device if it was actually used.
  57. * Therefore the returned list might be empty, although devices are available.
  58. * After using all devices at least once the number will be correct.
  59. *
  60. * This was fixed for Android in SDL 2.0.1.
  61. *
  62. * \param count a pointer filled in with the number of devices returned, can
  63. * be NULL.
  64. * \returns a 0 terminated array of touch device IDs which should be freed
  65. * with SDL_free(), or NULL on error; call SDL_GetError() for more
  66. * details.
  67. *
  68. * \since This function is available since SDL 3.0.0.
  69. */
  70. extern DECLSPEC SDL_TouchID *SDLCALL SDL_GetTouchDevices(int *count);
  71. /**
  72. * Get the touch device name as reported from the driver.
  73. *
  74. * You do not own the returned string, do not modify or free it.
  75. *
  76. * \param touchID the touch device instance ID.
  77. * \returns touch device name, or NULL on error; call SDL_GetError() for more
  78. * details.
  79. *
  80. * \since This function is available since SDL 3.0.0.
  81. */
  82. extern DECLSPEC const char* SDLCALL SDL_GetTouchDeviceName(SDL_TouchID touchID);
  83. /**
  84. * Get the type of the given touch device.
  85. *
  86. * \param touchID the ID of a touch device
  87. * \returns touch device type
  88. *
  89. * \since This function is available since SDL 3.0.0.
  90. */
  91. extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID);
  92. /**
  93. * Get the number of active fingers for a given touch device.
  94. *
  95. * \param touchID the ID of a touch device
  96. * \returns the number of active fingers for a given touch device on success
  97. * or a negative error code on failure; call SDL_GetError() for more
  98. * information.
  99. *
  100. * \since This function is available since SDL 3.0.0.
  101. *
  102. * \sa SDL_GetTouchFinger
  103. */
  104. extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID);
  105. /**
  106. * Get the finger object for specified touch device ID and finger index.
  107. *
  108. * The returned resource is owned by SDL and should not be deallocated.
  109. *
  110. * \param touchID the ID of the requested touch device
  111. * \param index the index of the requested finger
  112. * \returns a pointer to the SDL_Finger object or NULL if no object at the
  113. * given ID and index could be found.
  114. *
  115. * \since This function is available since SDL 3.0.0.
  116. */
  117. extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index);
  118. /* Ends C function definitions when using C++ */
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #include <SDL3/SDL_close_code.h>
  123. #endif /* SDL_touch_h_ */