Fixed detection of current vt when not running as root.
authorSam Lantinga <slouken@libsdl.org>
Mon, 08 May 2006 05:17:10 +0000
changeset 1778e28233f37f8c
parent 1777 402d5ff1cf88
child 1779 67fc81efcfc3
Fixed detection of current vt when not running as root.
src/video/fbcon/SDL_fbevents.c
     1.1 --- a/src/video/fbcon/SDL_fbevents.c	Mon May 08 04:19:03 2006 +0000
     1.2 +++ b/src/video/fbcon/SDL_fbevents.c	Mon May 08 05:17:10 2006 +0000
     1.3 @@ -55,6 +55,7 @@
     1.4  #define GPM_NODE_FIFO	"/dev/gpmdata"
     1.5  #endif
     1.6  
     1.7 +/*#define DEBUG_KEYBOARD*/
     1.8  /*#define DEBUG_MOUSE*/
     1.9  
    1.10  /* The translation tables from a console scancode to a SDL keysym */
    1.11 @@ -281,8 +282,15 @@
    1.12  		}
    1.13   		if ( keyboard_fd < 0 ) {
    1.14  			/* Last resort, maybe our tty is a usable VT */
    1.15 -			current_vt = 0;
    1.16 +			struct vt_stat vtstate;
    1.17 +
    1.18  			keyboard_fd = open("/dev/tty", O_RDWR);
    1.19 +
    1.20 +			if ( ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0 ) {
    1.21 +				current_vt = vtstate.v_active;
    1.22 +			} else {
    1.23 +				current_vt = 0;
    1.24 +			}
    1.25   		}
    1.26  #ifdef DEBUG_KEYBOARD
    1.27  		fprintf(stderr, "Current VT: %d\n", current_vt);