Wiki Page Content

Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2010-08-28 21:27:56
Size: 1006
Editor: SheenaSmith
Comment: update content (old wiki)
Revision 4 as of 2013-02-07 14:42:23
Size: 1135
Comment: Changed argument to SDL_Joystick*.
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
const char* SDL_JoystickName(int device_index) const char* SDL_JoystickName(SDL_Joystick *joystick)
Line 16: Line 16:
||'''device_index'''||^the index of the joystick to query^ ''-or-'' *the N'th joystick on the system*|| ||'''joystick'''||^the [[SDL_Joystick]] obtained from [[SDL_JoystickOpen]] ||
Line 19: Line 19:
Returns the name of the selected joystick. If no name can be found, this function returns NULL. Returns the name of the selected joystick. If no name can be found, this function returns NULL; call [[SDL_GetError]]() for more information.
Line 26: Line 26:
num_joy=SDL_NumJoysticks(); num_joy = SDL_NumJoysticks();
Line 28: Line 28:
for(i=0;i<num_joy;i++)
  printf("%s\n", SDL_JoystickName(i));
for(i = 0; i < num_joy; i++)
{
  SDL_Joystick *joystick = SDL_JoystickOpen(i);

  printf("%s\n", SDL_JoystickName(joystick));
}
Line 34: Line 37:
This can be called before any joysticks are opened.  This can be called before any joysticks are opened.
Line 38: Line 41:
 .[[SDL_JoystickNameForIndex]] *

DRAFT

SDL_JoystickName

Use this function to get the implementation dependent name of a joystick.

Syntax

const char* SDL_JoystickName(SDL_Joystick *joystick)

Function Parameters

joystick

^the SDL_Joystick obtained from SDL_JoystickOpen

Return Value

Returns the name of the selected joystick. If no name can be found, this function returns NULL; call SDL_GetError() for more information.

Code Examples

*

/* Print the names of all attached joysticks */
int num_joy, i;
num_joy = SDL_NumJoysticks();
printf("%d joysticks found\n", num_joy);
for(i = 0; i < num_joy; i++)
{
  SDL_Joystick *joystick = SDL_JoystickOpen(i);
  printf("%s\n", SDL_JoystickName(joystick));
}

*

Remarks

This can be called before any joysticks are opened.


CategoryAPI, CategoryJoystick

None: SDL_JoystickName (last edited 2015-04-26 18:55:49 by PhilippWiesemann)

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