---
name: "SDL_SetJoystickPlayerIndex"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_SetJoystickPlayerIndex"
---

# SDL\_SetJoystickPlayerIndex(3)

Set the player index of an opened joystick.

## NAME

SDL\_SetJoystickPlayerIndex - Set the player index of an opened joystick.

## HEADER FILE

Defined in SDL3/SDL\_joystick.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_SetJoystickPlayerIndex(SDL\_Joystick \*joystick, int player\_index);**

## FUNCTION PARAMETERS

- *joystick*

  the  **SDL\_Joystick**\
    obtained from  **SDL\_OpenJoystick** ().

- *player\_index*

  player index to assign to this joystick, or -1 to clear the player index and turn off player LEDs.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_GetJoystickPlayerIndex**(3)](/SDL_GetJoystickPlayerIndex/3.md)
