File style cleanup for the SDL 2.0 release

This commit is contained in:
Sam Lantinga 2013-05-18 14:17:52 -07:00
parent 2ac8624930
commit 0cb6385637
376 changed files with 17562 additions and 17773 deletions

View file

@ -56,7 +56,7 @@ struct _SDL_Haptic
SDL_HapticEffect rumble_effect; /* Rumble effect. */
};
/*
/*
* Scans the system for haptic devices.
*
* Returns 0 on success, -1 on error.

View file

@ -35,7 +35,7 @@
#include <ForceFeedback/ForceFeedbackConstants.h>
#ifndef IO_OBJECT_NULL
#define IO_OBJECT_NULL ((io_service_t)0)
#define IO_OBJECT_NULL ((io_service_t)0)
#endif
#define MAX_HAPTICS 32
@ -83,7 +83,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type);
static int HIDGetDeviceProduct(io_service_t dev, char *name);
/*
/*
* Like strerror but for force feedback errors.
*/
static const char *
@ -562,7 +562,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
}
/*
/*
* Clean up after system specific haptic stuff
*/
void

View file

@ -155,7 +155,7 @@ SDL_SYS_HapticInit(void)
numhaptics = 0;
/*
/*
* Limit amount of checks to MAX_HAPTICS since we may or may not have
* permission to some or all devices.
*/
@ -446,7 +446,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
}
/*
/*
* Clean up after system specific haptic stuff
*/
void
@ -498,44 +498,44 @@ SDL_SYS_ToDirection(SDL_HapticDirection * dir)
switch (dir->type) {
case SDL_HAPTIC_POLAR:
/* Linux directions start from south.
(and range from 0 to 0xFFFF)
Quoting include/linux/input.h, line 926:
Direction of the effect is encoded as follows:
0 deg -> 0x0000 (down)
90 deg -> 0x4000 (left)
180 deg -> 0x8000 (up)
270 deg -> 0xC000 (right)
*/
tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; // convert to range [0,0xFFFF]
(and range from 0 to 0xFFFF)
Quoting include/linux/input.h, line 926:
Direction of the effect is encoded as follows:
0 deg -> 0x0000 (down)
90 deg -> 0x4000 (left)
180 deg -> 0x8000 (up)
270 deg -> 0xC000 (right)
*/
tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */
return (Uint16) tmp;
case SDL_HAPTIC_SPHERICAL:
/*
We convert to polar, because that's the only supported direction on Linux.
The first value of a spherical direction is practically the same as a
Polar direction, except that we have to add 90 degrees. It is the angle
from EAST {1,0} towards SOUTH {0,1}.
--> add 9000
--> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
*/
tmp = ((dir->dir[0]) + 9000) % 36000; /* Convert to polars */
tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; // convert to range [0,0xFFFF]
case SDL_HAPTIC_SPHERICAL:
/*
We convert to polar, because that's the only supported direction on Linux.
The first value of a spherical direction is practically the same as a
Polar direction, except that we have to add 90 degrees. It is the angle
from EAST {1,0} towards SOUTH {0,1}.
--> add 9000
--> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
*/
tmp = ((dir->dir[0]) + 9000) % 36000; /* Convert to polars */
tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */
return (Uint16) tmp;
case SDL_HAPTIC_CARTESIAN:
f = atan2(dir->dir[1], dir->dir[0]);
/*
atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
- Y-axis-value is the second coordinate (from center to SOUTH)
- X-axis-value is the first coordinate (from center to EAST)
We add 36000, because atan2 also returns negative values. Then we practically
have the first spherical value. Therefore we proceed as in case
SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value.
--> add 45000 in total
--> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
*/
tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000;
tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; // convert to range [0,0xFFFF]
/*
atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
- Y-axis-value is the second coordinate (from center to SOUTH)
- X-axis-value is the first coordinate (from center to EAST)
We add 36000, because atan2 also returns negative values. Then we practically
have the first spherical value. Therefore we proceed as in case
SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value.
--> add 45000 in total
--> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
*/
tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000;
tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */
return (Uint16) tmp;
default:

View file

@ -41,8 +41,8 @@ static struct
char *name;
SDL_Haptic *haptic;
DIDEVCAPS capabilities;
Uint8 bXInputHaptic; // Supports force feedback via XInput.
Uint8 userid; // XInput userid index for this joystick
Uint8 bXInputHaptic; /* Supports force feedback via XInput. */
Uint8 userid; /* XInput userid index for this joystick */
} SDL_hapticlist[MAX_HAPTICS];
@ -54,8 +54,8 @@ struct haptic_hwdata
LPDIRECTINPUTDEVICE8 device;
DWORD axes[3]; /* Axes to use. */
int is_joystick; /* Device is loaded as joystick. */
Uint8 bXInputHaptic; // Supports force feedback via XInput.
Uint8 userid; // XInput userid index for this joystick
Uint8 bXInputHaptic; /* Supports force feedback via XInput. */
Uint8 userid; /* XInput userid index for this joystick */
};
@ -107,7 +107,7 @@ static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE *
static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
/*
/*
* Like SDL_SetError but for DX error codes.
*/
static int
@ -732,7 +732,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
}
/*
/*
* Clean up after system specific haptic stuff
*/
void
@ -1264,12 +1264,13 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
DIEFFECT temp;
if (haptic->hwdata->bXInputHaptic) {
// !!! FIXME: this isn't close to right. We only support "sine" effects,
// !!! FIXME: we ignore most of the parameters, and we probably get
// !!! FIXME: the ones we don't ignore wrong, too.
// !!! FIXME: if I had a better understanding of how the two motors
// !!! FIXME: could be used in unison, perhaps I could implement other
// !!! FIXME: effect types?
/* !!! FIXME: this isn't close to right. We only support "sine" effects,
* !!! FIXME: we ignore most of the parameters, and we probably get
* !!! FIXME: the ones we don't ignore wrong, too.
* !!! FIXME: if I had a better understanding of how the two motors
* !!! FIXME: could be used in unison, perhaps I could implement other
* !!! FIXME: effect types?
*/
/* From MSDN:
"Note that the right motor is the high-frequency motor, the left
motor is the low-frequency motor. They do not always need to be
@ -1528,5 +1529,6 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
return 0;
}
#endif /* SDL_HAPTIC_DINPUT */
/* vi: set ts=4 sw=4 expandtab: */