CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Enumerations | Functions
Joystick.h File Reference
`#include <SFML/Window/Export.h>`

Go to the source code of this file.

## Enumerations
enum | { sfJoystickCount = 8, sfJoystickButtonCount = 32, sfJoystickAxisCount = 8 }
| Global joysticks capabilities. More...
enum | sfJoystickAxis { sfJoystickX, sfJoystickY, sfJoystickZ, sfJoystickR, sfJoystickU, sfJoystickV, sfJoystickPovX, sfJoystickPovY }
| Axes supported by SFML joysticks. More...

## Functions
CSFML_WINDOW_API sfBool | sfJoystick_isConnected (unsigned int joystick)
| Check if a joystick is connected. More...
CSFML_WINDOW_API unsigned int | sfJoystick_getButtonCount (unsigned int joystick)
| Return the number of buttons supported by a joystick. More...
CSFML_WINDOW_API sfBool | sfJoystick_hasAxis (unsigned int joystick, sfJoystickAxis axis)
| Check if a joystick supports a given axis. More...
CSFML_WINDOW_API sfBool | sfJoystick_isButtonPressed (unsigned int joystick, unsigned int button)
| Check if a joystick button is pressed. More...
CSFML_WINDOW_API float | sfJoystick_getAxisPosition (unsigned int joystick, sfJoystickAxis axis)
| Get the current position of a joystick axis. More...
CSFML_WINDOW_API void | sfJoystick_update (void)
| Update the states of all joysticks. More...

## Enumeration Type Documentation

anonymous enum

Global joysticks capabilities.

Enumerator
sfJoystickCount | Maximum number of supported joysticks.
sfJoystickButtonCount | Maximum number of supported buttons.
sfJoystickAxisCount | Maximum number of supported axes.

Definition at line 37 of file Joystick.h.

enum sfJoystickAxis

Axes supported by SFML joysticks.

Enumerator
sfJoystickX | The X axis.
sfJoystickY | The Y axis.
sfJoystickZ | The Z axis.
sfJoystickR | The R axis.
sfJoystickU | The U axis.
sfJoystickV | The V axis.
sfJoystickPovX | The X axis of the point-of-view hat.
sfJoystickPovY | The Y axis of the point-of-view hat.

Definition at line 49 of file Joystick.h.

## Function Documentation

CSFML_WINDOW_API float sfJoystick_getAxisPosition | ( | unsigned int | joystick,
|  | sfJoystickAxis | axis
| ) |  |

Get the current position of a joystick axis.

If the joystick is not connected, this function returns 0.

Parameters

  joystick | Index of the joystick
  axis | Axis to check

Returns
  Current position of the axis, in range [-100 .. 100]

CSFML_WINDOW_API unsigned int sfJoystick_getButtonCount | ( | unsigned int | joystick) |  |

Return the number of buttons supported by a joystick.

If the joystick is not connected, this function returns 0.

Parameters

  joystick | Index of the joystick

Returns
  Number of buttons supported by the joystick

CSFML_WINDOW_API sfBool sfJoystick_hasAxis | ( | unsigned int | joystick,
|  | sfJoystickAxis | axis
| ) |  |

Check if a joystick supports a given axis.

If the joystick is not connected, this function returns false.

Parameters

  joystick | Index of the joystick
  axis | Axis to check

Returns
  sfTrue if the joystick supports the axis, sfFalse otherwise

CSFML_WINDOW_API sfBool sfJoystick_isButtonPressed | ( | unsigned int | joystick,
|  | unsigned int | button
| ) |  |

Check if a joystick button is pressed.

If the joystick is not connected, this function returns false.

Parameters

  joystick | Index of the joystick
  button | Button to check

Returns
  sfTrue if the button is pressed, sfFalse otherwise

CSFML_WINDOW_API sfBool sfJoystick_isConnected | ( | unsigned int | joystick) |  |

Check if a joystick is connected.

Parameters

  joystick | Index of the joystick to check

Returns
  sfTrue if the joystick is connected, sfFalse otherwise

CSFML_WINDOW_API void sfJoystick_update | ( | void | ) |  |

Update the states of all joysticks.

This function is used internally by SFML, so you normally don't have to call it explicitely. However, you may need to call it if you have no window yet (or no window at all): in this case the joysticks states are not updated automatically.