Some code cleanup. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Sun, 01 Jun 2008 19:11:49 +0000
branchgsoc2008_force_feedback
changeset 24754b874e3a3a2c
parent 2474 3f80bf1528b4
child 2476 242d8a668ebb
Some code cleanup.
src/haptic/SDL_haptic.c
src/haptic/SDL_haptic_c.h
src/haptic/SDL_syshaptic.h
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/src/haptic/SDL_haptic.c	Sun Jun 01 18:46:51 2008 +0000
     1.2 +++ b/src/haptic/SDL_haptic.c	Sun Jun 01 19:11:49 2008 +0000
     1.3 @@ -83,7 +83,7 @@
     1.4  
     1.5  
     1.6  /*
     1.7 - * Opens a Haptic device
     1.8 + * Opens a Haptic device.
     1.9   */
    1.10  SDL_Haptic *
    1.11  SDL_HapticOpen(int device_index)
    1.12 @@ -127,6 +127,19 @@
    1.13  }
    1.14  
    1.15  
    1.16 +/*
    1.17 + * Closes a SDL_Haptic device.
    1.18 + */
    1.19 +void
    1.20 +SDL_HapticClose(SDL_Haptic * haptic)
    1.21 +{
    1.22 +   (void)haptic;
    1.23 +   /* TODO */
    1.24 +}
    1.25 +
    1.26 +/*
    1.27 + * Cleans up after the subsystem.
    1.28 + */
    1.29  void
    1.30  SDL_HapticQuit(void)
    1.31  {
     2.1 --- a/src/haptic/SDL_haptic_c.h	Sun Jun 01 18:46:51 2008 +0000
     2.2 +++ b/src/haptic/SDL_haptic_c.h	Sun Jun 01 19:11:49 2008 +0000
     2.3 @@ -29,6 +29,6 @@
     2.4  extern const char * SDL_HapticName(int device_index);
     2.5  extern struct _SDL_Haptic * SDL_HapticOpen(int device_index);
     2.6  extern int SDL_HapticOpened(int device_index);
     2.7 -extern int SDL_HapticIndex(struct _SDL_Haptic *haptic);
     2.8 -extern void SDL_HapticClose(struct _SDL_Haptic *haptic);
     2.9 +extern int SDL_HapticIndex(SDL_Haptic * haptic);
    2.10 +extern void SDL_HapticClose(SDL_Haptic * haptic);
    2.11  extern void SDL_HapticQuit(void);
     3.1 --- a/src/haptic/SDL_syshaptic.h	Sun Jun 01 18:46:51 2008 +0000
     3.2 +++ b/src/haptic/SDL_syshaptic.h	Sun Jun 01 19:11:49 2008 +0000
     3.3 @@ -27,8 +27,8 @@
     3.4  
     3.5  struct _SDL_Haptic
     3.6  {  
     3.7 -   Uint8 index;
     3.8 -   const char* name;
     3.9 +   Uint8 index; /* stores index it is attached to */
    3.10 +   const char* name; /* stores the name of the device */
    3.11  
    3.12     int neffects; /* maximum amount of effects */
    3.13     unsigned int supported; /* supported effects */
    3.14 @@ -39,6 +39,8 @@
    3.15  
    3.16  
    3.17  extern int SDL_SYS_HapticInit(void);
    3.18 +extern const char * SDL_SYS_HapticName(int index);
    3.19 +extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic);
    3.20 +extern void SDL_SYS_HapticClose(SDL_Haptic * haptic);
    3.21 +extern void SDL_SYS_HapticQuit(void);
    3.22  
    3.23 -extern const char * SDL_SYS_HapticName(int index);
    3.24 -
     4.1 --- a/src/haptic/linux/SDL_syshaptic.c	Sun Jun 01 18:46:51 2008 +0000
     4.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Sun Jun 01 19:11:49 2008 +0000
     4.3 @@ -37,28 +37,37 @@
     4.4  #include <string.h>
     4.5  
     4.6  
     4.7 -#include <stdio.h>
     4.8 -
     4.9 -
    4.10  #define MAX_HAPTICS  32
    4.11  
    4.12  
    4.13 +/*
    4.14 + * List of available haptic devices.
    4.15 + */
    4.16  static struct
    4.17  {
    4.18     char *fname;
    4.19     SDL_Haptic *haptic;
    4.20  } SDL_hapticlist[MAX_HAPTICS];
    4.21  
    4.22 +
    4.23 +/*
    4.24 + * Haptic system hardware data.
    4.25 + */
    4.26  struct haptic_hwdata
    4.27  {
    4.28     int fd;
    4.29  };
    4.30  
    4.31  
    4.32 +
    4.33  #define test_bit(nr, addr) \
    4.34     (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0)
    4.35  #define EV_TEST(ev,f) \
    4.36     if (test_bit((ev), features)) ret |= (f);
    4.37 +/*
    4.38 + * Test whether a device has haptic properties.
    4.39 + * Returns available properties or 0 if there are none.
    4.40 + */
    4.41  static int
    4.42  EV_IsHaptic(int fd)
    4.43  {
    4.44 @@ -139,6 +148,9 @@
    4.45  }
    4.46  
    4.47  
    4.48 +/*
    4.49 + * Return the name of a haptic device, does not need to be opened.
    4.50 + */
    4.51  const char *
    4.52  SDL_SYS_HapticName(int index)
    4.53  {
    4.54 @@ -162,6 +174,9 @@
    4.55  }
    4.56  
    4.57  
    4.58 +/*
    4.59 + * Opens a haptic device for usage.
    4.60 + */
    4.61  int
    4.62  SDL_SYS_HapticOpen(SDL_Haptic * haptic)
    4.63  {
    4.64 @@ -182,6 +197,15 @@
    4.65  }
    4.66  
    4.67  
    4.68 +/*
    4.69 + * Closes the haptic device.
    4.70 + */
    4.71 +void
    4.72 +SDL_SYS_HapticClose(SDL_Haptic * haptic)
    4.73 +{
    4.74 +}
    4.75 +
    4.76 +
    4.77  /* Clean up after system specific haptic stuff */
    4.78  void
    4.79  SDL_SYS_HapticQuit(void)