This repository has been archived by the owner. It is now read-only.
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Added SDL_HapticIndex.
- Loading branch information
Showing
with
46 additions
and
18 deletions.
-
+14
−0
include/SDL_haptic.h
-
+32
−18
src/haptic/SDL_haptic.c
|
@@ -636,11 +636,25 @@ extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); |
|
|
* \param device_index Index of the device to open. |
|
|
* \return Device identifier or NULL on error. |
|
|
* |
|
|
* \sa SDL_HapticIndex |
|
|
* \sa SDL_HapticOpenFromJoystick |
|
|
* \sa SDL_HapticClose |
|
|
*/ |
|
|
extern DECLSPEC SDL_Haptic * SDL_HapticOpen(int device_index); |
|
|
|
|
|
|
|
|
/** |
|
|
* \fn int SDL_HapticIndex(SDL_Haptic * haptic) |
|
|
* |
|
|
* \brief Gets the index of a haptic device. |
|
|
* |
|
|
* \param haptic Haptic device to get the index of. |
|
|
* \return The index of the haptic device or -1 on error. |
|
|
* |
|
|
* \sa SDL_HapticOpen |
|
|
*/ |
|
|
extern DECLSPEC int SDL_HapticIndex(SDL_Haptic * haptic); |
|
|
|
|
|
/** |
|
|
* \fn int SDL_JoystickIsHaptic(SDL_Joystick * joystick) |
|
|
* |
|
|
|
@@ -58,6 +58,24 @@ SDL_HapticInit(void) |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Checks to see if the haptic device is valid |
|
|
*/ |
|
|
static int |
|
|
ValidHaptic(SDL_Haptic ** haptic) |
|
|
{ |
|
|
int valid; |
|
|
|
|
|
if (*haptic == NULL) { |
|
|
SDL_SetError("Haptic device hasn't been opened yet"); |
|
|
valid = 0; |
|
|
} else { |
|
|
valid = 1; |
|
|
} |
|
|
return valid; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Returns the number of available devices. |
|
|
*/ |
|
@@ -130,6 +148,20 @@ SDL_HapticOpen(int device_index) |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Returns the index to a haptic device. |
|
|
*/ |
|
|
int |
|
|
SDL_HapticIndex(SDL_Haptic * haptic) |
|
|
{ |
|
|
if (!ValidHaptic(&haptic)) { |
|
|
return -1; |
|
|
} |
|
|
|
|
|
return haptic->index; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Returns SDL_TRUE if joystick has haptic features. |
|
|
*/ |
|
@@ -203,24 +235,6 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Checks to see if the haptic device is valid |
|
|
*/ |
|
|
static int |
|
|
ValidHaptic(SDL_Haptic ** haptic) |
|
|
{ |
|
|
int valid; |
|
|
|
|
|
if (*haptic == NULL) { |
|
|
SDL_SetError("Haptic device hasn't been opened yet"); |
|
|
valid = 0; |
|
|
} else { |
|
|
valid = 1; |
|
|
} |
|
|
return valid; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Closes a SDL_Haptic device. |
|
|
*/ |
|
|
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.