From dd37f154cfb34c21f85ad86c0a59a7de399e6461 Mon Sep 17 00:00:00 2001 From: Edgar Simo Date: Sun, 1 Jun 2008 19:11:49 +0000 Subject: [PATCH] Some code cleanup. --- src/haptic/SDL_haptic.c | 15 ++++++++++++++- src/haptic/SDL_haptic_c.h | 4 ++-- src/haptic/SDL_syshaptic.h | 8 +++++--- src/haptic/linux/SDL_syshaptic.c | 30 +++++++++++++++++++++++++++--- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index a09209148..822c2d6b2 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -83,7 +83,7 @@ SDL_HapticName(int device_index) /* - * Opens a Haptic device + * Opens a Haptic device. */ SDL_Haptic * SDL_HapticOpen(int device_index) @@ -127,6 +127,19 @@ SDL_HapticOpen(int device_index) } +/* + * Closes a SDL_Haptic device. + */ +void +SDL_HapticClose(SDL_Haptic * haptic) +{ + (void)haptic; + /* TODO */ +} + +/* + * Cleans up after the subsystem. + */ void SDL_HapticQuit(void) { diff --git a/src/haptic/SDL_haptic_c.h b/src/haptic/SDL_haptic_c.h index 645407b25..0d29b4d0d 100644 --- a/src/haptic/SDL_haptic_c.h +++ b/src/haptic/SDL_haptic_c.h @@ -29,6 +29,6 @@ extern int SDL_NumHaptics(void); extern const char * SDL_HapticName(int device_index); extern struct _SDL_Haptic * SDL_HapticOpen(int device_index); extern int SDL_HapticOpened(int device_index); -extern int SDL_HapticIndex(struct _SDL_Haptic *haptic); -extern void SDL_HapticClose(struct _SDL_Haptic *haptic); +extern int SDL_HapticIndex(SDL_Haptic * haptic); +extern void SDL_HapticClose(SDL_Haptic * haptic); extern void SDL_HapticQuit(void); diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h index 7e2304b61..d7d29db7e 100644 --- a/src/haptic/SDL_syshaptic.h +++ b/src/haptic/SDL_syshaptic.h @@ -27,8 +27,8 @@ struct _SDL_Haptic { - Uint8 index; - const char* name; + Uint8 index; /* stores index it is attached to */ + const char* name; /* stores the name of the device */ int neffects; /* maximum amount of effects */ unsigned int supported; /* supported effects */ @@ -39,6 +39,8 @@ struct _SDL_Haptic extern int SDL_SYS_HapticInit(void); - extern const char * SDL_SYS_HapticName(int index); +extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic); +extern void SDL_SYS_HapticClose(SDL_Haptic * haptic); +extern void SDL_SYS_HapticQuit(void); diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 1d78ccfbb..8aebcfada 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -37,28 +37,37 @@ #include -#include - - #define MAX_HAPTICS 32 +/* + * List of available haptic devices. + */ static struct { char *fname; SDL_Haptic *haptic; } SDL_hapticlist[MAX_HAPTICS]; + +/* + * Haptic system hardware data. + */ struct haptic_hwdata { int fd; }; + #define test_bit(nr, addr) \ (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) #define EV_TEST(ev,f) \ if (test_bit((ev), features)) ret |= (f); +/* + * Test whether a device has haptic properties. + * Returns available properties or 0 if there are none. + */ static int EV_IsHaptic(int fd) { @@ -139,6 +148,9 @@ SDL_SYS_HapticInit(void) } +/* + * Return the name of a haptic device, does not need to be opened. + */ const char * SDL_SYS_HapticName(int index) { @@ -162,6 +174,9 @@ SDL_SYS_HapticName(int index) } +/* + * Opens a haptic device for usage. + */ int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { @@ -182,6 +197,15 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) } +/* + * Closes the haptic device. + */ +void +SDL_SYS_HapticClose(SDL_Haptic * haptic) +{ +} + + /* Clean up after system specific haptic stuff */ void SDL_SYS_HapticQuit(void)