Page 1 of 1

key board handler in C

Posted: Sat Jul 26, 2008 11:35 pm
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);
}
}

Re: key board handler in C

Posted: Wed Jul 30, 2008 10:33 am
by Combuster
yikes.

1) fugly code layout, no comments.
2) exit() within an ISR
3) no scancode conversion

Re: key board handler in C

Posted: Fri Aug 15, 2008 3:31 pm
by mohammed
you are right
that's why i used while (1) with kbhit() and it worked
thank you