mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-15 17:28:28 +00:00
SDL_GetTouchFingers() follows the SDL_GetStringRule
This commit is contained in:
parent
975457cfb6
commit
0079b6d45f
4 changed files with 10 additions and 10 deletions
|
@ -122,16 +122,17 @@ extern SDL_DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_Touch
|
||||||
/**
|
/**
|
||||||
* Get a list of active fingers for a given touch device.
|
* Get a list of active fingers for a given touch device.
|
||||||
*
|
*
|
||||||
|
* This returns temporary memory which will be automatically freed later, and can be claimed with SDL_ClaimTemporaryMemory().
|
||||||
|
*
|
||||||
* \param touchID the ID of a touch device.
|
* \param touchID the ID of a touch device.
|
||||||
* \param count a pointer filled in with the number of fingers returned, can
|
* \param count a pointer filled in with the number of fingers returned, can
|
||||||
* be NULL.
|
* be NULL.
|
||||||
* \returns a NULL terminated array of SDL_Finger pointers which should be
|
* \returns a NULL terminated array of SDL_Finger pointers or NULL on failure; call SDL_GetError() for
|
||||||
* freed with SDL_free(), or NULL on failure; call SDL_GetError() for
|
|
||||||
* more information.
|
* more information.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*/
|
*/
|
||||||
extern SDL_DECLSPEC SDL_Finger ** SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count);
|
extern SDL_DECLSPEC const SDL_Finger * const * SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count);
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -501,7 +501,7 @@ SDL_DYNAPI_PROC(Uint64,SDL_GetTicksNS,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(const char*,SDL_GetTouchDeviceName,(SDL_TouchID a),(a),return)
|
SDL_DYNAPI_PROC(const char*,SDL_GetTouchDeviceName,(SDL_TouchID a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_TouchDeviceType,SDL_GetTouchDeviceType,(SDL_TouchID a),(a),return)
|
SDL_DYNAPI_PROC(SDL_TouchDeviceType,SDL_GetTouchDeviceType,(SDL_TouchID a),(a),return)
|
||||||
SDL_DYNAPI_PROC(const SDL_TouchID*,SDL_GetTouchDevices,(int *a),(a),return)
|
SDL_DYNAPI_PROC(const SDL_TouchID*,SDL_GetTouchDevices,(int *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_Finger**,SDL_GetTouchFingers,(SDL_TouchID a, int *b),(a,b),return)
|
SDL_DYNAPI_PROC(const SDL_Finger* const*,SDL_GetTouchFingers,(SDL_TouchID a, int *b),(a,b),return)
|
||||||
SDL_DYNAPI_PROC(const char*,SDL_GetUserFolder,(SDL_Folder a),(a),return)
|
SDL_DYNAPI_PROC(const char*,SDL_GetUserFolder,(SDL_Folder a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_GetVersion,(void),(),return)
|
SDL_DYNAPI_PROC(int,SDL_GetVersion,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
|
SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
|
||||||
|
|
|
@ -134,7 +134,7 @@ static SDL_Finger *SDL_GetFinger(const SDL_Touch *touch, SDL_FingerID id)
|
||||||
return touch->fingers[index];
|
return touch->fingers[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Finger **SDL_GetTouchFingers(SDL_TouchID touchID, int *count)
|
const SDL_Finger * const * SDL_GetTouchFingers(SDL_TouchID touchID, int *count)
|
||||||
{
|
{
|
||||||
SDL_Finger **fingers;
|
SDL_Finger **fingers;
|
||||||
SDL_Finger *finger_data;
|
SDL_Finger *finger_data;
|
||||||
|
@ -153,7 +153,7 @@ SDL_Finger **SDL_GetTouchFingers(SDL_TouchID touchID, int *count)
|
||||||
if (!fingers) {
|
if (!fingers) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
finger_data = (SDL_Finger *)((Uint8 *)fingers + (touch->num_fingers + 1) * sizeof(*fingers));
|
finger_data = (SDL_Finger *)(fingers + (touch->num_fingers + 1));
|
||||||
|
|
||||||
for (int i = 0; i < touch->num_fingers; ++i) {
|
for (int i = 0; i < touch->num_fingers; ++i) {
|
||||||
fingers[i] = &finger_data[i];
|
fingers[i] = &finger_data[i];
|
||||||
|
@ -164,7 +164,7 @@ SDL_Finger **SDL_GetTouchFingers(SDL_TouchID touchID, int *count)
|
||||||
if (count) {
|
if (count) {
|
||||||
*count = touch->num_fingers;
|
*count = touch->num_fingers;
|
||||||
}
|
}
|
||||||
return fingers;
|
return SDL_FreeLater(fingers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
|
int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
|
||||||
|
|
|
@ -1735,11 +1735,11 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
|
||||||
}
|
}
|
||||||
if (existingTouchCount == 0) {
|
if (existingTouchCount == 0) {
|
||||||
int numFingers;
|
int numFingers;
|
||||||
SDL_Finger **fingers = SDL_GetTouchFingers(touchID, &numFingers);
|
const SDL_Finger * const *fingers = SDL_GetTouchFingers(touchID, &numFingers);
|
||||||
if (fingers) {
|
if (fingers) {
|
||||||
DLog("Reset Lost Fingers: %d", numFingers);
|
DLog("Reset Lost Fingers: %d", numFingers);
|
||||||
for (--numFingers; numFingers >= 0; --numFingers) {
|
for (--numFingers; numFingers >= 0; --numFingers) {
|
||||||
SDL_Finger *finger = fingers[numFingers];
|
const SDL_Finger *finger = fingers[numFingers];
|
||||||
/* trackpad touches have no window. If we really wanted one we could
|
/* trackpad touches have no window. If we really wanted one we could
|
||||||
* use the window that has mouse or keyboard focus.
|
* use the window that has mouse or keyboard focus.
|
||||||
* Sending a null window currently also prevents synthetic mouse
|
* Sending a null window currently also prevents synthetic mouse
|
||||||
|
@ -1748,7 +1748,6 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
|
||||||
SDL_Window *window = NULL;
|
SDL_Window *window = NULL;
|
||||||
SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, SDL_FALSE, 0, 0, 0);
|
SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, SDL_FALSE, 0, 0, 0);
|
||||||
}
|
}
|
||||||
SDL_free(fingers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue