# HG changeset patch # User Sam Lantinga # Date 1147065430 0 # Node ID e28233f37f8c5a8a4251256aa2134025a5c1c46d # Parent 402d5ff1cf88aa41860d5ce686b148dca7646bae Fixed detection of current vt when not running as root. diff -r 402d5ff1cf88 -r e28233f37f8c src/video/fbcon/SDL_fbevents.c --- a/src/video/fbcon/SDL_fbevents.c Mon May 08 04:19:03 2006 +0000 +++ b/src/video/fbcon/SDL_fbevents.c Mon May 08 05:17:10 2006 +0000 @@ -55,6 +55,7 @@ #define GPM_NODE_FIFO "/dev/gpmdata" #endif +/*#define DEBUG_KEYBOARD*/ /*#define DEBUG_MOUSE*/ /* The translation tables from a console scancode to a SDL keysym */ @@ -281,8 +282,15 @@ } if ( keyboard_fd < 0 ) { /* Last resort, maybe our tty is a usable VT */ - current_vt = 0; + struct vt_stat vtstate; + keyboard_fd = open("/dev/tty", O_RDWR); + + if ( ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0 ) { + current_vt = vtstate.v_active; + } else { + current_vt = 0; + } } #ifdef DEBUG_KEYBOARD fprintf(stderr, "Current VT: %d\n", current_vt);