GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Sep-2003, 10:30
Ilya Ilya is offline
Invalid Email Address
 
Join Date: Sep 2003
Location: Saransk, Russia
Posts: 2
Ilya is an unknown quantity at this point

Keys pressing procceding


Tell me please how to in C under DOS make proceeded not only single key pressing but specualy trace situation when a moving cursor key is pressed and beeing hold.

I've tryed it by the interruption but the following program hangs:
CPP / C++ / C Code:
#include <stdio.h>
#include <dos.h>
#include <conio.h>

#define INTR 0X09

#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif


void interrupt far ( *oldhandler)(__CPPARGS);

void interrupt far handler(__CPPARGS)
{
int pcode, updown, keycode;
outportb (0x20,0x20);
pcode = inportb (0x64);
updown = pcode & 0x80; - нажатие, 0x80 - отпускание
keycode = pcode & 0x7F;

/* call the old routine */
oldhandler();
if (updown == 0)
printf ("Key pressed");
else
printf ("Key unpressed");
}


int main(void)
{
/* save the old interrupt vector */
oldhandler = getvect(INTR);

/* install the new interrupt handler */
setvect(INTR, handler);
while (getch()!=27);
setvect(INTR, oldhandler);
}
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:30.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.