mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-28 23:49:12 +00:00
SDL_GetKeyboards() follows the SDL_GetStringRule
This commit is contained in:
parent
5ce0aacaa4
commit
6ca18ed0e5
6 changed files with 13 additions and 14 deletions
|
@ -73,9 +73,10 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasKeyboard(void);
|
||||||
* power buttons, etc. You should wait for input from a device before you
|
* power buttons, etc. You should wait for input from a device before you
|
||||||
* consider it actively in use.
|
* consider it actively in use.
|
||||||
*
|
*
|
||||||
* \param count a pointer filled in with the number of keyboards returned.
|
* The returned array follows the SDL_GetStringRule, and will be automatically freed later.
|
||||||
* \returns a 0 terminated array of keyboards instance IDs which should be
|
*
|
||||||
* freed with SDL_free(), or NULL on failure; call SDL_GetError() for
|
* \param count a pointer filled in with the number of keyboards returned, may be NULL.
|
||||||
|
* \returns a 0 terminated array of keyboards instance IDs 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.
|
||||||
|
@ -83,7 +84,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasKeyboard(void);
|
||||||
* \sa SDL_GetKeyboardNameForID
|
* \sa SDL_GetKeyboardNameForID
|
||||||
* \sa SDL_HasKeyboard
|
* \sa SDL_HasKeyboard
|
||||||
*/
|
*/
|
||||||
extern SDL_DECLSPEC SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count);
|
extern SDL_DECLSPEC const SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a keyboard.
|
* Get the name of a keyboard.
|
||||||
|
|
|
@ -372,7 +372,7 @@ SDL_DYNAPI_PROC(const char*,SDL_GetKeyName,(SDL_Keycode a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetKeyboardFocus,(void),(),return)
|
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetKeyboardFocus,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(const char*,SDL_GetKeyboardNameForID,(SDL_KeyboardID a),(a),return)
|
SDL_DYNAPI_PROC(const char*,SDL_GetKeyboardNameForID,(SDL_KeyboardID a),(a),return)
|
||||||
SDL_DYNAPI_PROC(const Uint8*,SDL_GetKeyboardState,(int *a),(a),return)
|
SDL_DYNAPI_PROC(const Uint8*,SDL_GetKeyboardState,(int *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_KeyboardID*,SDL_GetKeyboards,(int *a),(a),return)
|
SDL_DYNAPI_PROC(const SDL_KeyboardID*,SDL_GetKeyboards,(int *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_GetLogOutputFunction,(SDL_LogOutputFunction *a, void **b),(a,b),)
|
SDL_DYNAPI_PROC(void,SDL_GetLogOutputFunction,(SDL_LogOutputFunction *a, void **b),(a,b),)
|
||||||
SDL_DYNAPI_PROC(SDL_LogPriority,SDL_GetLogPriority,(int a),(a),return)
|
SDL_DYNAPI_PROC(SDL_LogPriority,SDL_GetLogPriority,(int a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_GetMasksForPixelFormat,(SDL_PixelFormat a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
|
SDL_DYNAPI_PROC(int,SDL_GetMasksForPixelFormat,(SDL_PixelFormat a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
|
||||||
|
|
|
@ -177,7 +177,7 @@ SDL_bool SDL_HasKeyboard(void)
|
||||||
return (SDL_keyboard_count > 0);
|
return (SDL_keyboard_count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_KeyboardID *SDL_GetKeyboards(int *count)
|
const SDL_KeyboardID *SDL_GetKeyboards(int *count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
SDL_KeyboardID *keyboards;
|
SDL_KeyboardID *keyboards;
|
||||||
|
@ -198,7 +198,7 @@ SDL_KeyboardID *SDL_GetKeyboards(int *count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyboards;
|
return SDL_FreeLater(keyboards);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id)
|
const char *SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id)
|
||||||
|
|
|
@ -824,7 +824,7 @@ static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count)
|
||||||
*list = new_list;
|
*list = new_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool HasDeviceID(Uint32 deviceID, Uint32 *list, int count)
|
static SDL_bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
if (deviceID == list[i]) {
|
if (deviceID == list[i]) {
|
||||||
|
@ -867,7 +867,7 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c
|
||||||
PRAWINPUTDEVICELIST raw_devices = NULL;
|
PRAWINPUTDEVICELIST raw_devices = NULL;
|
||||||
UINT raw_device_count = 0;
|
UINT raw_device_count = 0;
|
||||||
int old_keyboard_count = 0;
|
int old_keyboard_count = 0;
|
||||||
SDL_KeyboardID *old_keyboards = NULL;
|
const SDL_KeyboardID *old_keyboards = NULL;
|
||||||
int new_keyboard_count = 0;
|
int new_keyboard_count = 0;
|
||||||
SDL_KeyboardID *new_keyboards = NULL;
|
SDL_KeyboardID *new_keyboards = NULL;
|
||||||
int old_mouse_count = 0;
|
int old_mouse_count = 0;
|
||||||
|
@ -982,7 +982,6 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(old_keyboards);
|
|
||||||
SDL_free(new_keyboards);
|
SDL_free(new_keyboards);
|
||||||
SDL_free(old_mice);
|
SDL_free(old_mice);
|
||||||
SDL_free(new_mice);
|
SDL_free(new_mice);
|
||||||
|
|
|
@ -715,7 +715,7 @@ static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count)
|
||||||
*list = new_list;
|
*list = new_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool HasDeviceID(Uint32 deviceID, Uint32 *list, int count)
|
static SDL_bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
if (deviceID == list[i]) {
|
if (deviceID == list[i]) {
|
||||||
|
@ -734,7 +734,7 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check)
|
||||||
XIDeviceInfo *info;
|
XIDeviceInfo *info;
|
||||||
int ndevices;
|
int ndevices;
|
||||||
int old_keyboard_count = 0;
|
int old_keyboard_count = 0;
|
||||||
SDL_KeyboardID *old_keyboards = NULL;
|
const SDL_KeyboardID *old_keyboards = NULL;
|
||||||
int new_keyboard_count = 0;
|
int new_keyboard_count = 0;
|
||||||
SDL_KeyboardID *new_keyboards = NULL;
|
SDL_KeyboardID *new_keyboards = NULL;
|
||||||
int old_mouse_count = 0;
|
int old_mouse_count = 0;
|
||||||
|
@ -839,7 +839,6 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(old_keyboards);
|
|
||||||
SDL_free(new_keyboards);
|
SDL_free(new_keyboards);
|
||||||
SDL_free(old_mice);
|
SDL_free(old_mice);
|
||||||
SDL_free(new_mice);
|
SDL_free(new_mice);
|
||||||
|
|
|
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
||||||
//SDL_CreateWindow("Dummy", 128, 128, 0);
|
//SDL_CreateWindow("Dummy", 128, 128, 0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SDL_free(SDL_GetKeyboards(&num_keyboards));
|
SDL_GetKeyboards(&num_keyboards);
|
||||||
SDL_Log("There are %d keyboards at startup\n", num_keyboards);
|
SDL_Log("There are %d keyboards at startup\n", num_keyboards);
|
||||||
|
|
||||||
SDL_free(SDL_GetMice(&num_mice));
|
SDL_free(SDL_GetMice(&num_mice));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue