key board handler in C

Programming, for all ages and all languages.
Post Reply
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

key board handler in C

Post by mohammed »

hi all
i was trying to make an interrupt handler for the key board useing the functions setvect and getvect but it didn't work..is there any obvious mistake in my code ?
thanks in advance.

Code: Select all

#include <stdio.h>
#include <dos.h>
#define kbint  0x09
#define kbport 0x60
void (interrupt far *old_isr)();
void interrupt far kbhandler()
{
char kb = inport(kbport);
if (kb == 'x')
exit(1);
}
main()
{
old_isr = getvect(kbint);
setvect(kbint,kbhandler);
while(1)
{
printf("hello\n");
delay(10000000);
}
}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: key board handler in C

Post by Combuster »

yikes.

1) fugly code layout, no comments.
2) exit() within an ISR
3) no scancode conversion
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Re: key board handler in C

Post by mohammed »

you are right
that's why i used while (1) with kbhit() and it worked
thank you
Post Reply