Article View: comp.sys.atari.st
Article #28964Re: Keyboard questions?
From: Martin Minow
Date: Thu, 29 Oct 1987 01:41
Date: Thu, 29 Oct 1987 01:41
65 lines
2190 bytes
2190 bytes
In article <1516@wiley.UUCP>, Bob Amstadt asks how to read the shift,
control, and alt keys.
Here is a fragment from a much larger program that shows how you
can get this information. I have no idea how to do this using
the evnt_...(); routines.
Martin Minow
decvax!minow
The following software is in the public domain. It is incomplete
as it stands and intended only as an illustration.
/*
* The keytable structure is is returned by Keytbl(). It "points"
* to the keyboard translation tables in the operating system.
*/
typedef struct {
char *unshifted;
char *shifted;
char *capslock;
} KEYTBL;
#define RIGHTSHIFT 0x01
#define LEFTSHIFT 0x02
#define CTRLSHIFT 0x04
#define ALTSHIFT 0x08
#define CAPSSHIFT 0x10
KEYTBL *keytbl;
main()
{
...
keytbl = Keytbl(-1L, -1L, -1L); /* keyboard translation table */
...
}
int
read_keyboard()
{
register long rawkey;
register int scancode;
register int c; /* Translated key code */
register int shift;
rawkey = Bconin(2); /* Get char from kb: */
scancode = (rawkey >> 16) & 0xFF; /* Raw keyboard code. */
shift = Getshift(-1); /* Need the ALT key */
if (scancode >= 0x78
&& scancode <= 0x83) /* Normalize strange */
scancode -= (0x78 - 0x02); /* "ALT" + digit */
if ((c = rawkey & 0xFF) == 0) { /* ALT compose? */
if ((shift & (RIGHTSHIFT | LEFTSHIFT)) != 0)
c = keytbl->shifted[scancode];
else if ((shift & CAPSSHIFT) != 0)
c = keytbl->capslock[scancode];
else {
c = keytbl->unshifted[scancode];
}
if ((shift & CTRLSHIFT) != 0)
c &= 0x1F;
}
return (c);
}
Technical Details
Message-ID:
<177@decvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!minowReferences:
<1516@wiley.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!minow From: minow@decvax.UUCP (Martin Minow) Newsgroups: comp.sys.atari.st Subject: Re: Keyboard questions? Message-ID: <177@decvax.UUCP> Date: Wed, 28-Oct-87 20:41:15 EST Article-I.D.: decvax.177 Posted: Wed Oct 28 20:41:15 1987 Date-Received: Sat, 31-Oct-87 14:36:25 EST References: <1516@wiley.UUCP> Reply-To: minow@decvax.UUCP (Martin Minow) Organization: Digital Eq. Corp. - Merrimack NH. Lines: 65