delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/22/17:31:20

From: Michal Mertl <xmerm05 AT manes DOT vse DOT cz>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problems installing mouse handler
Date: Wed, 22 Oct 1997 17:10:10 +0200
Organization: Prague University of Economics
Lines: 73
Message-ID: <Pine.ULT.3.95.971022165351.7138C-100000@manes.vse.cz>
References: <344df950 DOT 23766063 AT news DOT zip DOT com DOT au>
NNTP-Posting-Host: manes.vse.cz
Mime-Version: 1.0
In-Reply-To: <344df950.23766063@news.zip.com.au>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Wed, 22 Oct 1997, Dean wrote:

> I have written a small mouse handler, but have not had a chance to see
> if it works yet as the code I use to install it does not seem to do
> anything, here's the function:
> 
> void mouse_init()
> {
>   __dpmi_regs regs;
> 
>   interrupt = 0x0C;
> 
>   mx = midx;
>   my = midy;
> 
>   //initialise the mouse driver
>   regs.x.ax = 0;
>   __dpmi_int( 0x33, &regs );
> 
>   //lock all data and code
>   _go32_dpmi_lock_data( &mx, sizeof(mx) );
>     //same thing to rest of variables here
>   _go32_dpmi_lock_code( mouse, (unsigned long)((long)__end_mouse - (long)mouse) );
> 
>   _go32_dpmi_get_protected_mode_interrupt_vector( interrupt, &old_handler );
> 
>   my_handler.pm_offset = (int)mouse;
>   my_handler.pm_selector = _go32_my_cs();
>   _go32_dpmi_allocate_iret_wrapper( &my_handler )
>   _go32_dpmi_set_protected_mode_interrupt_vector( interrupt, &my_handler )
> }
> 
I've never seene before people hooking 0x33 interrupt. I think it's not
possible becuase there lives the handler which deals with moude hardware.
To install a mouse handler you would do this, ask mouse driver to install
callback for some mouse events. This callback is in real mode so you have to
ask dpmi server to allocate callback. For more information about mouse
functions get Ralf Brown's Interrupt List or similar. The only missing thing
is locking the handler and mouseregs.

The code will look like this (not tested but, check if mouse function is ok):

static _dpmi_registers mouseregs;
void handler(_dpmi_registers *regs)
{
 whatever; /* in regs is state of the buttons, event occured, 
    position of mouse, you should avoid calling library functions from this
    code, and lock all other data and code which this touches and probably
    stack what is quite impossible */ 
}

int main()
{
  _go32_dpmi_seginfo info;
  _dpmi_registers regs;

  info.pm_offset=(int)handler;
  _go32_dpmi_allocate_real_mode_retf(&info,&mouseregs);
  regs.x.ax=0x14; //(or 0xc ...)
  regs.x.cx=0x7f;
  regs.x.es=info.rm_segment;
  regs.x.di=info.rm_offset;
  __dpmi_int(0x33,&regs); /* and the handler is installed - to uninstall
call _go32_dpmi_free_real_mode_retf after removing the handler by mouse
function 0x14 (or whatever) */    
}

Hope this works and helps.

Michal "MiMe" Mertl
  xmerm05 AT vse DOT cz


- Raw text -


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