From: Endlisnis 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: Reply-To: Endlisnis NNTP-Posting-Host: sol-alt1.unb.ca Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 #include #include 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]