Use C++ style comments consistently in SDL source code

Implemented using this script:

find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
    core/linux/SDL_evdev_kbd_default_keymap.h \
    events/imKStoUCS.* \
    hidapi \
    joystick/controller_type.c \
    joystick/controller_type.h \
    joystick/hidapi/steam/controller_constants.h \
    joystick/hidapi/steam/controller_structs.h \
    joystick/SDL_gamepad_db.h \
    libm \
    render/*/*Shader*.h \
    render/vitagxm/SDL_render_vita_gxm_shaders.h \
    render/metal/SDL_shaders_metal_*.h \
    stdlib/SDL_malloc.c \
    stdlib/SDL_qsort.c \
    stdlib/SDL_strtokr.c \
    test/ \
    video/directx/SDL_d3d12_xbox_cmacros.h \
    video/directx/d3d12.h \
    video/directx/d3d12sdklayers.h \
    video/khronos \
    video/x11/edid-parse.c \
    video/x11/xsettings-client.* \
    video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
Sam Lantinga
2024-08-22 10:30:45 -07:00
parent 658fc3db0f
commit 6501e90018
743 changed files with 11882 additions and 11882 deletions

View File

@@ -23,8 +23,8 @@
#ifdef SDL_HAPTIC_IOKIT
#include "../SDL_syshaptic.h"
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
#include "../../joystick/darwin/SDL_iokitjoystick_c.h" /* For joystick hwdata */
#include "../../joystick/SDL_sysjoystick.h" // For the real SDL_Joystick
#include "../../joystick/darwin/SDL_iokitjoystick_c.h" // For joystick hwdata
#include "SDL_syshaptic_c.h"
#include <IOKit/IOKitLib.h>
@@ -43,12 +43,12 @@
typedef struct SDL_hapticlist_item
{
SDL_HapticID instance_id;
char name[256]; /* Name of the device. */
char name[256]; // Name of the device.
io_service_t dev; /* Node we use to create the device. */
SDL_Haptic *haptic; /* Haptic currently associated with it. */
io_service_t dev; // Node we use to create the device.
SDL_Haptic *haptic; // Haptic currently associated with it.
/* Usage pages for determining if it's a mouse or not. */
// Usage pages for determining if it's a mouse or not.
long usage;
long usagePage;
@@ -60,7 +60,7 @@ typedef struct SDL_hapticlist_item
*/
struct haptic_hwdata
{
FFDeviceObjectReference device; /* Hardware device. */
FFDeviceObjectReference device; // Hardware device.
UInt8 axes[3];
};
@@ -69,8 +69,8 @@ struct haptic_hwdata
*/
struct haptic_hweffect
{
FFEffectObjectReference ref; /* Reference. */
struct FFEFFECT effect; /* Hardware effect. */
FFEffectObjectReference ref; // Reference.
struct FFEFFECT effect; // Hardware effect.
};
/*
@@ -91,7 +91,7 @@ static const char *FFStrError(unsigned int err)
switch (err) {
case FFERR_DEVICEFULL:
return "device full";
/* This should be valid, but for some reason isn't defined... */
// This should be valid, but for some reason isn't defined...
/* case FFERR_DEVICENOTREG:
return "device not registered"; */
case FFERR_DEVICEPAUSED:
@@ -153,26 +153,26 @@ int SDL_SYS_HapticInit(void)
}
numhaptics = 0;
/* Get HID devices. */
// Get HID devices.
match = IOServiceMatching(kIOHIDDeviceKey);
if (!match) {
return SDL_SetError("Haptic: Failed to get IOServiceMatching.");
}
/* Now search I/O Registry for matching devices. */
// Now search I/O Registry for matching devices.
result = IOServiceGetMatchingServices(kIOMainPortDefault, match, &iter);
if (result != kIOReturnSuccess) {
return SDL_SetError("Haptic: Couldn't create a HID object iterator.");
}
/* IOServiceGetMatchingServices consumes dictionary. */
// IOServiceGetMatchingServices consumes dictionary.
if (!IOIteratorIsValid(iter)) { /* No iterator. */
if (!IOIteratorIsValid(iter)) { // No iterator.
return 0;
}
while ((device = IOIteratorNext(iter)) != IO_OBJECT_NULL) {
MacHaptic_MaybeAddDevice(device);
/* always release as the AddDevice will retain IF it's a forcefeedback device */
// always release as the AddDevice will retain IF it's a forcefeedback device
IOObjectRelease(device);
}
IOObjectRelease(iter);
@@ -221,18 +221,18 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
SDL_hapticlist_item *item;
if (numhaptics == -1) {
return -1; /* not initialized. We'll pick these up on enumeration if we init later. */
return -1; // not initialized. We'll pick these up on enumeration if we init later.
}
/* Check for force feedback. */
// Check for force feedback.
if (FFIsForceFeedback(device) != FF_OK) {
return -1;
}
/* Make sure we don't already have it */
// Make sure we don't already have it
for (item = SDL_hapticlist; item; item = item->next) {
if (IOObjectIsEqualTo((io_object_t)item->dev, device)) {
/* Already added */
// Already added
return -1;
}
}
@@ -243,14 +243,14 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
}
item->instance_id = SDL_GetNextObjectID();
/* retain it as we are going to keep it around a while */
// retain it as we are going to keep it around a while
IOObjectRetain(device);
/* Set basic device data. */
// Set basic device data.
HIDGetDeviceProduct(device, item->name);
item->dev = device;
/* Set usage pages. */
// Set usage pages.
hidProperties = 0;
refCF = 0;
result = IORegistryEntryCreateCFProperties(device,
@@ -282,7 +282,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
SDL_hapticlist_tail = item;
}
/* Device has been added. */
// Device has been added.
++numhaptics;
return numhaptics;
@@ -294,11 +294,11 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device)
SDL_hapticlist_item *prev = NULL;
if (numhaptics == -1) {
return -1; /* not initialized. ignore this. */
return -1; // not initialized. ignore this.
}
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
// found it, remove it.
if (IOObjectIsEqualTo((io_object_t)item->dev, device)) {
const int retval = item->haptic ? 0 : -1;
@@ -312,9 +312,9 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device)
SDL_hapticlist_tail = prev;
}
/* Need to decrement the haptic count */
// Need to decrement the haptic count
--numhaptics;
/* !!! TODO: Send a haptic remove event? */
// !!! TODO: Send a haptic remove event?
IOObjectRelease(item->dev);
SDL_free(item);
@@ -383,7 +383,7 @@ static int HIDGetDeviceProduct(io_service_t dev, char *name)
* try hid dictionary first, if fail then go to USB dictionary
*/
/* Get product name */
// Get product name
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
if (!refCF) {
refCF = CFDictionaryGetValue(usbProperties,
@@ -401,7 +401,7 @@ static int HIDGetDeviceProduct(io_service_t dev, char *name)
return SDL_SetError("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties.");
}
/* Release stuff. */
// Release stuff.
if (kIOReturnSuccess != IOObjectRelease(parent2)) {
SDL_SetError("Haptic: IOObjectRelease error with parent2.");
}
@@ -438,11 +438,11 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic)
supported = 0;
/* Get maximum effects. */
// Get maximum effects.
haptic->neffects = features.storageCapacity;
haptic->nplaying = features.playbackCapacity;
/* Test for effects. */
// Test for effects.
FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT);
FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP);
FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE);
@@ -456,7 +456,7 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic)
FF_TEST(FFCAP_ET_FRICTION, SDL_HAPTIC_FRICTION);
FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM);
/* Check if supports gain. */
// Check if supports gain.
ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN,
&val, sizeof(val));
if (ret == FF_OK) {
@@ -466,7 +466,7 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic)
FFStrError(ret));
}
/* Checks if supports autocenter. */
// Checks if supports autocenter.
ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER,
&val, sizeof(val));
if (ret == FF_OK) {
@@ -476,13 +476,13 @@ static unsigned int GetSupportedFeatures(SDL_Haptic *haptic)
FFStrError(ret));
}
/* Check for axes, we have an artificial limit on axes */
// Check for axes, we have an artificial limit on axes
haptic->naxes = ((features.numFfAxes) > 3) ? 3 : features.numFfAxes;
/* Actually store the axes we want to use */
// Actually store the axes we want to use
SDL_memcpy(haptic->hwdata->axes, features.ffAxes,
haptic->naxes * sizeof(Uint8));
/* Always supported features. */
// Always supported features.
supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE;
haptic->supported = supported;
@@ -497,26 +497,26 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
HRESULT ret;
int ret2;
/* Allocate the hwdata */
// Allocate the hwdata
haptic->hwdata = (struct haptic_hwdata *) SDL_calloc(1, sizeof(*haptic->hwdata));
if (!haptic->hwdata) {
goto creat_err;
}
/* Open the device */
// Open the device
ret = FFCreateDevice(service, &haptic->hwdata->device);
if (ret != FF_OK) {
SDL_SetError("Haptic: Unable to create device from service: %s.", FFStrError(ret));
goto creat_err;
}
/* Get supported features. */
// Get supported features.
ret2 = GetSupportedFeatures(haptic);
if (ret2 < 0) {
goto open_err;
}
/* Reset and then enable actuators. */
// Reset and then enable actuators.
ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device,
FFSFFC_RESET);
if (ret != FF_OK) {
@@ -531,19 +531,19 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
goto open_err;
}
/* Allocate effects memory. */
// Allocate effects memory.
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (!haptic->effects) {
goto open_err;
}
/* Clear the memory */
// Clear the memory
SDL_memset(haptic->effects, 0,
sizeof(struct haptic_effect) * haptic->neffects);
return 0;
/* Error handling */
// Error handling
open_err:
FFReleaseDevice(haptic->hwdata->device);
creat_err:
@@ -653,15 +653,15 @@ void SDL_SYS_HapticClose(SDL_Haptic *haptic)
{
if (haptic->hwdata) {
/* Free Effects. */
// Free Effects.
SDL_free(haptic->effects);
haptic->effects = NULL;
haptic->neffects = 0;
/* Clean up */
// Clean up
FFReleaseDevice(haptic->hwdata->device);
/* Free */
// Free
SDL_free(haptic->hwdata);
haptic->hwdata = NULL;
}
@@ -680,7 +680,7 @@ void SDL_SYS_HapticQuit(void)
/* Opened and not closed haptics are leaked, this is on purpose.
* Close your haptic devices after usage. */
/* Free the io_service_t */
// Free the io_service_t
IOObjectRelease(item->dev);
SDL_free(item);
}
@@ -713,14 +713,14 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, const SDL_HapticDirection *dir
{
LONG *rglDir;
/* Handle no axes a part. */
// Handle no axes a part.
if (naxes == 0) {
effect->dwFlags |= FFEFF_SPHERICAL; /* Set as default. */
effect->dwFlags |= FFEFF_SPHERICAL; // Set as default.
effect->rglDirection = NULL;
return 0;
}
/* Has axes. */
// Has axes.
rglDir = SDL_malloc(sizeof(LONG) * naxes);
if (!rglDir) {
return -1;
@@ -763,9 +763,9 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, const SDL_HapticDirection *dir
}
}
/* Clamps and converts. */
// Clamps and converts.
#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
/* Just converts. */
// Just converts.
#define CONVERT(x) (((x)*10000) / 0x7FFF)
/*
* Creates the FFEFFECT from a SDL_HapticEffect.
@@ -775,7 +775,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
int i;
FFCONSTANTFORCE *constant = NULL;
FFPERIODIC *periodic = NULL;
FFCONDITION *condition = NULL; /* Actually an array of conditions - one per axis. */
FFCONDITION *condition = NULL; // Actually an array of conditions - one per axis.
FFRAMPFORCE *ramp = NULL;
FFCUSTOMFORCE *custom = NULL;
FFENVELOPE *envelope = NULL;
@@ -786,22 +786,22 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
const SDL_HapticCustom *hap_custom = NULL;
DWORD *axes = NULL;
/* Set global stuff. */
// Set global stuff.
SDL_memset(dest, 0, sizeof(FFEFFECT));
dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */
dest->dwSamplePeriod = 0; /* Not used by us. */
dest->dwGain = 10000; /* Gain is set globally, not locally. */
dest->dwFlags = FFEFF_OBJECTOFFSETS; /* Seems obligatory. */
dest->dwSize = sizeof(FFEFFECT); // Set the structure size.
dest->dwSamplePeriod = 0; // Not used by us.
dest->dwGain = 10000; // Gain is set globally, not locally.
dest->dwFlags = FFEFF_OBJECTOFFSETS; // Seems obligatory.
/* Envelope. */
// Envelope.
envelope = SDL_calloc(1, sizeof(FFENVELOPE));
if (!envelope) {
return -1;
}
dest->lpEnvelope = envelope;
envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
envelope->dwSize = sizeof(FFENVELOPE); // Always should be this.
/* Axes. */
// Axes.
if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) {
dest->cAxes = 1;
} else {
@@ -812,7 +812,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
if (!axes) {
return -1;
}
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
axes[0] = haptic->hwdata->axes[0]; // Always at least one axis.
if (dest->cAxes > 1) {
axes[1] = haptic->hwdata->axes[1];
}
@@ -822,7 +822,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
dest->rgdwAxes = axes;
}
/* The big type handling switch, even bigger then Linux's version. */
// The big type handling switch, even bigger then Linux's version.
switch (src->type) {
case SDL_HAPTIC_CONSTANT:
hap_constant = &src->constant;
@@ -831,23 +831,23 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
return -1;
}
/* Specifics */
// Specifics
constant->lMagnitude = CONVERT(hap_constant->level);
dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE);
dest->lpvTypeSpecificParams = constant;
/* Generics */
dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
// Generics
dest->dwDuration = hap_constant->length * 1000; // In microseconds.
dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button);
dest->dwTriggerRepeatInterval = hap_constant->interval;
dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_constant->delay * 1000; // In microseconds.
/* Direction. */
// Direction.
if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
return -1;
}
/* Envelope */
// Envelope
if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) {
SDL_free(envelope);
dest->lpEnvelope = NULL;
@@ -871,7 +871,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
return -1;
}
/* Specifics */
// Specifics
periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
periodic->lOffset = CONVERT(hap_periodic->offset);
periodic->dwPhase =
@@ -880,18 +880,18 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
dest->lpvTypeSpecificParams = periodic;
/* Generics */
dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
// Generics
dest->dwDuration = hap_periodic->length * 1000; // In microseconds.
dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button);
dest->dwTriggerRepeatInterval = hap_periodic->interval;
dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_periodic->delay * 1000; // In microseconds.
/* Direction. */
// Direction.
if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
return -1;
}
/* Envelope */
// Envelope
if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) {
SDL_free(envelope);
dest->lpEnvelope = NULL;
@@ -915,7 +915,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
return -1;
}
/* Specifics */
// Specifics
for (i = 0; i < dest->cAxes; i++) {
condition[i].lOffset = CONVERT(hap_condition->center[i]);
condition[i].lPositiveCoefficient =
@@ -933,18 +933,18 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
dest->lpvTypeSpecificParams = condition;
/* Generics */
dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
// Generics
dest->dwDuration = hap_condition->length * 1000; // In microseconds.
dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button);
dest->dwTriggerRepeatInterval = hap_condition->interval;
dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_condition->delay * 1000; // In microseconds.
/* Direction. */
// Direction.
if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
return -1;
}
/* Envelope - Not actually supported by most CONDITION implementations. */
// Envelope - Not actually supported by most CONDITION implementations.
SDL_free(dest->lpEnvelope);
dest->lpEnvelope = NULL;
@@ -957,24 +957,24 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
return -1;
}
/* Specifics */
// Specifics
ramp->lStart = CONVERT(hap_ramp->start);
ramp->lEnd = CONVERT(hap_ramp->end);
dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE);
dest->lpvTypeSpecificParams = ramp;
/* Generics */
dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
// Generics
dest->dwDuration = hap_ramp->length * 1000; // In microseconds.
dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button);
dest->dwTriggerRepeatInterval = hap_ramp->interval;
dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_ramp->delay * 1000; // In microseconds.
/* Direction. */
// Direction.
if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
return -1;
}
/* Envelope */
// Envelope
if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) {
SDL_free(envelope);
dest->lpEnvelope = NULL;
@@ -994,31 +994,31 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, const SDL_Hapt
return -1;
}
/* Specifics */
// Specifics
custom->cChannels = hap_custom->channels;
custom->dwSamplePeriod = hap_custom->period * 1000;
custom->cSamples = hap_custom->samples;
custom->rglForceData =
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */
for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { // Copy data.
custom->rglForceData[i] = CCONVERT(hap_custom->data[i]);
}
dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE);
dest->lpvTypeSpecificParams = custom;
/* Generics */
dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
// Generics
dest->dwDuration = hap_custom->length * 1000; // In microseconds.
dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button);
dest->dwTriggerRepeatInterval = hap_custom->interval;
dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
dest->dwStartDelay = hap_custom->delay * 1000; // In microseconds.
/* Direction. */
// Direction.
if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) <
0) {
return -1;
}
/* Envelope */
// Envelope
if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) {
SDL_free(envelope);
dest->lpEnvelope = NULL;
@@ -1050,7 +1050,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type)
SDL_free(effect->rgdwAxes);
effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
if (type == SDL_HAPTIC_CUSTOM) { // Must free the custom data.
custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams;
SDL_free(custom->rglForceData);
custom->rglForceData = NULL;
@@ -1120,25 +1120,25 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
HRESULT ret;
CFUUIDRef type;
/* Alloc the effect. */
// Alloc the effect.
effect->hweffect = (struct haptic_hweffect *)
SDL_calloc(1, sizeof(struct haptic_hweffect));
if (!effect->hweffect) {
goto err_hweffect;
}
/* Get the type. */
// Get the type.
type = SDL_SYS_HapticEffectType(base->type);
if (!type) {
goto err_hweffect;
}
/* Get the effect. */
// Get the effect.
if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
goto err_effectdone;
}
/* Create the actual effect. */
// Create the actual effect.
ret = FFDeviceCreateEffect(haptic->hwdata->device, type,
&effect->hweffect->effect,
&effect->hweffect->ref);
@@ -1168,7 +1168,7 @@ int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,
FFEffectParameterFlag flags;
FFEFFECT temp;
/* Get the effect. */
// Get the effect.
SDL_memset(&temp, 0, sizeof(FFEFFECT));
if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) {
goto err_update;
@@ -1183,14 +1183,14 @@ int SDL_SYS_HapticUpdateEffect(SDL_Haptic *haptic,
FFEP_TRIGGERBUTTON |
FFEP_TRIGGERREPEATINTERVAL | FFEP_TYPESPECIFICPARAMS;
/* Create the actual effect. */
// Create the actual effect.
ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags);
if (ret != FF_OK) {
SDL_SetError("Haptic: Unable to update effect: %s.", FFStrError(ret));
goto err_update;
}
/* Copy it over. */
// Copy it over.
SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type);
SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT));
@@ -1210,14 +1210,14 @@ int SDL_SYS_HapticRunEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
HRESULT ret;
Uint32 iter;
/* Check if it's infinite. */
// Check if it's infinite.
if (iterations == SDL_HAPTIC_INFINITY) {
iter = FF_INFINITE;
} else {
iter = iterations;
}
/* Run the effect. */
// Run the effect.
ret = FFEffectStart(effect->hweffect->ref, iter, 0);
if (ret != FF_OK) {
return SDL_SetError("Haptic: Unable to run the effect: %s.",
@@ -1279,7 +1279,7 @@ int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic,
if (status == 0) {
return SDL_FALSE;
}
return SDL_TRUE; /* Assume it's playing or emulated. */
return SDL_TRUE; // Assume it's playing or emulated.
}
/*
@@ -1290,7 +1290,7 @@ int SDL_SYS_HapticSetGain(SDL_Haptic *haptic, int gain)
HRESULT ret;
Uint32 val;
val = gain * 100; /* macOS uses 0 to 10,000 */
val = gain * 100; // macOS uses 0 to 10,000
ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
FFPROP_FFGAIN, &val);
if (ret != FF_OK) {
@@ -1308,7 +1308,7 @@ int SDL_SYS_HapticSetAutocenter(SDL_Haptic *haptic, int autocenter)
HRESULT ret;
Uint32 val;
/* macOS only has 0 (off) and 1 (on) */
// macOS only has 0 (off) and 1 (on)
if (autocenter == 0) {
val = 0;
} else {
@@ -1373,4 +1373,4 @@ int SDL_SYS_HapticStopAll(SDL_Haptic *haptic)
return 0;
}
#endif /* SDL_HAPTIC_IOKIT */
#endif // SDL_HAPTIC_IOKIT