Corrected Linux joystick things, fixes assertion failure from testjoystick.
This commit is contained in:
parent
d2b1601539
commit
6b4cb17219
2 changed files with 9 additions and 5 deletions
|
@ -319,7 +319,7 @@ MaybeRemoveDevice(const char *path)
|
||||||
if (SDL_strcmp(path, item->path) == 0) {
|
if (SDL_strcmp(path, item->path) == 0) {
|
||||||
const int retval = item->device_instance;
|
const int retval = item->device_instance;
|
||||||
if (item->hwdata) {
|
if (item->hwdata) {
|
||||||
item->hwdata->removed = SDL_TRUE;
|
item->hwdata->item = NULL;
|
||||||
}
|
}
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
prev->next = item->next;
|
prev->next = item->next;
|
||||||
|
@ -731,7 +731,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
|
||||||
joystick->hwdata->removed = SDL_FALSE;
|
joystick->hwdata->item = item;
|
||||||
joystick->hwdata->guid = item->guid;
|
joystick->hwdata->guid = item->guid;
|
||||||
joystick->hwdata->fd = fd;
|
joystick->hwdata->fd = fd;
|
||||||
joystick->hwdata->fname = SDL_strdup(item->path);
|
joystick->hwdata->fname = SDL_strdup(item->path);
|
||||||
|
@ -758,7 +758,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
/* Function to determine is this joystick is attached to the system right now */
|
/* Function to determine is this joystick is attached to the system right now */
|
||||||
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
|
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
return !joystick->closed && !joystick->hwdata->removed;
|
return !joystick->closed && (joystick->hwdata->item != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void
|
static __inline__ void
|
||||||
|
@ -913,6 +913,9 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
if (joystick->hwdata) {
|
if (joystick->hwdata) {
|
||||||
close(joystick->hwdata->fd);
|
close(joystick->hwdata->fd);
|
||||||
|
if (joystick->hwdata->item) {
|
||||||
|
joystick->hwdata->item->hwdata = NULL;
|
||||||
|
}
|
||||||
SDL_free(joystick->hwdata->hats);
|
SDL_free(joystick->hwdata->hats);
|
||||||
SDL_free(joystick->hwdata->balls);
|
SDL_free(joystick->hwdata->balls);
|
||||||
SDL_free(joystick->hwdata->fname);
|
SDL_free(joystick->hwdata->fname);
|
||||||
|
|
|
@ -21,12 +21,13 @@
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
|
||||||
|
struct SDL_joylist_item;
|
||||||
|
|
||||||
/* The private structure used to keep track of a joystick */
|
/* The private structure used to keep track of a joystick */
|
||||||
struct joystick_hwdata
|
struct joystick_hwdata
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
SDL_bool removed;
|
struct SDL_joylist_item *item;
|
||||||
|
|
||||||
SDL_JoystickGUID guid;
|
SDL_JoystickGUID guid;
|
||||||
char *fname; /* Used in haptic subsystem */
|
char *fname; /* Used in haptic subsystem */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue