src/video/svga/SDL_svgavideo.c
changeset 67 3647c809813d
parent 1 cf2af46e9e2a
child 205 13161d3d349d
equal deleted inserted replaced
66:7c26b77e610d 67:3647c809813d
    30 
    30 
    31 #include <stdlib.h>
    31 #include <stdlib.h>
    32 #include <stdio.h>
    32 #include <stdio.h>
    33 #include <unistd.h>
    33 #include <unistd.h>
    34 #include <sys/stat.h>
    34 #include <sys/stat.h>
       
    35 #include <sys/types.h>
       
    36 #include <sys/ioctl.h>
       
    37 #include <fcntl.h>
    35 
    38 
    36 #if defined(linux)
    39 #if defined(linux)
    37 #include <linux/vt.h>
    40 #include <linux/vt.h>
    38 #elif defined(__FreeBSD__)
    41 #elif defined(__FreeBSD__)
    39 #include <sys/consio.h>
    42 #include <sys/consio.h>
    75 
    78 
    76 static int SVGA_Available(void)
    79 static int SVGA_Available(void)
    77 {
    80 {
    78 	/* Check to see if we are root and stdin is a virtual console */
    81 	/* Check to see if we are root and stdin is a virtual console */
    79 	int console;
    82 	int console;
    80 
    83 	
       
    84 	/* SVGALib 1.9.x+ doesn't require root (via /dev/svga) */
       
    85 	int svgalib2 = -1;
       
    86 
       
    87 	/* See if we are connected to a virtual terminal */
    81 	console = STDIN_FILENO;
    88 	console = STDIN_FILENO;
    82 	if ( console >= 0 ) {
    89 	if ( console >= 0 ) {
    83 		struct stat sb;
    90 		struct stat sb;
    84 		struct vt_mode dummy;
    91 		struct vt_mode dummy;
    85 
    92 
    86 		if ( (fstat(console, &sb) < 0) ||
    93 		if ( (fstat(console, &sb) < 0) ||
    87 		     (ioctl(console, VT_GETMODE, &dummy) < 0) ) {
    94 		     (ioctl(console, VT_GETMODE, &dummy) < 0) ) {
    88 			console = -1;
    95 			console = -1;
    89 		}
    96 		}
    90 	}
    97 	}
    91 	return((geteuid() == 0) && (console >= 0));
    98 
       
    99 	/* See if SVGAlib 2.0 is available */
       
   100 	svgalib2 = open("/dev/svga", O_RDONLY);
       
   101 	if (svgalib2 != -1) {
       
   102 		close(svgalib2);
       
   103 	}
       
   104 
       
   105 	return(((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0));
    92 }
   106 }
    93 
   107 
    94 static void SVGA_DeleteDevice(SDL_VideoDevice *device)
   108 static void SVGA_DeleteDevice(SDL_VideoDevice *device)
    95 {
   109 {
    96 	free(device->hidden);
   110 	free(device->hidden);