delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/01/20:06:51

Date: Wed, 1 Oct 1997 17:03:46 -0700 (PDT)
Message-Id: <199710020003.RAA19217@adit.ap.net>
Mime-Version: 1.0
To: Peter Palotas <blizzar AT hem1 DOT passagen DOT se>,
Orlando Andico <orly AT dilnet DOT upd DOT edu DOT ph>
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Linux portability Q!
Cc: djgpp AT delorie DOT com

At 11:06  10/1/1997 -0400, Peter Palotas wrote:
>At 09.59 1997-10-01 +0800, you wrote:
>>On Tue, 30 Sep 1997, Peter Palotas wrote:
>>
>>> Under Linux, Is it possible to have a a function called every time a
>>> mouse-event occurs, like the int 33h callback function,
>>
>>prolly not. because there are two ways to handle the mouse under linux:
>>using gpm (on the console) and handling it as an XEvent when running under
>>X. the latter is more portable (works will all UNIX'es). don't know zip
>>about gpm.
>
>Well, if this is not possible, which is the preferred way of handling
>keyboard/mouse inputs if you want to make a portable program? 
>Callback functions, i.e. functions that are called every time an event
>occurs weren't possible you said, that means you have to use polled input
>in some way. Now I've seen examples where the mouse/keyboard events are
>merged together. Is this a feature of linux, or just the code I saw? (think
>it was GRX).
Usually direct interface to hardware (like the mouse or keyboard) is not
possible in a portable program. The event handling you mention is a feature
of GRX. It runs under Linux and DOS.
>
>>> or have a function
>>> called at a constant rate, like hooking the timerinterrupt?
>>
>>this is easy. you use this function called setitimer() and register a
>>signal handler. at the countdown interval (which you set, under linux the
>>resolution is 10ms, unless you're using RTlinux), the signal handler gets
>>called. afaik i think this also works under djgpp.
>
>Couldn't this functions be used to check for keyboard/mouse events then,
>and call our callback function if an event had occured? 
Sure, assuming you have a way to check the keyboard/mouse. But your callback
function will have to be very simple, because under some non-reentrant
systems (ie DOS) you might interrupt the OS, and if you try to use it then,
bad stuff happens.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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