Completed adding new hotplug stubs for the joystick implementations
authorSam Lantinga <slouken@libsdl.org>
Mon, 26 Nov 2012 22:27:49 -0800
changeset 669828ab2ef7bfc9
parent 6697 dbda91031456
child 6699 f5c53e855de7
child 6700 c8f3d3f0251e
Completed adding new hotplug stubs for the joystick implementations
src/joystick/beos/SDL_bejoystick.cc
src/joystick/bsd/SDL_sysjoystick.c
src/joystick/darwin/SDL_sysjoystick.c
src/joystick/dummy/SDL_sysjoystick.c
src/joystick/iphoneos/SDL_sysjoystick.m
src/joystick/linux/SDL_sysjoystick.c
src/joystick/nds/SDL_sysjoystick.c
src/joystick/windows/SDL_dxjoystick.c
src/joystick/windows/SDL_mmjoystick.c
     1.1 --- a/src/joystick/beos/SDL_bejoystick.cc	Mon Nov 26 22:09:58 2012 -0800
     1.2 +++ b/src/joystick/beos/SDL_bejoystick.cc	Mon Nov 26 22:27:49 2012 -0800
     1.3 @@ -50,6 +50,8 @@
     1.4          int16 *new_axes;
     1.5      };
     1.6  
     1.7 +    static int SDL_SYS_numjoysticks = 0;
     1.8 +
     1.9  /* Function to scan the system for joysticks.
    1.10   * This function should set SDL_numjoysticks to the number of available
    1.11   * joysticks.  Joystick 0 should be the system default joystick.
    1.12 @@ -58,34 +60,33 @@
    1.13      int SDL_SYS_JoystickInit(void)
    1.14      {
    1.15          BJoystick joystick;
    1.16 -        int numjoysticks;
    1.17          int i;
    1.18          int32 nports;
    1.19          char name[B_OS_NAME_LENGTH];
    1.20  
    1.21          /* Search for attached joysticks */
    1.22            nports = joystick.CountDevices();
    1.23 -          numjoysticks = 0;
    1.24 +          SDL_SYS_numjoysticks = 0;
    1.25            SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
    1.26            SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
    1.27 -        for (i = 0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i)
    1.28 +        for (i = 0; (SDL_SYS_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i)
    1.29          {
    1.30              if (joystick.GetDeviceName(i, name) == B_OK) {
    1.31                  if (joystick.Open(name) != B_ERROR) {
    1.32                      BString stick_name;
    1.33                        joystick.GetControllerName(&stick_name);
    1.34 -                      SDL_joyport[numjoysticks] = strdup(name);
    1.35 -                      SDL_joyname[numjoysticks] = strdup(stick_name.String());
    1.36 -                      numjoysticks++;
    1.37 +                      SDL_joyport[SDL_SYS_numjoysticks] = strdup(name);
    1.38 +                      SDL_joyname[SDL_SYS_numjoysticks] = strdup(stick_name.String());
    1.39 +                      SDL_SYS_numjoysticks++;
    1.40                        joystick.Close();
    1.41                  }
    1.42              }
    1.43          }
    1.44 -        return (numjoysticks);
    1.45 +        return (SDL_SYS_numjoysticks);
    1.46      }
    1.47  
    1.48  /* Function to get the device-dependent name of a joystick */
    1.49 -    const char *SDL_SYS_JoystickName(int index)
    1.50 +    const char *SDL_SYS_JoystickNameForIndex(int index)
    1.51      {
    1.52          return SDL_joyname[index];
    1.53      }
    1.54 @@ -95,11 +96,12 @@
    1.55     This should fill the nbuttons and naxes fields of the joystick structure.
    1.56     It returns 0, or -1 if there is an error.
    1.57   */
    1.58 -    int SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
    1.59 +    int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
    1.60      {
    1.61          BJoystick *stick;
    1.62  
    1.63          /* Create the joystick data structure */
    1.64 +        joystick->instance_id = device_index;
    1.65          joystick->hwdata = (struct joystick_hwdata *)
    1.66              SDL_malloc(sizeof(*joystick->hwdata));
    1.67          if (joystick->hwdata == NULL) {
    1.68 @@ -111,7 +113,7 @@
    1.69          joystick->hwdata->stick = stick;
    1.70  
    1.71          /* Open the requested joystick for use */
    1.72 -        if (stick->Open(SDL_joyport[joystick->index]) == B_ERROR) {
    1.73 +        if (stick->Open(SDL_joyport[device_index]) == B_ERROR) {
    1.74              SDL_SetError("Unable to open joystick");
    1.75              SDL_SYS_JoystickClose(joystick);
    1.76              return (-1);
    1.77 @@ -233,6 +235,53 @@
    1.78          SDL_joyname[0] = NULL;
    1.79      }
    1.80  
    1.81 +/* Function to perform the mapping from device index to the instance id for this index */
    1.82 +    SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
    1.83 +    {
    1.84 +        return index;
    1.85 +    }
    1.86 +
    1.87 +/* Function to determine is this joystick is attached to the system right now */
    1.88 +    int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
    1.89 +    {
    1.90 +        return 1;
    1.91 +    }
    1.92 +
    1.93 +    int SDL_SYS_NumJoysticks()
    1.94 +    {
    1.95 +        return SDL_SYS_numjoysticks;
    1.96 +    }
    1.97 +
    1.98 +    int SDL_SYS_JoystickNeedsPolling()
    1.99 +    {
   1.100 +        return 0;
   1.101 +    }
   1.102 +
   1.103 +    void SDL_SYS_JoystickDetect()
   1.104 +    {
   1.105 +    }
   1.106 +
   1.107 +    JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
   1.108 +    {
   1.109 +        JoystickGUID guid;
   1.110 +        // the GUID is just the first 16 chars of the name for now
   1.111 +        const char *name = SDL_SYS_JoystickNameForIndex( device_index );
   1.112 +        SDL_zero( guid );
   1.113 +        SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   1.114 +        return guid;
   1.115 +    }
   1.116 +
   1.117 +
   1.118 +    JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
   1.119 +    {
   1.120 +        JoystickGUID guid;
   1.121 +        // the GUID is just the first 16 chars of the name for now
   1.122 +        const char *name = joystick->name;
   1.123 +        SDL_zero( guid );
   1.124 +        SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   1.125 +        return guid;
   1.126 +    }
   1.127 +
   1.128  };                              // extern "C"
   1.129  
   1.130  #endif /* SDL_JOYSTICK_BEOS */
     2.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     2.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     2.3 @@ -278,6 +278,7 @@
     2.4          return (-1);
     2.5      }
     2.6  
     2.7 +    joy->instance_id = device_index;
     2.8      hw = (struct joystick_hwdata *)
     2.9          SDL_malloc(sizeof(struct joystick_hwdata));
    2.10      if (hw == NULL) {
     3.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     3.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     3.3 @@ -831,8 +831,8 @@
     3.4      for (index = device_index; index > 0; index--)
     3.5          device = device->pNext;
     3.6  
     3.7 +	joystick->instance_id = device->instance_id;
     3.8      joystick->hwdata = device;
     3.9 -	joystick->instance_id = device->instance_id;
    3.10  	joystick->name = device->product;
    3.11  
    3.12  	joystick->naxes = device->axes;
     4.1 --- a/src/joystick/dummy/SDL_sysjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     4.2 +++ b/src/joystick/dummy/SDL_sysjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     4.3 @@ -42,7 +42,7 @@
     4.4  
     4.5  /* Function to get the device-dependent name of a joystick */
     4.6  const char *
     4.7 -SDL_SYS_JoystickName(int index)
     4.8 +SDL_SYS_JoystickNameForDevice(int index)
     4.9  {
    4.10      SDL_SetError("Logic error: No joysticks available");
    4.11      return (NULL);
    4.12 @@ -54,7 +54,7 @@
    4.13     It returns 0, or -1 if there is an error.
    4.14   */
    4.15  int
    4.16 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
    4.17 +SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
    4.18  {
    4.19      SDL_SetError("Logic error: No joysticks available");
    4.20      return (-1);
    4.21 @@ -85,6 +85,53 @@
    4.22      return;
    4.23  }
    4.24  
    4.25 +/* Function to perform the mapping from device index to the instance id for this index */
    4.26 +SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
    4.27 +{
    4.28 +    return index;
    4.29 +}
    4.30 +
    4.31 +/* Function to determine is this joystick is attached to the system right now */
    4.32 +int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
    4.33 +{
    4.34 +    return 1;
    4.35 +}
    4.36 +
    4.37 +int SDL_SYS_NumJoysticks()
    4.38 +{
    4.39 +    return 0;
    4.40 +}
    4.41 +
    4.42 +int SDL_SYS_JoystickNeedsPolling()
    4.43 +{
    4.44 +    return 0;
    4.45 +}
    4.46 +
    4.47 +void SDL_SYS_JoystickDetect()
    4.48 +{
    4.49 +}
    4.50 +
    4.51 +JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
    4.52 +{
    4.53 +    JoystickGUID guid;
    4.54 +    // the GUID is just the first 16 chars of the name for now
    4.55 +    const char *name = SDL_SYS_JoystickNameForIndex( device_index );
    4.56 +    SDL_zero( guid );
    4.57 +    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    4.58 +    return guid;
    4.59 +}
    4.60 +
    4.61 +
    4.62 +JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
    4.63 +{
    4.64 +    JoystickGUID guid;
    4.65 +    // the GUID is just the first 16 chars of the name for now
    4.66 +    const char *name = joystick->name;
    4.67 +    SDL_zero( guid );
    4.68 +    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    4.69 +    return guid;
    4.70 +}
    4.71 +
    4.72  #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
    4.73  
    4.74  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/joystick/iphoneos/SDL_sysjoystick.m	Mon Nov 26 22:09:58 2012 -0800
     5.2 +++ b/src/joystick/iphoneos/SDL_sysjoystick.m	Mon Nov 26 22:27:49 2012 -0800
     5.3 @@ -68,12 +68,10 @@
     5.4  		joystick->nbuttons = 0;
     5.5  		[[SDLUIAccelerationDelegate sharedDelegate] startup];
     5.6  		return 0;
     5.7 -	}
     5.8 -	else {
     5.9 +	} else {
    5.10  		SDL_SetError("No joystick available with that index");
    5.11  		return (-1);
    5.12  	}
    5.13 -	
    5.14  }
    5.15  
    5.16  /* Function to update the state of a joystick - called as a device poll.
     6.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     6.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     6.3 @@ -390,7 +390,7 @@
     6.4  
     6.5  #endif /* SDL_INPUT_LINUXEV */
     6.6  
     6.7 -int SDL_SYS_numjoysticks = 0;
     6.8 +static int SDL_SYS_numjoysticks = 0;
     6.9  
    6.10  /* Function to scan the system for joysticks */
    6.11  int
    6.12 @@ -827,6 +827,7 @@
    6.13          SDL_SetError("Unable to open %s\n", SDL_joylist[joystick->instance_id]);
    6.14          return (-1);
    6.15      }
    6.16 +    joystick->instance_id = device_index;
    6.17      joystick->hwdata = (struct joystick_hwdata *)
    6.18          SDL_malloc(sizeof(*joystick->hwdata));
    6.19      if (joystick->hwdata == NULL) {
    6.20 @@ -837,7 +838,6 @@
    6.21      SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
    6.22      joystick->hwdata->fd = fd;
    6.23      joystick->hwdata->fname = fname;
    6.24 -    joystick->instance_id = device_index;
    6.25  
    6.26      /* Set the joystick to non-blocking read mode */
    6.27      fcntl(fd, F_SETFL, O_NONBLOCK);
     7.1 --- a/src/joystick/nds/SDL_sysjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     7.2 +++ b/src/joystick/nds/SDL_sysjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     7.3 @@ -43,13 +43,12 @@
     7.4  int
     7.5  SDL_SYS_JoystickInit(void)
     7.6  {
     7.7 -    SDL_numjoysticks = 1;
     7.8      return (1);
     7.9  }
    7.10  
    7.11  /* Function to get the device-dependent name of a joystick */
    7.12  const char *
    7.13 -SDL_SYS_JoystickName(int index)
    7.14 +SDL_SYS_JoystickNameForIndex(int index)
    7.15  {
    7.16      if (!index)
    7.17          return "NDS builtin joypad";
    7.18 @@ -63,7 +62,7 @@
    7.19     It returns 0, or -1 if there is an error.
    7.20   */
    7.21  int
    7.22 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
    7.23 +SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
    7.24  {
    7.25      joystick->nbuttons = 8;
    7.26      joystick->nhats = 0;
    7.27 @@ -168,4 +167,51 @@
    7.28  {
    7.29  }
    7.30  
    7.31 +/* Function to perform the mapping from device index to the instance id for this index */
    7.32 +SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
    7.33 +{
    7.34 +    return index;
    7.35 +}
    7.36 +
    7.37 +/* Function to determine is this joystick is attached to the system right now */
    7.38 +int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
    7.39 +{
    7.40 +    return 1;
    7.41 +}
    7.42 +
    7.43 +int SDL_SYS_NumJoysticks()
    7.44 +{
    7.45 +    return 1;
    7.46 +}
    7.47 +
    7.48 +int SDL_SYS_JoystickNeedsPolling()
    7.49 +{
    7.50 +    return 0;
    7.51 +}
    7.52 +
    7.53 +void SDL_SYS_JoystickDetect()
    7.54 +{
    7.55 +}
    7.56 +
    7.57 +JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
    7.58 +{
    7.59 +    JoystickGUID guid;
    7.60 +    // the GUID is just the first 16 chars of the name for now
    7.61 +    const char *name = SDL_SYS_JoystickNameForIndex( device_index );
    7.62 +    SDL_zero( guid );
    7.63 +    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    7.64 +    return guid;
    7.65 +}
    7.66 +
    7.67 +
    7.68 +JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
    7.69 +{
    7.70 +    JoystickGUID guid;
    7.71 +    // the GUID is just the first 16 chars of the name for now
    7.72 +    const char *name = joystick->name;
    7.73 +    SDL_zero( guid );
    7.74 +    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    7.75 +    return guid;
    7.76 +}
    7.77 +
    7.78  #endif /* SDL_JOYSTICK_NDS */
     8.1 --- a/src/joystick/windows/SDL_dxjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     8.2 +++ b/src/joystick/windows/SDL_dxjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     8.3 @@ -707,6 +707,7 @@
     8.4      dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
     8.5  
     8.6      /* allocate memory for system specific hardware data */
     8.7 +	joystick->instance_id = joystickdevice->nInstanceID;
     8.8      joystick->hwdata =
     8.9          (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata));
    8.10      if (joystick->hwdata == NULL) {
    8.11 @@ -716,7 +717,6 @@
    8.12      SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata));
    8.13      joystick->hwdata->buffered = 1;
    8.14  	joystick->hwdata->removed = 0;
    8.15 -	joystick->instance_id = joystickdevice->nInstanceID;
    8.16      joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS);
    8.17  	joystick->hwdata->guid = joystickdevice->guid;
    8.18  
     9.1 --- a/src/joystick/windows/SDL_mmjoystick.c	Mon Nov 26 22:09:58 2012 -0800
     9.2 +++ b/src/joystick/windows/SDL_mmjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     9.3 @@ -135,6 +135,8 @@
     9.4      return (name);
     9.5  }
     9.6  
     9.7 +static int SDL_SYS_numjoysticks = 0;
     9.8 +
     9.9  /* Function to scan the system for joysticks.
    9.10   * This function should set SDL_numjoysticks to the number of available
    9.11   * joysticks.  Joystick 0 should be the system default joystick.
    9.12 @@ -145,7 +147,6 @@
    9.13  {
    9.14      int i;
    9.15      int maxdevs;
    9.16 -    int numdevs;
    9.17      JOYINFOEX joyinfo;
    9.18      JOYCAPS joycaps;
    9.19      MMRESULT result;
    9.20 @@ -157,9 +158,9 @@
    9.21      }
    9.22  
    9.23      /* Loop over all potential joystick devices */
    9.24 -    numdevs = 0;
    9.25 +    SDL_SYS_numjoysticks = 0;
    9.26      maxdevs = joyGetNumDevs();
    9.27 -    for (i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i) {
    9.28 +    for (i = JOYSTICKID1; i < maxdevs && SDL_SYS_numjoysticks < MAX_JOYSTICKS; ++i) {
    9.29  
    9.30          joyinfo.dwSize = sizeof(joyinfo);
    9.31          joyinfo.dwFlags = JOY_RETURNALL;
    9.32 @@ -167,20 +168,20 @@
    9.33          if (result == JOYERR_NOERROR) {
    9.34              result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
    9.35              if (result == JOYERR_NOERROR) {
    9.36 -                SYS_JoystickID[numdevs] = i;
    9.37 -                SYS_Joystick[numdevs] = joycaps;
    9.38 -                SYS_JoystickName[numdevs] =
    9.39 +                SYS_JoystickID[SDL_SYS_numjoysticks] = i;
    9.40 +                SYS_Joystick[SDL_SYS_numjoysticks] = joycaps;
    9.41 +                SYS_JoystickName[SDL_SYS_numjoysticks] =
    9.42                      GetJoystickName(i, joycaps.szRegKey);
    9.43 -                numdevs++;
    9.44 +                SDL_SYS_numjoysticks++;
    9.45              }
    9.46          }
    9.47      }
    9.48 -    return (numdevs);
    9.49 +    return (SDL_SYS_numjoysticks);
    9.50  }
    9.51  
    9.52  /* Function to get the device-dependent name of a joystick */
    9.53  const char *
    9.54 -SDL_SYS_JoystickName(int index)
    9.55 +SDL_SYS_JoystickNameForIndex(int index)
    9.56  {
    9.57      if (SYS_JoystickName[index] != NULL) {
    9.58          return (SYS_JoystickName[index]);
    9.59 @@ -195,7 +196,7 @@
    9.60     It returns 0, or -1 if there is an error.
    9.61   */
    9.62  int
    9.63 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
    9.64 +SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
    9.65  {
    9.66      int index, i;
    9.67      int caps_flags[MAX_AXES - 2] =
    9.68 @@ -204,7 +205,7 @@
    9.69  
    9.70  
    9.71      /* shortcut */
    9.72 -    index = joystick->index;
    9.73 +    index = device_index;
    9.74      axis_min[0] = SYS_Joystick[index].wXmin;
    9.75      axis_max[0] = SYS_Joystick[index].wXmax;
    9.76      axis_min[1] = SYS_Joystick[index].wYmin;
    9.77 @@ -219,6 +220,7 @@
    9.78      axis_max[5] = SYS_Joystick[index].wVmax;
    9.79  
    9.80      /* allocate memory for system specific hardware data */
    9.81 +    joystick->instance_id = device_index;
    9.82      joystick->hwdata =
    9.83          (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
    9.84      if (joystick->hwdata == NULL) {
    9.85 @@ -377,6 +379,53 @@
    9.86      }
    9.87  }
    9.88  
    9.89 +/* Function to perform the mapping from device index to the instance id for this index */
    9.90 +SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
    9.91 +{
    9.92 +    return index;
    9.93 +}
    9.94 +
    9.95 +/* Function to determine is this joystick is attached to the system right now */
    9.96 +int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
    9.97 +{
    9.98 +    return 1;
    9.99 +}
   9.100 +
   9.101 +int SDL_SYS_NumJoysticks()
   9.102 +{
   9.103 +    return SDL_SYS_numjoysticks;
   9.104 +}
   9.105 +
   9.106 +int SDL_SYS_JoystickNeedsPolling()
   9.107 +{
   9.108 +    return 0;
   9.109 +}
   9.110 +
   9.111 +void SDL_SYS_JoystickDetect()
   9.112 +{
   9.113 +}
   9.114 +
   9.115 +JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
   9.116 +{
   9.117 +    JoystickGUID guid;
   9.118 +    // the GUID is just the first 16 chars of the name for now
   9.119 +    const char *name = SDL_SYS_JoystickNameForIndex( device_index );
   9.120 +    SDL_zero( guid );
   9.121 +    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   9.122 +    return guid;
   9.123 +}
   9.124 +
   9.125 +
   9.126 +JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
   9.127 +{
   9.128 +    JoystickGUID guid;
   9.129 +    // the GUID is just the first 16 chars of the name for now
   9.130 +    const char *name = joystick->name;
   9.131 +    SDL_zero( guid );
   9.132 +    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   9.133 +    return guid;
   9.134 +}
   9.135 +
   9.136  
   9.137  /* implementation functions */
   9.138  void