/* * call-seq: * name -> String * * Returns a String containing the name of the Joystick, up to 1024 * characters long. The name is implementation-dependent. See also * #get_name(). */ VALUE rbgm_joystick_name( VALUE self ) { char *name; SDL_Joystick *joy; Uint8 index; int n; int size = 1024; Data_Get_Struct(self,SDL_Joystick,joy); index = SDL_JoystickIndex(joy); name = (char *)malloc(size); n = snprintf(name,size,"%s",SDL_JoystickName(index)); return rb_str_new(name,n); }