From: "A.Appleyard" To: DJGPP AT DELORIE DOT COM Date: Thu, 21 Mar 1996 08:47:51 GMT Subject: A way to define my own mouse event handler Message-ID: A while ago, Eli Zaretski kindly sent me this way to define my own mouse event handler for djgpp v1. Will it still work with v2? #include #include #include #include /*-----*/ /* Simulate a software interrupt from protected mode. Like int86() but calls DPMI services and so doesn't need DOS extender, only a DPMI server. */ int int86dpmi(int intno) {REGS r,s; Regs S; S=R; S.x.ss=S.x.sp=0; /* DPMI server is to provide stack for interrupt call */ S.x.flags=0; /* he likeliest forgot to zero the flags */ /* I replaced the _go32_dpmi_simulate_int() call by a copy of its body here */ r.h.bl=intno; r.h.bh=0; r.x.cx=0; r.x.di=(int)&S; if(intno==0x21 && S.x.ax==0x4b00) { /* call a child process */ r.x.ax=0xff0a; int86(0x21,&r,&s);} else {r.x.ax=0x0300; int86(0x31,&r,&s);} R=S; return R.d.eax;} /*-----*/ Regs cb_regs; static _go32_dpmi_seginfo cb_info; /* for callback */ /*-----*/ void Mouse::settrap(uns int mask,void (*func)(Regs *)) { /* This is tricky in protected-mode. We must allocate a real-mode wrapper function which will be called by the mouse driver, and which in turn will switch to protected-mode and call our protected-mode handler function. */ if(!Jerry.nbuttons) return; if(!func) {Jerry.handlerInstalled=0; /* remove handler */ _go32_dpmi_free_real_mode_callback(&cb_info); R.x.dx=R.x.es=0;} else { /* Allocate real-mode call-back. Find real-mode address of handler */ cb_info.pm_offset=(uns long)func; Jerry.handlerInstalled=1; if(_go32_dpmi_allocate_real_mode_callback_retf(&cb_info,&cb_regs)) return; R.x.dx=cb_info.rm_offset; R.x.es=cb_info.rm_segment;} R.x.ax=12; R.x.cx=mask; int86dpmi(0x33);}