Skip to content

Commit

Permalink
SDL_GetMice() follows the SDL_GetStringRule
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 19, 2024
1 parent 8776480 commit a9d895d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
9 changes: 5 additions & 4 deletions include/SDL3/SDL_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,18 @@ 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.
*
* \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.
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi_procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,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)
Expand Down
4 changes: 2 additions & 2 deletions src/events/SDL_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -367,7 +367,7 @@ SDL_MouseID *SDL_GetMice(int *count)
}
}

return mice;
return SDL_FreeLater(mice);
}

const char *SDL_GetMouseNameForID(SDL_MouseID instance_id)
Expand Down
3 changes: 1 addition & 2 deletions src/video/windows/SDL_windowsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/video/x11/SDL_x11xinput2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/testhotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a9d895d

Please sign in to comment.