---
name: "SDL_GetGamepadJoystick"
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_GetGamepadJoystick"
---

# SDL\_GetGamepadJoystick(3)

Get the underlying joystick from a gamepad.

## NAME

SDL\_GetGamepadJoystick - Get the underlying joystick from a gamepad.

## HEADER FILE

Defined in SDL3/SDL\_gamepad.h

## SYNOPSIS

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

**SDL\_Joystick \* SDL\_GetGamepadJoystick(SDL\_Gamepad \*gamepad);**

## DESCRIPTION

This function will give you a  **SDL\_Joystick**\
  object, which allows you to use the  **SDL\_Joystick**\
  functions with a

**SDL\_Gamepad**\
  object. This would be useful for getting a joystick's position at any given time, even if it hasn't moved (moving it would produce an event, which would have the axis' value).

The pointer returned is owned by the  **SDL\_Gamepad** . You should not call  **SDL\_CloseJoystick** () on it, for example, since doing so will likely cause SDL to crash.

## FUNCTION PARAMETERS

- *gamepad*

  the gamepad object that you want to get a joystick from.

## RETURN VALUE

( **SDL\_Joystick**\
  \*) Returns an  **SDL\_Joystick**

object, or NULL on failure; call  **SDL\_GetError** () for more information.

## AVAILABILITY

This function is available since SDL 3.2.0.
