Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!husc6!genrad!decvax!virgin!bann From: bann@virgin.UUCP (Roger Bannister) Newsgroups: comp.unix.questions Subject: An ioctl question Message-ID: <2582@virgin.UUCP> Date: 25 Oct 89 21:18:08 GMT Reply-To: bann@virgin.UUCP (Roger Bannister) Distribution: na Organization: Virgin Software, Ltd., Nashua, NH. Lines: 62 I modified this progam that I found in a book so that prints out the hex code of each key. I noticed that the keypad was producing the same scan codes as the regular keys. Is there a way to get the keypad to give different scan code like curses. Roger ---------------------Program Starts here ---------------------------------- #include #include #include #include #include #include #define CLRSCR printf("\033[2J") struct termio OLD, NEW; int Keyfile; InitKeyboard() { Keyfile = open("/dev/tty",O_RDONLY); if (Keyfile < 0) { printf("Unable to open /dev/tty\n"); exit(1); } ioctl(Keyfile, TCGETA, &OLD); } SetRead() { NEW.c_lflag &= ~ICANON; NEW.c_lflag &= ~ECHO; NEW.c_cc[VMIN] = 1; NEW.c_cc[VTIME] = 0; ioctl(Keyfile, TCSETA, &NEW); } /******************* Start of Main Program ********************/ main() { int Bytes; int Buffer[2]; /*run_expire(); */ InitKeyboard(); do { SetRead(); Bytes = read( Keyfile, Buffer, 1 ); ioctl(Keyfile, TCSETA, &OLD); printf( "Read char %x\n", (short) Buffer[0] ); } while ( Buffer[0] != 'Z' ); }