www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/06/09:52:28

Date: Tue, 6 Jun 2000 19:05:06 +0530 (IST)
Message-Id: <200006061335.TAA29025@bgl2.vsnl.net.in>
From: Prashant TR <prashant_tr AT yahoo DOT com>
To: ryan4600 AT my-deja DOT com
CC: djgpp AT delorie DOT com
In-reply-to: <8hiia1$lvs$1@nnrp1.deja.com> (ryan4600@my-deja.com)
Subject: Re: Keyboard Handler problem
References: <8hiia1$lvs$1 AT nnrp1 DOT deja DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> I am writing a keyboard handler and am having some problems with
> writing efficient code. I have successfully locked all code (using DPMI
> functions) and can get most of the keys on my keyboard. But these are
> the problems I am having.
> 
> I have a state map which gets the state of keys like the alt and
> control key. Now the array I am using for this purpose is global in my
> program as I can't pass anything to the handler function.
> 
> Similarly there are other variables being used in the handler which are
> global.
> 
> Is it okay to pass variables to the handler(like other C
> functions)?

No, you don't want to pass variables. And btw, there should be no
reason for you to send variables to a h/w interrupt handler. Also, you
didn't mention if you used the iret-wrapper for your interrupt handler
(_go32_dpmi_allocate_iret_wrapper() IIRC).

> Another problem is that my handler size is getting bigger as I am
> making many checks inside the handler. One of them is for checking if
> the buffer (I am using) is full or not. Then there are othes for
> checking if any of the function keys was pressed, or any other keys I
> want to ignore. Is it okay to make checks in the ISR? Or should I make
> them outside?

IMO, it is best to just make a note of what key was pressed (store
that in a queue, probably). Later, the program would make checks for
necessary keys. Bloating the interrupt handler code can cause strange
problems (especially for timer interrupts).

Also, lock any data that you may be using for obvious reasons.

Good luck!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019