Keyboard handling in C

A

anon856525

Hi,

I'm trying to write a keyboard handle with Borland. I think the code
below should work, but it doesn't compile. The problem is I cannot set
the return of
getvect() to a void interrupt (*)(), ie

void interrupt (*old_int9)();

....

old_int9 = getvect (0x9);

I need a void interrupt function pointer so I can chain the old handle
to the new handle. Any help much appreciated. I'll attach the rest
of
the example program.


#include<stdlib.h>
#include<stdio.h>
#include<dos.h>
#include<conio.h>

#define TRUE 1
#define FALSE 0

void interrupt (*old_int9)();

void interrupt new_int9();

int scan_code,done = FALSE;

void interrupt new_int9()
{
disable();
scan_code = inport(0x60);
if (scan_code == 0x3b) done = TRUE; /* done = TRUE when F1 pressed */
old_int9(); /* chain the old interrupt */
enable();

}

void main ()
{
int old_scan_code;
char buffer[256];

clrscr();
old_int9 = getvect(0x9);
setvect (0x09,new_int9);

while (!done)
{ if (kbhit) getche();

}

setvect (0x09,old_int9);
}
 
U

user923005

Hi,

I'm trying to write a keyboard handle with Borland. I think the code
below should work, but it doesn't compile. The problem is I cannot set
the return of
getvect() to a void interrupt (*)(), ie
[snip]

You want
In the C-FAQ, section 19 is on "System Dependencies" like keyboard
interrupts, etc., but it won't really address your questions.
 
C

CBFalconer

I'm trying to write a keyboard handle with Borland. I think the
code below should work, but it doesn't compile. The problem is I
cannot set the return of getvect() to a void interrupt (*)(), ie

void interrupt (*old_int9)();

...

old_int9 = getvect (0x9);

I need a void interrupt function pointer so I can chain the old
handle to the new handle. Any help much appreciated. I'll
attach the rest of the example program.

Modern Winders won't allow you to do that. You need to try a DOS
newsgroup, or possibly W98 or W95.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,443
Members
47,089
Latest member
Bobby2025b

Latest Threads

Top