From 835f3e570b4d56a0735d162cf2fd82215f1d00e4 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 8 May 2006 05:17:10 +0000 Subject: [PATCH] Fixed detection of current vt when not running as root. --- src/video/fbcon/SDL_fbevents.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/video/fbcon/SDL_fbevents.c b/src/video/fbcon/SDL_fbevents.c index 8ffe67069..a3985665a 100644 --- a/src/video/fbcon/SDL_fbevents.c +++ b/src/video/fbcon/SDL_fbevents.c @@ -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 @@ int FB_OpenKeyboard(_THIS) } 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);