SDL_GetTouchDevices() follows the SDL_GetStringRule

This commit is contained in:
Sam Lantinga 2024-07-18 22:15:11 -07:00
parent 856d598d6e
commit eb22fcce35
4 changed files with 9 additions and 9 deletions

View File

@ -83,15 +83,16 @@ typedef struct SDL_Finger
* Therefore the returned list might be empty, although devices are available.
* After using all devices at least once the number will be correct.
*
* \param count a pointer filled in with the number of devices returned, can
* The returned array follows the SDL_GetStringRule, and will be automatically freed later.
*
* \param count a pointer filled in with the number of devices returned, may
* be NULL.
* \returns a 0 terminated array of touch device IDs which should be freed
* with SDL_free(), or NULL on failure; call SDL_GetError() for more
* \returns a 0 terminated array of touch device IDs or NULL on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count);
extern SDL_DECLSPEC const SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count);
/**
* Get the touch device name as reported from the driver.

View File

@ -502,7 +502,7 @@ SDL_DYNAPI_PROC(Uint64,SDL_GetTicks,(void),(),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetTicksNS,(void),(),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_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 char*,SDL_GetUserFolder,(SDL_Folder a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetVersion,(void),(),return)

View File

@ -49,7 +49,7 @@ SDL_bool SDL_TouchDevicesAvailable(void)
return SDL_num_touch > 0;
}
SDL_TouchID *SDL_GetTouchDevices(int *count)
const SDL_TouchID *SDL_GetTouchDevices(int *count)
{
if (count) {
*count = 0;
@ -67,7 +67,7 @@ SDL_TouchID *SDL_GetTouchDevices(int *count)
}
}
return retval;
return SDL_FreeLater(retval);
}
static int SDL_GetTouchIndex(SDL_TouchID id)

View File

@ -742,7 +742,7 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check)
int new_mouse_count = 0;
SDL_MouseID *new_mice = NULL;
int old_touch_count = 0;
SDL_TouchID *old_touch_devices64 = NULL;
const SDL_TouchID *old_touch_devices64 = NULL;
Uint32 *old_touch_devices = NULL;
int new_touch_count = 0;
Uint32 *new_touch_devices = NULL;
@ -765,7 +765,6 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check)
}
}
}
SDL_free(old_touch_devices64);
for (int i = 0; i < ndevices; i++) {
XIDeviceInfo *dev = &info[i];