Article View: fj.windows.x
Article #270Re: X server patch for Sun type 5 keyboard
From: Ryouji Hasegawa
Date: Sat, 19 Dec 1992 06:37
Date: Sat, 19 Dec 1992 06:37
214 lines
7224 bytes
7224 bytes
$@$3$s$K$A$O!#D9C+@n!w1~MQ%7%9%F%`It!%Cf1{EE;R$G$9!#(J
fj.sys.sun $@$K$b%/%m%9%]%9%H$7$^$9!#(JFollowup-To: fj.windows.x $@$G$9(J
> In article <KAZU.92Dec14184146@ribbon.csrd.nkk.co.JP> kazu@csrd.nkk.co.JP (Kazunari "ISSEY" Nakamura) writes:
>> Sun$@$N(JType5$@%-!<%\!<%I$,IU$$$?(JSparcStation$@$G(JX11R5$@$N(JMIT$@%5!<%P!<$rF0$+$9%Q%C(J
>> $@%A$H$$$&$N$O$I$3$+$KN.$l$J$+$C$?$G$7$g$&$+!)(J
> $@;d$N(J SS2 $@$O(J Type 5 $@$r(J Type 4 $@$HG'<1$7$F$7$^$C$F$$$k$N$GL5;vF0$$$F$$$^(J
> $@$9$M$(!#%-!<%^%C%W$OE,Ev$K(J xmodmap $@$GJQ$($F$$$^$9!#(J
$@;d$b!"(JType4 $@$K(JJLE$@$N$H$=$&$G$J$$$N$,$"$C$F!":.:_$7$F;HMQ$7$F$$$?$N$G(J
constype $@$N$h$&$K(J kbdtype $@$H$$$&%3%^%s%I$r:n$C$F(J
.xinitrc $@$NCf$G(J xmodmap $@$G@Z$jBX$($F$^$7$?!#(J
In article <BzBvKu.E8A@ntt-twins.ntt.jp>, takahiro@nttspe.ntt.jp (Takahiro Yamamoto2) writes:
> $@;d$N$H$3$m$G$O!"(JType5 $@$N(J UNIX $@7?$H(J US $@7?(J $@$OBg>fIW$J$s$G$9$,!"(J
> JLE$@7?$N%-!<%\!<%I$@$H!"(J!$@$H$+(J ^$@$H$+(J &$@$H$+$N5-9fF~NO$N(J
> $@$H$-!"%-!<%\!<%I$K0u:~$7$F$"$k5-9f$H$OJL$NJ8;z$,F~NO(J
> $@$5$l$F$7$^$$$^$9!#(J
> Type4$@$N%-!<%\!<%I$N$H$-$O(JJLE$@%-!<%\!<%I$G$bBg>fIW$G$7$?$,!"(J
> Type5$@$G$O$&$^$/$$$+$J$/$J$C$F$7$^$$$^$7$?!#(J
> $@$I$J$?$+!"BP=hK!$r$4B8CN$J$$$G$7$g$&$+!)(J
Type5 $@$N%-!<%\!<%I$b(J <sundev/kbd.h> $@$G$$$&=j$N(J KB_SUN4 $@$rJV$7$^$9!#(J
$@$=$l$G!"(JType4 $@$N(JJLE $@H=Dj$N$h$&$K(J KIOCLAYOUT $@$r8+$F(J (Type4 $@$N>l9g$3$l$O(J
$@%-!<%\!<%IFb$N%G%#%C%W%9%$%C%A$NCM$J$N$G$9$,(J)
0x21 $@0J>e$J$i(J Type5 $@$G$"$k$H$$$&$h$&$J;v$,(J comp.sys.sun.admin $@$K(J
$@=q$$$F$"$j$^$7$?!#(J
$@$3$A$i$K$O(J Type5 $@$,#1$D$7$+L5$$$N$G%F%9%H$G$-$J$$$N$G$9$,!"(J
$@$*$=$i$/(J KIOCLAYOUT $@$,(J UNIX $@7?(J,US$@7?(J,JLE$@7?(J $@$G0[$J$k$HM=A[$5$l$^$9!#(J
$@0J2<$K!"(Jkbdtype.c $@$N%=!<%9$r$D$1$^$9$N$G;n$7$F$_$F$O$$$+$+$G$7$g$&!)(J
cc kbdtype.c -o kbdtype $@$G%3%s%Q%$%k$7$F(J kbdtype -v $@$G>\:YI=<($7$^$9!#(J
------ $@$3$3$+$i(J -------- $@$3$3$+$i(J ------- $@$3$3$+$i(J ------------
/*
kbdtype : print keyboard type
*/
static char _VER_[] = "@(#)kbdtype Ver 1.02 by R.Hasegawa 92-12-17";
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sundev/kbio.h>
#include <sundev/kbd.h>
#ifndef KIOCLAYOUT
#define KIOCLAYOUT _IOR(k, 20, int)
struct kiockeymap {
int kio_tablemask; /* Translation table (one of: 0, CAPSMASK,
SHIFTMASK, CTRLMASK, UPMASK, ALTGRAPHMASK) */
u_char kio_station; /* Physical keyboard key station (0-127) */
u_short kio_entry; /* Translation table station's entry */
char kio_string[10]; /* Value for STRING entries (null terminated) */
};
#endif
#define ON 1
#define OFF 0
#define DIP_SW_4J 0x20 /* TYPE4 J */
#define DIP_SW_5 0x21 /* TYPE5 */
#ifndef KB_SUN4
#define KB_SUN4 0x04 /* Type 4 Sun keyboard */
#endif
/* Keyboard ID code = KB_SUN4, But KIOCLAYOUT >= 0x21 */
#ifndef KB_SUN4_T5
#define KB_SUN4_T5 0x05 /* Type 5 Sun keyboard */
#endif
/* Keyboard ID code = KB_SUN4, But KIOCLAYOUT = 0x20 */
#ifndef KB_SUN4J
#define KB_SUN4J 104 /* SunOS Type4 Japanese keyboard */
#endif
usage()
{
fprintf(stderr,"Usage: kbdtype [-v]\n");
fprintf(stderr,"\tKeyboard type\tverbose mode (-v)\t\tReturn val\n");
fprintf(stderr,"\t-------------\t-------------------------\t----------\n");
fprintf(stderr,"\tMS103\t\tMicro Switch 103SD32-2\t\t0\n");
fprintf(stderr,"\tVT100\t\tVT100 compatibl\t\t\t1\n");
fprintf(stderr,"\t2\t\tSun-2 Keyboard\t\t\t2\n");
fprintf(stderr,"\t3\t\tType 3 Keyboard\t\t\t3\n");
fprintf(stderr,"\t4\t\tType 4 Keyboard\t\t\t4\n");
fprintf(stderr,"\t4J\t\tType 4 Japanese Keyboard\t104\n");
fprintf(stderr,"\t5\t\tType 5 Keyboard\t\t\t5\n");
fprintf(stderr,"\tASCII\t\tASCII Terminal\t\t\t15\n");
fprintf(stderr,"\tUNKNOWN\t\tUnknown Type\t\t\tother\n");
exit(-1);
}
main(argc,argv)
int argc;
char *argv[];
{
int kbd_fd;
int get_key_type, key_type;
int dip_sw;
int verb = OFF;
struct kiockeymap key;
if( argc < 2 ){
verb = OFF;
}else{
if( argv[1][0]=='-' && argv[1][1]=='v' )
verb = ON;
else
usage();
}
if( ( kbd_fd = open("/dev/kbd",O_RDONLY) ) == NULL ){
fprintf(stderr,"Can not open /dev/kbd\n");
exit(1);
}
ioctl(kbd_fd, KIOCTYPE, &get_key_type);
key_type = get_key_type;
if( ioctl(kbd_fd, KIOCLAYOUT, &dip_sw) < 0 ){
/* SunOS 4.0.X */
if (key_type == KB_SUN3) {
struct kiockey key;
key.kio_tablemask = 0;
key.kio_station = 118;
if (ioctl(kbd_fd, KIOCGETKEY, &key)) {
perror( "ioctl KIOCGETKEY" );
exit(-1);
}
if (key.kio_entry != 0xa2) {
key_type = KB_SUN4;
}
}
}else{
/* SunOS 4.1.X */
if (key_type == KB_SUN4){
if( dip_sw == DIP_SW_4J ){
key_type = KB_SUN4J;
}else
if( dip_sw >= DIP_SW_5 ){
key_type = KB_SUN4_T5;
}
}
}
if( verb == ON ){
switch(key_type){
case KB_KLUNK:
printf("Micro Switch 103SD32-2\n");
break;
case KB_VT100:
printf("VT100 compatible\n");
break;
case KB_SUN2:
printf("Sun-2 Keyboard\n");
break;
case KB_SUN3:
printf("Type 3 Keyboard\n");
break;
case KB_SUN4:
printf("Type 4 Keyboard ");
printf("Layout = %xH\n",dip_sw);
break;
case KB_SUN4J:
printf("Type 4 Japanese Keyboard\n");
printf("Layout = %xH\n",dip_sw);
break;
case KB_SUN4_T5:
printf("Type 5 Keyboard ");
printf("key_type = %d ",get_key_type);
printf("Layout = %xH\n",dip_sw);
break;
case KB_ASCII:
printf("ASCII Terminal\n");
break;
default:
printf("Unknown Type\n");
break;
}
}else{
switch(key_type){
case KB_KLUNK:
printf("MS103\n"); break;
case KB_VT100:
printf("VT100\n"); break;
case KB_SUN2:
printf("2\n"); break;
case KB_SUN3:
printf("3\n"); break;
case KB_SUN4:
printf("4\n"); break;
case KB_SUN4J:
printf("4J\n"); break;
case KB_SUN4_T5:
printf("5\n"); break;
case KB_ASCII:
printf("ASCII\n"); break;
default:
printf("UNKNOWN\n"); break;
}
}
close(kbd_fd);
exit(key_type);
}
------ $@$3$3$^$G(J -------- $@$3$3$^$G(J ------- $@$3$3$^$G(J ------------
--
-----------------------------------------------------------------------
$@Cf1{EE;R3t<02q<R(J $@1~MQ%7%9%F%`;v6HIt(J $@D9C+@n5};J(J (hasegawa@cec.co.jp)
-----------------------------------------------------------------------
Technical Details
Message-ID:
<2532@cecgw.cec.co.jp>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sgiblab!nec-gw!nec-tyo!wnoc-tyo-news!sranha!cecgw!hasegawaReferences:
<KAZU.92Dec14184146@ribbon.csrd.nkk.co.JP> <BzBvKu.E8A@ntt-twins.ntt.jp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sgiblab!nec-gw!nec-tyo!wnoc-tyo-news!sranha!cecgw!hasegawa From: hasegawa@cec.co.jp (Ryouji Hasegawa) Newsgroups: fj.windows.x,fj.sys.sun Subject: Re: X server patch for Sun type 5 keyboard Message-ID: <2532@cecgw.cec.co.jp> Date: 19 Dec 92 06:37:47 GMT References: <KAZU.92Dec14184146@ribbon.csrd.nkk.co.JP> <BzBvKu.E8A@ntt-twins.ntt.jp> Sender: news@cec.co.jp Followup-To: fj.windows.x Distribution: fj Organization: Chuo Electronics Co., Ltd. Tokyo, Japan. Lines: 214 Nntp-Posting-Host: kei.cec.co.jp