Support for SVGALib 2.0, thanks to Benjamin Joel Stover
authorSam Lantinga <slouken@lokigames.com>
Sat, 16 Jun 2001 01:32:09 +0000
changeset 673647c809813d
parent 66 7c26b77e610d
child 68 ac6645260d31
Support for SVGALib 2.0, thanks to Benjamin Joel Stover
src/video/svga/SDL_svgavideo.c
     1.1 --- a/src/video/svga/SDL_svgavideo.c	Sat Jun 16 01:03:49 2001 +0000
     1.2 +++ b/src/video/svga/SDL_svgavideo.c	Sat Jun 16 01:32:09 2001 +0000
     1.3 @@ -32,6 +32,9 @@
     1.4  #include <stdio.h>
     1.5  #include <unistd.h>
     1.6  #include <sys/stat.h>
     1.7 +#include <sys/types.h>
     1.8 +#include <sys/ioctl.h>
     1.9 +#include <fcntl.h>
    1.10  
    1.11  #if defined(linux)
    1.12  #include <linux/vt.h>
    1.13 @@ -77,7 +80,11 @@
    1.14  {
    1.15  	/* Check to see if we are root and stdin is a virtual console */
    1.16  	int console;
    1.17 +	
    1.18 +	/* SVGALib 1.9.x+ doesn't require root (via /dev/svga) */
    1.19 +	int svgalib2 = -1;
    1.20  
    1.21 +	/* See if we are connected to a virtual terminal */
    1.22  	console = STDIN_FILENO;
    1.23  	if ( console >= 0 ) {
    1.24  		struct stat sb;
    1.25 @@ -88,7 +95,14 @@
    1.26  			console = -1;
    1.27  		}
    1.28  	}
    1.29 -	return((geteuid() == 0) && (console >= 0));
    1.30 +
    1.31 +	/* See if SVGAlib 2.0 is available */
    1.32 +	svgalib2 = open("/dev/svga", O_RDONLY);
    1.33 +	if (svgalib2 != -1) {
    1.34 +		close(svgalib2);
    1.35 +	}
    1.36 +
    1.37 +	return(((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0));
    1.38  }
    1.39  
    1.40  static void SVGA_DeleteDevice(SDL_VideoDevice *device)