From owner-freebsd-ports-bugs Tue Feb 18 7:30:12 2003 Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8AFFF37B401 for ; Tue, 18 Feb 2003 07:30:07 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2C1EF43F75 for ; Tue, 18 Feb 2003 07:30:06 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h1IFU5NS089103 for ; Tue, 18 Feb 2003 07:30:06 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h1IFU52C089102; Tue, 18 Feb 2003 07:30:05 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0599737B401; Tue, 18 Feb 2003 07:27:33 -0800 (PST) Received: from grosbein.pp.ru (www2.svzserv.kemerovo.su [213.184.65.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id C6F5443FBD; Tue, 18 Feb 2003 07:27:21 -0800 (PST) (envelope-from eu@grosbein.pp.ru) Received: from grosbein.pp.ru (smmsp@localhost [127.0.0.1]) by grosbein.pp.ru (8.12.6/8.12.6) with ESMTP id h1IFLkYb001387; Tue, 18 Feb 2003 22:21:46 +0700 (KRAT) (envelope-from eu@grosbein.pp.ru) Received: (from root@localhost) by grosbein.pp.ru (8.12.6/8.12.6/Submit) id h1IF8kK5000611; Tue, 18 Feb 2003 22:08:46 +0700 (KRAT) Message-Id: <200302181508.h1IF8kK5000611@grosbein.pp.ru> Date: Tue, 18 Feb 2003 22:08:46 +0700 (KRAT) From: Eugene Grosbein To: FreeBSD-gnats-submit@FreeBSD.org Cc: sobomax@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/48426: [PATCH] digger-vgl does not support console switching Sender: owner-freebsd-ports-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 48426 >Category: ports >Synopsis: [PATCH] digger-vgl does not support console switching >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Feb 18 07:30:05 PST 2003 >Closed-Date: >Last-Modified: >Originator: Eugene Grosbein >Release: FreeBSD 4.7-STABLE i386 >Organization: N/A >Environment: System: FreeBSD grosbein.pp.ru 4.7-STABLE FreeBSD 4.7-STABLE #4: Sun Feb 9 13:34:37 KRAT 2003 eu@grosbein.pp.ru:/usr/local/obj/usr/local/src/sys/DADV i386 >Description: It is not possible to tune sound volume while playing digger-vgl from console and it's not possible to switch vty's to tune it manually. One cannot start digger-vgl, suspend it to do some work and go back to the game for the same reason. >How-To-Repeat: Run digger-vgl and try to use Alt-Fn to switch vty's, you will fail. >Fix: The next patch makes it possible to switch to one of ttyv0,...,ttyv9 using Alt-F1,...,Alt-F10. Game will pause automatically. One can go back to the game, unpause it using Space and contunue. I run it over a year and it seems to be very useful. I put it into the 'files/' directory. --- fbsd_kbd.c Fri Jul 6 17:58:17 2001 +++ fbsd_kbd.c Fri Jul 6 21:16:51 2001 @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include "def.h" @@ -20,6 +22,14 @@ 'a','s','d','f','g','h','j','k','l',';','\'','z','x',\ 'c','v','b','n','m',',','.','/',' '}; +#define F1KEY (59+128) +#define F10KEY (68+128) +#define LALTKEY (56+128) +#define RALTKEY (93+128) +#define altpressed (states[LALTKEY] || states[RALTKEY]) + +extern bool started, pausef; + void initkeyb(void) { VGLKeyboardInit(VGL_CODEKEYS); @@ -31,33 +41,80 @@ VGLKeyboardEnd(); } +bool UpdateStates(Sint4* result) +{ + Sint4 i; + bool isasymbol, state; + + if(*result < 128) + state = TRUE; + else { + state = FALSE; + *result -= 128; + } + + isasymbol = FALSE; + for(i=0;quertycodes[i]!=0;i++) + if(*result == quertycodes[i]) { + *result = chars[i]; + isasymbol = TRUE; + break; + } + + if (isasymbol == FALSE) + *result+=128; + + states[*result] = state; + return state; +} + void ProcessKbd(void) { - Sint4 result, i; - bool isasymbol; + Sint4 result; + static bool newconsf=FALSE; bool state; while((result = VGLKeyboardGetCh()) != 0) { - if(result < 128) - state = TRUE; - else { - state = FALSE; - result -= 128; - } + state=UpdateStates(&result); - isasymbol = FALSE; - for(i=0;quertycodes[i]!=0;i++) - if(result == quertycodes[i]) { - result = chars[i]; - isasymbol = TRUE; - break; + if(newconsf==TRUE && pausef==TRUE) /* return to game ? */ + if(state==FALSE) + continue; + else newconsf=FALSE; /* yes */ + + while(newconsf==FALSE && state==TRUE && + result>=F1KEY && result<=F10KEY && altpressed) { + /* Alt-Fn pressed to switch consoles */ + int activecons=0; + int newcons=result-F1KEY+1; + ioctl(0, VT_GETACTIVE, &activecons); + if(newcons==activecons) /* to another console ? */ + break; + + newconsf=TRUE; + /* do switch */ + ioctl(0,VT_ACTIVATE,(caddr_t)(long)newcons); + if(started==TRUE && pausef==FALSE) { + pausef=TRUE; + testpause(); /* force pause if game active */ + } + else { + VGLCheckSwitch(); /* game not active - just switch */ + /* now wait for another keyboard strike */ + result=VGLKeyboardGetCh(); + while(1) { + if(result!=0) { + state=UpdateStates(&result); + if(state==TRUE) /* ignore releases */ + break; + } + usleep(500); /* don't waste CPU when idle */ + result=VGLKeyboardGetCh(); } - - if (isasymbol == FALSE) - result+=128; - - states[result] = state; + } + newconsf=FALSE; /* switched back */ + } if(state == TRUE) continue; --- main.c Tue Apr 4 04:42:44 2000 +++ main.c Fri Jul 6 21:06:29 2001 @@ -561,7 +561,6 @@ { int i; if (pausef) { - pausef=FALSE; soundpause(); sett2val(40); setsoundt2(); @@ -575,6 +574,7 @@ drawlives(); if (!synchvid) curtime=gethrt(); + pausef=FALSE; } else soundpauseoff(); Eugene Grosbein >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports-bugs" in the body of the message