Article View: comp.sys.sun
Article #11162Re: Dvorak keyboard software on a Sun (source included)
From: Alan Dewar
Date: Tue, 28 Feb 1989 10:46
Date: Tue, 28 Feb 1989 10:46
218 lines
8547 bytes
8547 bytes
In article <890201-093010-10574@Xerox>, SBartlett.OsbuSouth@xerox.com writes:
> Does anyone out there in net-land know of a way I can configure a Sun to
> treat its standard keyboard as having a Dvorak layout?
I put together a Dvorak keyboard for the Sun 3 some time ago, mostly just
to see if it could be done. What I wrote was actually a little more
general than that--it can be used to set any keyboard mapping you like.
The user interface is somewhat unfriendly, I'm afraid. You have to edit
binary files by hand if you want anything new. (I started with the
standard QWERTY mapping, obtained by my "getkbd.c", and edited it to get a
Dvorak layout.) In any event, it works, and I did get a Dvorak keyboard.
Any enhancements to the programs would be welcome.
The following programs, getkbd.c and setkbd.c, respectively get and set
the keyboard mapping, writing to stdout or reading from stdin. Two
mappings (uuencoded) are also included: qwerty.kbd and dvorak.kbd.
Alan Dewar Computer Science Dept. University of Calgary
dewar@cpsc.UCalgary.CA ..!alberta!calgary!dewar
- - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - -
/* getkbd.c */
/* write the current Sun 3 keyboard layout to stdout (for setkbd) */
/* */
/* Written: 88-04-20 Alan Dewar (dewar@cpsc.UCalgary.CA) */
#include <stdio.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sundev/kbd.h>
#include <sys/types.h>
#include <sundev/kbio.h>
static int TABLEMASKS[] = {0, CAPSMASK, SHIFTMASK, CTRLMASK, UPMASK};
#define NMASKS ( sizeof(TABLEMASKS) / sizeof(int) )
main ()
{
int fd;
struct kbd_data {
struct keyboard kbd;
struct keymap map[NMASKS];
char string[16][KTAB_STRLEN];
} data;
struct kiockey key;
int mask, station;
int m, n;
int err;
fd = open ("/dev/kbd", O_RDWR);
if (fd < 0) {
fprintf (stderr, "Cannot open /dev/kbd\n");
exit (-1);
}
for (m = 0; m < 16; m++) {
for (n = 0; n < KTAB_STRLEN; n++) {
data.string[m][n] = '\0';
}
}
for (mask = 0; mask < NMASKS; mask++) {
((struct keymap **)(&data.kbd))[mask] = &data.map[mask];
key.kio_tablemask = TABLEMASKS[mask];
for (station = 0; station < 128; station++) {
key.kio_station = station;
err = ioctl (fd, KIOCGETKEY, &key);
if (err != 0) {
fprintf ("Error %d encountered\n", err);
}
data.map[mask].keymap[station] = key.kio_entry;
if (key.kio_entry >= STRING && key.kio_entry < STRING+16) {
m = key.kio_entry & 0x0F;
for (n = 0; n < KTAB_STRLEN; n++) {
data.string[m][n] = key.kio_string[n];
}
}
}
}
key.kio_tablemask = -1;
err = ioctl (fd, KIOCGETKEY, &key);
if (err != 0) {
fprintf ("Error %d encountered\n", err);
}
data.kbd.k_abort1 = key.kio_station;
key.kio_tablemask = -2;
err = ioctl (fd, KIOCGETKEY, &key);
if (err != 0) {
fprintf ("Error %d encountered\n", err);
}
data.kbd.k_abort2 = key.kio_station;
for (mask = 0; mask < NMASKS; mask++) {
(long) (((struct keymap **)(&data.kbd))[mask]) =
(char *) (((struct keymap **)(&data.kbd))[mask])
- (char *) (&data);
}
fwrite (&data, sizeof(data), 1, stdout);
}
- - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - -
/* setkbd.c */
/* set the Sun 3 keyboard layout as specified by stdin (from getkbd) */
/* */
/* Written: 88-04-20 Alan Dewar (dewar@cpsc.UCalgary.CA) */
#include <stdio.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sundev/kbd.h>
#include <sys/types.h>
#include <sundev/kbio.h>
static int TABLEMASKS[] = {0, CAPSMASK, SHIFTMASK, CTRLMASK, UPMASK};
#define NMASKS ( sizeof(TABLEMASKS) / sizeof(int) )
main ()
{
int fd;
struct kbd_data {
struct keyboard kbd;
struct keymap map[NMASKS];
char string[16][KTAB_STRLEN];
} data;
struct kiockey key;
int mask, station;
int m, n;
int err;
fd = open ("/dev/kbd", O_RDWR);
if (fd < 0) {
fprintf (stderr, "Cannot open /dev/kbd\n");
exit (-1);
}
if (fread (&data, sizeof(data), 1, stdin) != 1) {
fprintf (stderr, "Cannot read keyboard data\n");
exit (-2);
}
for (mask = 0; mask < NMASKS; mask++) {
(char *) (((struct keymap **)(&data.kbd))[mask]) =
(char *) (&data)
+ (long) (((struct keymap **)(&data.kbd))[mask]);
}
for (mask = 0; mask < NMASKS; mask++) {
key.kio_tablemask = TABLEMASKS[mask];
for (station = 0; station < 128; station++) {
key.kio_station = station;
key.kio_entry = data.map[mask].keymap[station];
if (key.kio_entry >= STRING && key.kio_entry < STRING+16) {
m = key.kio_entry & 0x0F;
for (n = 0; n < KTAB_STRLEN; n++) {
key.kio_string[n] = data.string[m][n];
}
}
err = ioctl (fd, KIOCSETKEY, &key);
if (err != 0) {
fprintf ("Error %d encountered\n", err);
}
}
}
key.kio_tablemask = -1;
key.kio_station = data.kbd.k_abort1;
err = ioctl (fd, KIOCSETKEY, &key);
if (err != 0) {
fprintf ("Error %d encountered\n", err);
}
key.kio_tablemask = -2;
key.kio_station = data.kbd.k_abort2;
err = ioctl (fd, KIOCSETKEY, &key);
if (err != 0) {
fprintf ("Error %d encountered\n", err);
}
}
- - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - -
begin 644 qwerty.kbd
M (@ *( $B !H@ B( %- **1HL&BX.&BXJ+C
MHN2BY:+FY^@&HM#1TJ+"PZ*B&S$R,S0U-C<X.3 M/6 (HM/4U:+$HL6B"7%W
M97)T>75I;W!;77^BUK'8HL;'S:*$87-D9F=H:FML.R=<#:*SVK2BR,[)HH)Z
M>&-V8FYM+"XO@PK<LMZBHJ*B@) @D**BHJ>HHI&BP:+@X:+BHN.BY*+EHN;G
MZ :BT-'2HL+#HJ(;,3(S-#4V-S@Y,"T]8 BBT]35HL2BQ:()45=%4E1954E/
M4%M=?Z+6L=BBQL>BHH1!4T1&1TA*2TP[)UP-HK/:M*+(SLFB@EI80U9"3DTL
M+B^#"MRRWJ*BHJ* D""0HJ*BIZBBD:+!HN#AHN*BXZ+DHN6BYN?H!J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+%H@D_/#Y0649'0U),(BM_HM:Q
MV*+&QZ*BA$%/155)1$A43E-?? VBL]JTHLC.R:*".E%*2UA"35=66H,*W++>
MHJ*BHH"0()"BHJ*GJ**1HL&BX.&BXJ+CHN2BY:+FY^@&HM#1TJ+"PZ*B&S$
M,S0U'C<X.3 ;'1X(HM/4U:+$HL6B"1\L+A 9!@<#$@PG/7^BUK'8HL;'HJ*$
M 0\%%0D$"!0.$Q\<#:*SVK2BR,[)HH([$0H+& (-%Q8:@PK<LMZBHJ*B@)
MD**BHJ>HHI&BH:*AH:*AHJ&BH:*AHJ&AH:&BH:&@HJ&AHJ*@H*"@H*"@H*"@
MH*"@H*"BH:&@HJ&BH:*@H*"@H*"@H*"@H*"@H**AH:"BH:&BHH2@H*"@H*"@
MH*"@H*"@HJ&AH**AH:&B@J"@H*"@H*"@H*"#H*&AH**BHJ*@D*"0HJ*BHJ8
M &UM! !M;0@ ;6T0 &UM#
M
M
8
end
- - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - -
Technical Details
Message-ID:
<720@cs-spool.calgary.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-requestReferences:
<890201-093010-10574@Xerox>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: dewar@cpsc.ucalgary.ca (Alan Dewar) Newsgroups: comp.sys.sun Subject: Re: Dvorak keyboard software on a Sun (source included) Message-ID: <720@cs-spool.calgary.UUCP> Date: 28 Feb 89 10:46:15 GMT References: <890201-093010-10574@Xerox> Sender: usenet@rice.edu Organization: Sun-Spots Lines: 218 Approved: Sun-Spots@rice.edu Original-Date: Wed, 15 Feb 89 14:49:05 EST X-Sun-Spots-Digest: Volume 7, Issue 171, message 9 of 9