Mail Archives: djgpp/1998/07/05/12:31:42
From: | Endlisnis <s257m AT unb DOT ca>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Mouse Handling
|
Date: | Sun, 5 Jul 1998 12:59:42 -0300
|
Organization: | University of New Brunswick
|
Lines: | 71
|
Message-ID: | <Pine.SOL.3.96.980705120455.14877A-100000@sol.sun.csd.unb.ca>
|
Reply-To: | Endlisnis <s257m AT unb DOT ca>
|
NNTP-Posting-Host: | sol-alt1.unb.ca
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I tried to set up one of the examples shown in the FAQ to have a
function of mine called every time a mouse event occurs. My function
doesn't contain any code, it is just blank. Yet anytime the mouse moves,
the system crashes. Can anyone tell me what I'm doing wrong? I even
tried locking the memory used by the function to no avail. Here is the
code.
//----------------------------------------------------------------
#include <iostream.h>
#include <dpmi.h>
#include <go32.h>
static __dpmi_regs callback_regs;
static _go32_dpmi_seginfo callback_info;
volatile struct {
int x,y,b;
} Mouse;
int InstallHandler (unsigned mask, void (*func)(__dpmi_regs *), int Size)
{
__dpmi_regs r;
callback_info.pm_offset = (long)func;
if (_go32_dpmi_allocate_real_mode_callback_retf(&callback_info,
&callback_regs))
return -1; /* failure */
r.x.ax = 0xc;
r.x.cx = mask;
__dpmi_int (0x33, &r);
_go32_dpmi_lock_data(func,Size);
return (r.x.flags & 1) ? -1 : 0;
}
void MouseHandle(__dpmi_regs* Regs)
{
//Mouse.x = (*Regs).x.cx;
//Mouse.y = (*Regs).x.dx;
//Mouse.b = (*Regs).x.bx;
}
char InitMouse()
{
__dpmi_regs Regs;
//memset(&Regs, 0, sizeof(Regs));
Regs.x.ax=0;
__dpmi_int(0x33, &Regs);
return Regs.x.ax;
}
void main()
{
if(!InitMouse()) {
cout << "No Driver present!";
return; }
if(InstallHandler(0x1F, MouseHandle,
(unsigned)main-(unsigned)MouseHandle)==-1)
{
cout << "Didn't work!";
return; }
while(Mouse.x!=80)
cout << Mouse.x << "," << Mouse.y << "," << Mouse.b << "\r";
}
Endlisnis
[I have a pyramid of wingyness]
- Raw text -