delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/06/23:45:48

From: ryan4600 AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Keyboard Handler problem
Date: Tue, 06 Jun 2000 19:25:13 GMT
Organization: Deja.com - Before you buy.
Lines: 65
Message-ID: <8hjj65$flt$1@nnrp1.deja.com>
References: <8hiia1$lvs$1 AT nnrp1 DOT deja DOT com> <200006061335 DOT TAA29025 AT bgl2 DOT vsnl DOT net DOT in>
NNTP-Posting-Host: 24.64.21.150
X-Article-Creation-Date: Tue Jun 06 19:25:13 2000 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
X-Http-Proxy: 1.1 x60.deja.com:80 (Squid/1.1.22) for client 24.64.21.150
X-MyDeja-Info: XMYDJUIDryan4600
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <200006061335 DOT TAA29025 AT bgl2 DOT vsnl DOT net DOT in>,
  djgpp AT delorie DOT com wrote:
> > 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).

Okay then my program would have lots of global variables. Is that okay?
Is it how things are done when writing keyboard handlers? Would it be
posible to see some sample source code which implements keyboard
handler? Yes I did use wrappers for my handler so I don't need IRET
instruction in my handler.


>
> > 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.
>
I am thinking about disabling all virtual memory for now. I now this
might make things slower in the real world, but is safer for learning
purposes..

> Good luck!

Thanks!

>
>


Sent via Deja.com http://www.deja.com/
Before you buy.

- Raw text -


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