CSFML - C binding of the Simple and Fast Multimedia Library

CSFML 2.6.1

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Enumerations | Functions
Joystick.h File Reference
`#include <SFML/Window/Export.h>`
`#include <SFML/Window/JoystickIdentification.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
sfBool | sfJoystick_isConnected (unsigned int joystick)
| Check if a joystick is connected.
unsigned int | sfJoystick_getButtonCount (unsigned int joystick)
| Return the number of buttons supported by a joystick.
sfBool | sfJoystick_hasAxis (unsigned int joystick, sfJoystickAxis axis)
| Check if a joystick supports a given axis.
sfBool | sfJoystick_isButtonPressed (unsigned int joystick, unsigned int button)
| Check if a joystick button is pressed.
float | sfJoystick_getAxisPosition (unsigned int joystick, sfJoystickAxis axis)
| Get the current position of a joystick axis.
sfJoystickIdentification | sfJoystick_getIdentification (unsigned int joystick)
| Get the joystick information.
void | sfJoystick_update (void)
| Update the states of all joysticks.

## Enumeration Type Documentation

## ◆ anonymous enum

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 39 of file Joystick.h.

## ◆ sfJoystickAxis

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 51 of file Joystick.h.

## Function Documentation

## ◆ sfJoystick_getAxisPosition()

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]

## ◆ sfJoystick_getButtonCount()

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

## ◆ sfJoystick_getIdentification()

sfJoystickIdentification sfJoystick_getIdentification | ( | unsigned int | joystick | ) |

Get the joystick information.

The result of this function will only remain valid until the next time the function is called.

Parameters

  joystick | Index of the joystick

Returns
  Structure containing joystick information.

## ◆ sfJoystick_hasAxis()

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

## ◆ sfJoystick_isButtonPressed()

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

## ◆ sfJoystick_isConnected()

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

## ◆ sfJoystick_update()

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.