early-access version 2281
This commit is contained in:
17
externals/SDL/src/haptic/linux/SDL_syshaptic.c
vendored
17
externals/SDL/src/haptic/linux/SDL_syshaptic.c
vendored
@@ -35,7 +35,6 @@
|
||||
#include <fcntl.h> /* O_RDWR */
|
||||
#include <limits.h> /* INT_MAX */
|
||||
#include <errno.h> /* errno, strerror */
|
||||
#include <math.h> /* atan2 */
|
||||
#include <sys/stat.h> /* stat */
|
||||
|
||||
/* Just in case. */
|
||||
@@ -166,7 +165,7 @@ SDL_SYS_HapticInit(void)
|
||||
i = 0;
|
||||
for (j = 0; j < MAX_HAPTICS; ++j) {
|
||||
|
||||
snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||
SDL_snprintf(path, PATH_MAX, joydev_pattern, i++);
|
||||
MaybeAddDevice(path);
|
||||
}
|
||||
|
||||
@@ -260,7 +259,7 @@ MaybeAddDevice(const char *path)
|
||||
}
|
||||
|
||||
/* try to open */
|
||||
fd = open(path, O_RDWR, 0);
|
||||
fd = open(path, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -375,7 +374,7 @@ SDL_SYS_HapticName(int index)
|
||||
item = HapticByDevIndex(index);
|
||||
/* Open the haptic device. */
|
||||
name = NULL;
|
||||
fd = open(item->fname, O_RDONLY, 0);
|
||||
fd = open(item->fname, O_RDONLY | O_CLOEXEC, 0);
|
||||
|
||||
if (fd >= 0) {
|
||||
|
||||
@@ -453,7 +452,7 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
||||
|
||||
item = HapticByDevIndex(haptic->index);
|
||||
/* Open the character device */
|
||||
fd = open(item->fname, O_RDWR, 0);
|
||||
fd = open(item->fname, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
item->fname, strerror(errno));
|
||||
@@ -483,7 +482,7 @@ SDL_SYS_HapticMouse(void)
|
||||
|
||||
for (item = SDL_hapticlist; item; item = item->next) {
|
||||
/* Open the device. */
|
||||
fd = open(item->fname, O_RDWR, 0);
|
||||
fd = open(item->fname, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
item->fname, strerror(errno));
|
||||
@@ -570,7 +569,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
||||
}
|
||||
|
||||
fd = open(joystick->hwdata->fname, O_RDWR, 0);
|
||||
fd = open(joystick->hwdata->fname, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
joystick->hwdata->fname, strerror(errno));
|
||||
@@ -713,10 +712,10 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
|
||||
else {
|
||||
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
/*
|
||||
atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
|
||||
SDL_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
|
||||
We add 36000, because SDL_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
|
||||
|
Reference in New Issue
Block a user