Add a new keyboard mode K_CODE. Returns a single byte for each key

much like the scancode mode.
However the keys that (for no good reason) returns extension codes
etc, are translated into singlebyte codes.
Needed by libvgl.  This makes life ALOT easier, also the XFree86
folks could use this.
This commit is contained in:
Søren Schmidt 1997-10-01 20:46:29 +00:00
parent 62a9dc968b
commit 3bd724f2b3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30043
8 changed files with 79 additions and 41 deletions

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: console.h,v 1.30 1997/08/08 22:52:25 sos Exp $
* $Id: console.h,v 1.31 1997/09/04 09:05:17 kato Exp $
*/
#ifndef _MACHINE_CONSOLE_H_
@ -153,6 +153,7 @@ struct mouse_info {
#define K_RAW 0 /* keyboard returns scancodes */
#define K_XLATE 1 /* keyboard returns ascii */
#define K_CODE 2 /* keyboard returns keycodes */
#define KB_84 1 /* 'old' 84 key AT-keyboard */
#define KB_101 2 /* MF-101 or MF-102 keyboard */

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.232 1997/09/14 03:19:27 peter Exp $
* $Id: syscons.c,v 1.233 1997/09/26 15:27:55 itojun Exp $
*/
#include "sc.h"
@ -1408,13 +1408,19 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case KDSKBMODE: /* set keyboard mode */
switch (*data) {
case K_RAW: /* switch to RAW scancode mode */
scp->status &= ~KBD_CODE_MODE;
scp->status |= KBD_RAW_MODE;
return 0;
case K_CODE: /* switch to CODE mode */
scp->status &= ~KBD_RAW_MODE;
scp->status |= KBD_CODE_MODE;
return 0;
case K_XLATE: /* switch to XLT ascii mode */
if (scp == cur_console && scp->status & KBD_RAW_MODE)
shfts = ctls = alts = agrs = metas = 0;
scp->status &= ~KBD_RAW_MODE;
scp->status &= ~(KBD_RAW_MODE | KBD_CODE_MODE);
return 0;
default:
return EINVAL;
@ -1422,7 +1428,8 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
/* NOT REACHED */
case KDGKBMODE: /* get keyboard mode */
*data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE;
*data = (scp->status & KBD_RAW_MODE) ? K_RAW :
((scp->status & KBD_CODE_MODE) ? K_CODE : K_XLATE);
return 0;
case KDMKTONE: /* sound the bell */
@ -1992,7 +1999,8 @@ exchange_scr(void)
set_destructive_cursor(new_scp);
if ((old_scp->status & UNKNOWN_MODE) && crtc_vga)
load_palette(palette);
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE ||
old_scp->status & KBD_CODE_MODE || new_scp->status & KBD_CODE_MODE)
shfts = ctls = alts = agrs = metas = 0;
update_leds(new_scp->status);
delayed_next_scr = FALSE;
@ -3026,6 +3034,9 @@ next_code:
break;
}
if (cur_console->status & KBD_CODE_MODE)
return (keycode | (scancode & 0x80));
/* if scroll-lock pressed allow history browsing */
if (cur_console->history && cur_console->status & SLKED) {
int i;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.h,v 1.32 1997/08/25 23:21:55 bde Exp $
* $Id: syscons.h,v 1.33 1997/09/04 23:01:06 yokota Exp $
*/
#ifndef _I386_ISA_SYSCONS_H_
@ -56,14 +56,15 @@
#define LED_MASK 0x00007
#define UNKNOWN_MODE 0x00010
#define KBD_RAW_MODE 0x00020
#define SWITCH_WAIT_REL 0x00040
#define SWITCH_WAIT_ACQ 0x00080
#define BUFFER_SAVED 0x00100
#define CURSOR_ENABLED 0x00200
#define MOUSE_ENABLED 0x00400
#define MOUSE_MOVED 0x00800
#define MOUSE_CUTTING 0x01000
#define MOUSE_VISIBLE 0x02000
#define KBD_CODE_MODE 0x00040
#define SWITCH_WAIT_REL 0x00080
#define SWITCH_WAIT_ACQ 0x00100
#define BUFFER_SAVED 0x00200
#define CURSOR_ENABLED 0x00400
#define MOUSE_ENABLED 0x00800
#define MOUSE_MOVED 0x01000
#define MOUSE_CUTTING 0x02000
#define MOUSE_VISIBLE 0x04000
/* configuration flags */
#define VISUAL_BELL 0x00001

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: console.h,v 1.30 1997/08/08 22:52:25 sos Exp $
* $Id: console.h,v 1.31 1997/09/04 09:05:17 kato Exp $
*/
#ifndef _MACHINE_CONSOLE_H_
@ -153,6 +153,7 @@ struct mouse_info {
#define K_RAW 0 /* keyboard returns scancodes */
#define K_XLATE 1 /* keyboard returns ascii */
#define K_CODE 2 /* keyboard returns keycodes */
#define KB_84 1 /* 'old' 84 key AT-keyboard */
#define KB_101 2 /* MF-101 or MF-102 keyboard */

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.232 1997/09/14 03:19:27 peter Exp $
* $Id: syscons.c,v 1.233 1997/09/26 15:27:55 itojun Exp $
*/
#include "sc.h"
@ -1408,13 +1408,19 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case KDSKBMODE: /* set keyboard mode */
switch (*data) {
case K_RAW: /* switch to RAW scancode mode */
scp->status &= ~KBD_CODE_MODE;
scp->status |= KBD_RAW_MODE;
return 0;
case K_CODE: /* switch to CODE mode */
scp->status &= ~KBD_RAW_MODE;
scp->status |= KBD_CODE_MODE;
return 0;
case K_XLATE: /* switch to XLT ascii mode */
if (scp == cur_console && scp->status & KBD_RAW_MODE)
shfts = ctls = alts = agrs = metas = 0;
scp->status &= ~KBD_RAW_MODE;
scp->status &= ~(KBD_RAW_MODE | KBD_CODE_MODE);
return 0;
default:
return EINVAL;
@ -1422,7 +1428,8 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
/* NOT REACHED */
case KDGKBMODE: /* get keyboard mode */
*data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE;
*data = (scp->status & KBD_RAW_MODE) ? K_RAW :
((scp->status & KBD_CODE_MODE) ? K_CODE : K_XLATE);
return 0;
case KDMKTONE: /* sound the bell */
@ -1992,7 +1999,8 @@ exchange_scr(void)
set_destructive_cursor(new_scp);
if ((old_scp->status & UNKNOWN_MODE) && crtc_vga)
load_palette(palette);
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE ||
old_scp->status & KBD_CODE_MODE || new_scp->status & KBD_CODE_MODE)
shfts = ctls = alts = agrs = metas = 0;
update_leds(new_scp->status);
delayed_next_scr = FALSE;
@ -3026,6 +3034,9 @@ next_code:
break;
}
if (cur_console->status & KBD_CODE_MODE)
return (keycode | (scancode & 0x80));
/* if scroll-lock pressed allow history browsing */
if (cur_console->history && cur_console->status & SLKED) {
int i;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.h,v 1.32 1997/08/25 23:21:55 bde Exp $
* $Id: syscons.h,v 1.33 1997/09/04 23:01:06 yokota Exp $
*/
#ifndef _I386_ISA_SYSCONS_H_
@ -56,14 +56,15 @@
#define LED_MASK 0x00007
#define UNKNOWN_MODE 0x00010
#define KBD_RAW_MODE 0x00020
#define SWITCH_WAIT_REL 0x00040
#define SWITCH_WAIT_ACQ 0x00080
#define BUFFER_SAVED 0x00100
#define CURSOR_ENABLED 0x00200
#define MOUSE_ENABLED 0x00400
#define MOUSE_MOVED 0x00800
#define MOUSE_CUTTING 0x01000
#define MOUSE_VISIBLE 0x02000
#define KBD_CODE_MODE 0x00040
#define SWITCH_WAIT_REL 0x00080
#define SWITCH_WAIT_ACQ 0x00100
#define BUFFER_SAVED 0x00200
#define CURSOR_ENABLED 0x00400
#define MOUSE_ENABLED 0x00800
#define MOUSE_MOVED 0x01000
#define MOUSE_CUTTING 0x02000
#define MOUSE_VISIBLE 0x04000
/* configuration flags */
#define VISUAL_BELL 0x00001

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.232 1997/09/14 03:19:27 peter Exp $
* $Id: syscons.c,v 1.233 1997/09/26 15:27:55 itojun Exp $
*/
#include "sc.h"
@ -1408,13 +1408,19 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case KDSKBMODE: /* set keyboard mode */
switch (*data) {
case K_RAW: /* switch to RAW scancode mode */
scp->status &= ~KBD_CODE_MODE;
scp->status |= KBD_RAW_MODE;
return 0;
case K_CODE: /* switch to CODE mode */
scp->status &= ~KBD_RAW_MODE;
scp->status |= KBD_CODE_MODE;
return 0;
case K_XLATE: /* switch to XLT ascii mode */
if (scp == cur_console && scp->status & KBD_RAW_MODE)
shfts = ctls = alts = agrs = metas = 0;
scp->status &= ~KBD_RAW_MODE;
scp->status &= ~(KBD_RAW_MODE | KBD_CODE_MODE);
return 0;
default:
return EINVAL;
@ -1422,7 +1428,8 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
/* NOT REACHED */
case KDGKBMODE: /* get keyboard mode */
*data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE;
*data = (scp->status & KBD_RAW_MODE) ? K_RAW :
((scp->status & KBD_CODE_MODE) ? K_CODE : K_XLATE);
return 0;
case KDMKTONE: /* sound the bell */
@ -1992,7 +1999,8 @@ exchange_scr(void)
set_destructive_cursor(new_scp);
if ((old_scp->status & UNKNOWN_MODE) && crtc_vga)
load_palette(palette);
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE)
if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE ||
old_scp->status & KBD_CODE_MODE || new_scp->status & KBD_CODE_MODE)
shfts = ctls = alts = agrs = metas = 0;
update_leds(new_scp->status);
delayed_next_scr = FALSE;
@ -3026,6 +3034,9 @@ next_code:
break;
}
if (cur_console->status & KBD_CODE_MODE)
return (keycode | (scancode & 0x80));
/* if scroll-lock pressed allow history browsing */
if (cur_console->history && cur_console->status & SLKED) {
int i;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.h,v 1.32 1997/08/25 23:21:55 bde Exp $
* $Id: syscons.h,v 1.33 1997/09/04 23:01:06 yokota Exp $
*/
#ifndef _I386_ISA_SYSCONS_H_
@ -56,14 +56,15 @@
#define LED_MASK 0x00007
#define UNKNOWN_MODE 0x00010
#define KBD_RAW_MODE 0x00020
#define SWITCH_WAIT_REL 0x00040
#define SWITCH_WAIT_ACQ 0x00080
#define BUFFER_SAVED 0x00100
#define CURSOR_ENABLED 0x00200
#define MOUSE_ENABLED 0x00400
#define MOUSE_MOVED 0x00800
#define MOUSE_CUTTING 0x01000
#define MOUSE_VISIBLE 0x02000
#define KBD_CODE_MODE 0x00040
#define SWITCH_WAIT_REL 0x00080
#define SWITCH_WAIT_ACQ 0x00100
#define BUFFER_SAVED 0x00200
#define CURSOR_ENABLED 0x00400
#define MOUSE_ENABLED 0x00800
#define MOUSE_MOVED 0x01000
#define MOUSE_CUTTING 0x02000
#define MOUSE_VISIBLE 0x04000
/* configuration flags */
#define VISUAL_BELL 0x00001