Date: Fri, 14 Apr 2000 19:52:53 +0300 From: Anatoly Vorobey <mellon@pobox.com> To: Daniel O'Connor <doconnor@gsoft.com.au> Cc: hackers@freebsd.org, imp@village.org Subject: Re: PC Keyboard Scancodes Message-ID: <20000414195253.41151@techunix.technion.ac.il>
next in thread | raw e-mail | index | archive | help
> I will see if I can try what Anatoly suggests.. :) Use this simple prog to cough up the scancodes: #include <stdio.h> #include <sys/kbio.h> #include <sys/ioctl.h> #include <fcntl.h> #include <termios.h> void die(char *str) { perror(str); exit(0); } int main(void) { int err, mode; struct termios term_saved, term; int i; char ch; err = tcgetattr(0,&term); if(err==-1) die("tcgetattr"); term_saved = term; cfmakeraw(&term); err = ioctl(0,KDGKBMODE, &mode); if(err==-1) die("getkbdmode"); else printf("current kb mode: %d\n", mode); err = ioctl(0,KDSKBMODE, K_RAW); if(err==-1) die("setkbmode"); else printf("K_RAW mode set\n"); printf("Press Esc to end.\n"); err = tcsetattr(0,TCSANOW,&term); /* set terminal to raw */ if(err==-1) die("tcsetattr"); for(i=0; i<1000; i++) { err=read(0,&ch,1); if(err!=1) break; printf("%d ",ch); fflush(stdout); if(ch==1) break; /* break on Escape */ } err = tcsetattr(0,TCSANOW,&term_saved); if(err==-1) die("tcsetattr"); err = ioctl(0,KDSKBMODE,mode); if(err==-1) die("setkbmode"); else printf("\nkb mode restored\n"); } -- Anatoly Vorobey, mellon@pobox.com http://pobox.com/~mellon/ "Angels can fly because they take themselves lightly" - G.K.Chesterton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000414195253.41151>