[SDL] Weirdness with SDL_GetVideoInfo and Joystick

Tyler Olsen roots at allacrost.org
Thu Aug 26 03:15:33 PDT 2004


I've been working with SDL for 2 months and so far everything seems to 
be working great, but a couple days ago I wrote a function to try 
printing out information about my system and I got some really 
unexpected results. Here is the C++ code (this is for Debian Linux):


   cout << "_____Printing system information_____" << endl;

   // Initialize SDL and its subsystems and make sure it shutdowns 
properly on exit
   if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) != 0) {
     cout << "ERROR: Unable to initialize SDL: " << SDL_GetError() << endl;
     return;
   }
   else
     cout << "SDL Initialized succesfully." << endl;
   atexit(SDL_Quit);

   // Video Information
   cout << " *** VIDEO INFORMATION *** " << endl;
   char video_driver[20];
   SDL_VideoDriverName(video_driver, 20);
   cout << "Video driver name: " << video_driver << "\n" << endl;

   const SDL_VideoInfo *user_video;
   user_video = SDL_GetVideoInfo(); // Get information about the user's 
video system
   cout << "Best available video mode" << endl;
   cout << ">Creates hardware surfaces: ";
   if (user_video->hw_available == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Has window manager available: ";
   if (user_video->wm_available == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Hardware to hardware blits accelerated: ";
   if (user_video->blit_hw == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Hardware to hardware colorkey blits accelerated: ";
   if (user_video->blit_hw_CC == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Hardware to hardware alpha blits accelerated: ";
   if (user_video->blit_hw_A == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Software to hardware blits acceleerated: ";
   if (user_video->blit_sw == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Software to hardware colorkey blits accelerated: ";
   if (user_video->blit_sw_CC == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Software to hardware alpha blits accelerated: ";
   if (user_video->blit_sw_A == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Color fills accelerated: ";
   if (user_video->blit_fill == 1) cout << "yes\n";
   else cout << "no\n";
   cout << ">Total video memory: " << user_video->video_mem << " 
kilobytes" << "\n" << endl;

   // Joystick Information
   cout << " *** JOYSTICK INFORMATION *** " << endl;

   int js_num = SDL_NumJoysticks(); // Get the number of joysticks available
   cout << "SDL has recognized " << js_num << " on this system." << endl;
   for (int i = 0; i < js_num; i++) { // Print out information about 
each joystick
     joy_stick = SDL_JoystickOpen(i);
     if (joy_stick == NULL)
       cout << "ERROR: SDL was unable to open joystick #" << i << endl;
     else {
       cout << "Joystick #" << i << endl;
       cout << ">Name: " << SDL_JoystickName(i) << endl;
       cout << ">Axes: " << SDL_JoystickNumAxes(joy_stick) << endl;
       cout << ">Buttons: " << SDL_JoystickNumButtons(joy_stick) << endl;
       cout << ">Trackballs: " << SDL_JoystickNumBalls(joy_stick) << endl;
       cout << ">Hat Switches: " << SDL_JoystickNumHats(joy_stick) << endl;
       SDL_JoystickClose(joy_stick);
     }
   }



Here is the output from the program:

_____Printing system information_____
SDL Initialized succesfully.
  *** VIDEO INFORMATION ***
Video driver name: x11

Best available video mode
 >Creates hardware surfaces: no
 >Has window manager available: yes
 >Hardware to hardware blits accelerated: no
 >Hardware to hardware colorkey blits accelerated: no
 >Hardware to hardware alpha blits accelerated: no
 >Software to hardware blits acceleerated: no
 >Software to hardware colorkey blits accelerated: no
 >Software to hardware alpha blits accelerated: no
 >Color fills accelerated: no
 >Total video memory: 0 kilobytes

  *** JOYSTICK INFORMATION ***
SDL has recognized 0 on this system.



I tried calling SDL_SetVideoMode before I call SDL_GetVideoInfo(), but I 
got the same results for the video information. I have a Radeon 9500PRO 
video card and I have successfuly installed the ATI drivers so I don't 
know how I could have 0KB of video memory (-_-'). Does anyone know what 
the problem is here?

Also, I have a Logitech Wingman Extreme gamepad currently plugged into a 
USB port on my PC, so I thought SDL would recognize that but it doesn't. 
I see it recognized during my kernel boot-up messages, and last time I 
checked it worked fine when I was running SNES9x. Again I find it 
strange that nothing was detected.

Thanks in advance to any insight to this matter.

-- 
Tyler Olsen - Lead Developer
Hero of Allacrost: http://www.allacrost.org





More information about the SDL mailing list