---
name: "SDL_GetJoystickHat"
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_GetJoystickHat"
---

# SDL\_GetJoystickHat(3)

Get the current state of a POV hat on a joystick.

## NAME

SDL\_GetJoystickHat - Get the current state of a POV hat on a joystick.

## HEADER FILE

Defined in SDL3/SDL\_joystick.h

## SYNOPSIS

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

**Uint8 SDL\_GetJoystickHat(SDL\_Joystick \*joystick, int hat);** **#define SDL\_HAT\_CENTERED    0x00u** **#define SDL\_HAT\_UP          0x01u** **#define SDL\_HAT\_RIGHT       0x02u** **#define SDL\_HAT\_DOWN        0x04u** **#define SDL\_HAT\_LEFT        0x08u** **#define SDL\_HAT\_RIGHTUP     (SDL\_HAT\_RIGHT\|SDL\_HAT\_UP)** **#define SDL\_HAT\_RIGHTDOWN   (SDL\_HAT\_RIGHT\|SDL\_HAT\_DOWN)** **#define SDL\_HAT\_LEFTUP      (SDL\_HAT\_LEFT\|SDL\_HAT\_UP)** **#define SDL\_HAT\_LEFTDOWN    (SDL\_HAT\_LEFT\|SDL\_HAT\_DOWN)**

## DESCRIPTION

The returned value will be one of the **SDL\_HAT\_\*** values.

## FUNCTION PARAMETERS

- *joystick*

  an  **SDL\_Joystick**\
    structure containing joystick information.

- *hat*

  the hat index to get the state from; indices start at index 0.

## RETURN VALUE

Returns the current hat position.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_GetNumJoystickHats**(3)](/SDL_GetNumJoystickHats/3.md)
