THIS PAGE IS A WORK IN PROGRESS ... Please make edits to this page to improve it!
Structure that represents a haptic direction.
Defined in [SDL_haptic.h](https://github.com/libsdl-org/SDL/blob/SDL2/include/SDL_haptic.h), but apps should _only_ `#include "SDL.h"`!
typedef struct SDL_HapticDirection
{/**< The type of encoding. */
Uint8 type; 3]; /**< The encoded direction. */
Sint32 dir[ } SDL_HapticDirection;
This is the direction where the force comes from, instead of the direction in which the force is exerted.
Directions can be specified by: ::SDL_HAPTIC_POLAR : Specified by polar coordinates. ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. * ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates.
Cardinal directions of the haptic device are relative to the positioning of the device. North is considered to be away from the user.
The following diagram represents the cardinal directions:
Example of force coming from the south with all encodings (force coming from the south means the user will have to pull the stick to counteract):
SDL_HapticDirection direction;
// Cartesian directions
// Using cartesian direction encoding.
direction.type = SDL_HAPTIC_CARTESIAN; 0] = 0; // X position
direction.dir[1] = 1; // Y position
direction.dir[// Assuming the device has 2 axes, we don't need to specify third parameter.
// Polar directions
// We'll be using polar direction encoding.
direction.type = SDL_HAPTIC_POLAR; 0] = 18000; // Polar only uses first parameter
direction.dir[
// Spherical coordinates
// Spherical encoding
direction.type = SDL_HAPTIC_SPHERICAL; 0] = 9000; // Since we only have two axes we don't need more parameters. direction.dir[
Uint8 |
type |
the type of encoding; see Remarks for details |
Sint32 |
dir |
the encoded direction; see Remarks for details |
CategoryAPI, CategoryAPIStruct, CategoryStruct, CategoryForceFeedback, CategoryDraft