Wiki Page Content

Differences between revisions 3 and 4
Revision 3 as of 2013-02-13 18:35:11
Size: 1389
Editor: jorgenpt
Comment: Add a missing const
Revision 4 as of 2013-08-10 18:51:48
Size: 1401
Comment: Fixed warning and output errors in example.
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:
    char *name = SDL_GameControllerNameForIndex(i);     const char *name = SDL_GameControllerNameForIndex(i);
Line 33: Line 33:
        printf("Joystick %i has game controller name '%s'\n", name);         printf("Joystick %i has game controller name '%s'\n", i, name);
Line 35: Line 35:
        printf("Joystick %i has no game controller name.\n");         printf("Joystick %i has no game controller name.\n", i);

DRAFT

SDL_GameControllerNameForIndex

Use this function to get the implementation dependent name for the game controller.

Syntax

const char *SDL_GameControllerNameForIndex(int joystick_index)

Function Parameters

joystick_index

the device_index of a device, up to SDL_NumJoysticks()

Return Value

Returns the implementation dependent name for the game controller, or NULL if there is no name or the index is invalid.

Code Examples

for (int i = 0; i < SDL_NumJoysticks(); ++i) {
    const char *name = SDL_GameControllerNameForIndex(i);
    if (name) {
        printf("Joystick %i has game controller name '%s'\n", i, name);
    } else {
        printf("Joystick %i has no game controller name.\n", i);
    }
}

Remarks

joystick_index is the same as the device_index passed to SDL_JoystickOpen.


CategoryAPI, CategoryGameController

None: SDL_GameControllerNameForIndex (last edited 2016-04-10 22:45:35 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit