SDL_GetMice() follows the SDL_GetStringRule

This commit is contained in:
Sam Lantinga 2024-07-18 17:29:24 -07:00
parent 6ca18ed0e5
commit 9be73ed7c5
6 changed files with 11 additions and 12 deletions

View File

@ -135,9 +135,10 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasMouse(void);
* You should wait for input from a device before you consider it actively in
* use.
*
* \param count a pointer filled in with the number of mice returned.
* \returns a 0 terminated array of mouse instance IDs which should be freed
* with SDL_free(), or NULL on failure; call SDL_GetError() for more
* The returned array follows the SDL_GetStringRule, and will be automatically freed later.
*
* \param count a pointer filled in with the number of mice returned, may be NULL.
* \returns a 0 terminated array of mouse instance IDs or NULL on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 3.0.0.
@ -145,7 +146,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasMouse(void);
* \sa SDL_GetMouseNameForID
* \sa SDL_HasMouse
*/
extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count);
extern SDL_DECLSPEC const SDL_MouseID * SDLCALL SDL_GetMice(int *count);
/**
* Get the name of a mouse.

View File

@ -379,7 +379,7 @@ SDL_DYNAPI_PROC(int,SDL_GetMasksForPixelFormat,(SDL_PixelFormat a, int *b, Uint3
SDL_DYNAPI_PROC(int,SDL_GetMaxHapticEffects,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetMaxHapticEffectsPlaying,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
SDL_DYNAPI_PROC(SDL_MouseID*,SDL_GetMice,(int *a),(a),return)
SDL_DYNAPI_PROC(const SDL_MouseID*,SDL_GetMice,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_Keymod,SDL_GetModState,(void),(),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetMouseFocus,(void),(),return)
SDL_DYNAPI_PROC(const char*,SDL_GetMouseNameForID,(SDL_MouseID a),(a),return)

View File

@ -346,7 +346,7 @@ SDL_bool SDL_HasMouse(void)
return (SDL_mouse_count > 0);
}
SDL_MouseID *SDL_GetMice(int *count)
const SDL_MouseID *SDL_GetMice(int *count)
{
int i;
SDL_MouseID *mice;
@ -367,7 +367,7 @@ SDL_MouseID *SDL_GetMice(int *count)
}
}
return mice;
return SDL_FreeLater(mice);
}
const char *SDL_GetMouseNameForID(SDL_MouseID instance_id)

View File

@ -871,7 +871,7 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c
int new_keyboard_count = 0;
SDL_KeyboardID *new_keyboards = NULL;
int old_mouse_count = 0;
SDL_MouseID *old_mice = NULL;
const SDL_MouseID *old_mice = NULL;
int new_mouse_count = 0;
SDL_MouseID *new_mice = NULL;
SDL_bool send_event = !initial_check;
@ -983,7 +983,6 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c
}
SDL_free(new_keyboards);
SDL_free(old_mice);
SDL_free(new_mice);
SetupDiDestroyDeviceInfoList(devinfo);

View File

@ -738,7 +738,7 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check)
int new_keyboard_count = 0;
SDL_KeyboardID *new_keyboards = NULL;
int old_mouse_count = 0;
SDL_MouseID *old_mice = NULL;
const SDL_MouseID *old_mice = NULL;
int new_mouse_count = 0;
SDL_MouseID *new_mice = NULL;
int old_touch_count = 0;
@ -840,7 +840,6 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check)
}
SDL_free(new_keyboards);
SDL_free(old_mice);
SDL_free(new_mice);
SDL_free(old_touch_devices);
SDL_free(new_touch_devices);

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
SDL_GetKeyboards(&num_keyboards);
SDL_Log("There are %d keyboards at startup\n", num_keyboards);
SDL_free(SDL_GetMice(&num_mice));
SDL_GetMice(&num_mice);
SDL_Log("There are %d mice at startup\n", num_mice);
SDL_GetJoysticks(&num_joysticks);