SDL_GetHaptics() follows the SDL_GetStringRule
This commit is contained in:
parent
9de8cb888a
commit
b32c9615a7
@ -695,7 +695,7 @@ Rather than iterating over haptic devices using device index, there is a new fun
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0) {
|
||||
int i, num_haptics;
|
||||
SDL_HapticID *haptics = SDL_GetHaptics(&num_haptics);
|
||||
const SDL_HapticID *haptics = SDL_GetHaptics(&num_haptics);
|
||||
if (haptics) {
|
||||
for (i = 0; i < num_haptics; ++i) {
|
||||
SDL_HapticID instance_id = haptics[i];
|
||||
@ -704,7 +704,6 @@ Rather than iterating over haptic devices using device index, there is a new fun
|
||||
SDL_Log("Haptic %" SDL_PRIu32 ": %s\n",
|
||||
instance_id, name ? name : "Unknown");
|
||||
}
|
||||
SDL_free(haptics);
|
||||
}
|
||||
SDL_QuitSubSystem(SDL_INIT_HAPTIC);
|
||||
}
|
||||
|
@ -45,7 +45,6 @@
|
||||
* SDL_HapticID *haptics = SDL_GetHaptics(NULL);
|
||||
* if (haptics) {
|
||||
* haptic = SDL_OpenHaptic(haptics[0]);
|
||||
* SDL_free(haptics);
|
||||
* }
|
||||
* if (haptic == NULL)
|
||||
* return -1;
|
||||
@ -932,17 +931,18 @@ typedef Uint32 SDL_HapticID;
|
||||
/**
|
||||
* Get a list of currently connected haptic devices.
|
||||
*
|
||||
* The returned array follows the SDL_GetStringRule, and will be automatically freed later.
|
||||
*
|
||||
* \param count a pointer filled in with the number of haptic devices
|
||||
* returned.
|
||||
* \returns a 0 terminated array of haptic device instance IDs which should be
|
||||
* freed with SDL_free(), or NULL on failure; call SDL_GetError() for
|
||||
* returned, may be NULL.
|
||||
* \returns a 0 terminated array of haptic device instance IDs or NULL on failure; call SDL_GetError() for
|
||||
* more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_OpenHaptic
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_HapticID * SDLCALL SDL_GetHaptics(int *count);
|
||||
extern SDL_DECLSPEC const SDL_HapticID * SDLCALL SDL_GetHaptics(int *count);
|
||||
|
||||
/**
|
||||
* Get the implementation dependent name of a haptic device.
|
||||
|
@ -327,7 +327,7 @@ SDL_DYNAPI_PROC(SDL_Haptic*,SDL_GetHapticFromID,(SDL_HapticID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_HapticID,SDL_GetHapticID,(SDL_Haptic *a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetHapticName,(SDL_Haptic *a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetHapticNameForID,(SDL_HapticID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_HapticID*,SDL_GetHaptics,(int *a),(a),return)
|
||||
SDL_DYNAPI_PROC(const SDL_HapticID*,SDL_GetHaptics,(int *a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetHint,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetIOProperties,(SDL_IOStream *a),(a),return)
|
||||
|
@ -63,7 +63,7 @@ static SDL_bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_HapticID *SDL_GetHaptics(int *count)
|
||||
const SDL_HapticID *SDL_GetHaptics(int *count)
|
||||
{
|
||||
int device_index;
|
||||
int haptic_index = 0, num_haptics = 0;
|
||||
@ -89,7 +89,7 @@ SDL_HapticID *SDL_GetHaptics(int *count)
|
||||
}
|
||||
}
|
||||
|
||||
return haptics;
|
||||
return SDL_FreeLater(haptics);
|
||||
}
|
||||
|
||||
const char *SDL_GetHapticNameForID(SDL_HapticID instance_id)
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char **argv)
|
||||
int id[9];
|
||||
int nefx;
|
||||
unsigned int supported;
|
||||
SDL_HapticID *haptics;
|
||||
const SDL_HapticID *haptics;
|
||||
int num_haptics;
|
||||
|
||||
/* Initialize test framework */
|
||||
@ -91,7 +91,6 @@ int main(int argc, char **argv)
|
||||
if (haptics) {
|
||||
if (num_haptics == 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -101,7 +100,6 @@ int main(int argc, char **argv)
|
||||
|
||||
if (i >= num_haptics) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index out of range, aborting.\n");
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -115,7 +113,6 @@ int main(int argc, char **argv)
|
||||
|
||||
if (i >= num_haptics) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name);
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -123,12 +120,10 @@ int main(int argc, char **argv)
|
||||
haptic = SDL_OpenHaptic(haptics[i]);
|
||||
if (!haptic) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError());
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
SDL_Log("Device: %s\n", SDL_GetHapticName(haptic));
|
||||
HapticPrintSupported(haptic);
|
||||
SDL_free(haptics);
|
||||
}
|
||||
|
||||
/* We only want force feedback errors. */
|
||||
|
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (enable_haptic) {
|
||||
int num_haptics;
|
||||
SDL_free(SDL_GetHaptics(&num_haptics));
|
||||
SDL_GetHaptics(&num_haptics);
|
||||
SDL_Log("There are %d haptic devices at startup\n", num_haptics);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ int main(int argc, char **argv)
|
||||
char *name = NULL;
|
||||
int index;
|
||||
SDLTest_CommonState *state;
|
||||
SDL_HapticID *haptics;
|
||||
const SDL_HapticID *haptics;
|
||||
int num_haptics;
|
||||
|
||||
/* Initialize test framework */
|
||||
@ -92,7 +92,6 @@ int main(int argc, char **argv)
|
||||
if (haptics) {
|
||||
if (num_haptics == 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -102,7 +101,6 @@ int main(int argc, char **argv)
|
||||
|
||||
if (i >= num_haptics) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index out of range, aborting.\n");
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -116,7 +114,6 @@ int main(int argc, char **argv)
|
||||
|
||||
if (i >= num_haptics) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name);
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -124,11 +121,9 @@ int main(int argc, char **argv)
|
||||
haptic = SDL_OpenHaptic(haptics[i]);
|
||||
if (!haptic) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError());
|
||||
SDL_free(haptics);
|
||||
return 1;
|
||||
}
|
||||
SDL_Log("Device: %s\n", SDL_GetHapticName(haptic));
|
||||
SDL_free(haptics);
|
||||
}
|
||||
|
||||
/* We only want force feedback errors. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user