1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-19 17:28:18 +00:00
Interlisp.maiko/src/dosmouse.c
Nick Briggs 6528ac38e3 Remove proprietary license from all files.
The code is being re-licensed under the MIT license.

	modified:   bin/fixid
	modified:   bin/launch.asm
	modified:   bin/makefile-hpux.hp9000-x
	modified:   bin/makefile-init.sgi
	modified:   bin/makefile-init.sparc
	modified:   bin/makefile-init.sparc-multi
	modified:   bin/makefile-irix.sgi-x
	modified:   bin/makefile-sunos4.sparc
	modified:   bin/makefile-sunos4.sparc%
	modified:   bin/makefile-sunos4.sparc-multi
	modified:   bin/makefile-sunos5.386-x
	modified:   bin/makefile-sunos5.i386-x
	modified:   bin/makefile-sunos5.sparc-x
	modified:   bin/makefile-tail
	modified:   bin/makeisc
	modified:   bin/makeright
	modified:   inc/Check.h
	modified:   inc/MyWindow.h
	modified:   inc/Stipple.h
	modified:   inc/XCursors.h
	modified:   inc/XKeymap.h
	modified:   inc/XVersion.h
	modified:   inc/Xdeflt.h
	modified:   inc/Xicon.h
	modified:   inc/address.h
	modified:   inc/arith.h
	modified:   inc/arith2.h
	modified:   inc/array.h
	modified:   inc/bb.h
	modified:   inc/cell.h
	modified:   inc/cell.h%
	modified:   inc/copyright
	modified:   inc/dbprint.h
	modified:   inc/debug.h
	modified:   inc/devif.h
	modified:   inc/display.h
	modified:   inc/dspdata.h
	modified:   inc/ether.h
	modified:   inc/fast_dsp.h
	modified:   inc/fp.h
	modified:   inc/gc.h
	modified:   inc/gc.h.save
	modified:   inc/gcscan.h
	modified:   inc/hdw_conf.h
	modified:   inc/ifpage.h
	modified:   inc/inlineC.h
	modified:   inc/inlnMIPS.h
	modified:   inc/inlnPS2.h
	modified:   inc/inlndos.h
	modified:   inc/iopage.h
	modified:   inc/kbdif.h
	modified:   inc/keyboard.h
	modified:   inc/keyboard.h%
	modified:   inc/keysym.h
	modified:   inc/ldeXdefs.h
	modified:   inc/lispemul.h
	modified:   inc/lispemul.h.save
	modified:   inc/lispmap.h
	modified:   inc/lldsp.h
	modified:   inc/lnk-Xdeflt.h
	modified:   inc/lnk-debug.h
	modified:   inc/lnk-fast_dsp.h
	modified:   inc/lnk-inlineC.h
	modified:   inc/lnk-lispmap.h
	modified:   inc/lnk-tosfns.h
	modified:   inc/lnk-tosret.h
	modified:   inc/locfile.h
	modified:   inc/lpdefs.h
	modified:   inc/lpglobl.h
	modified:   inc/lspglob.h
	modified:   inc/lsptypes.h
	modified:   inc/medleyfp.h
	modified:   inc/mnxdefs.h
	modified:   inc/my.h
	modified:   inc/native.h
	modified:   inc/ocr.h
	modified:   inc/osmsg.h
	modified:   inc/picture.h
	modified:   inc/pilotbbt.h
	modified:   inc/print.h
	modified:   inc/profile.h
	modified:   inc/rawrs232c.h
	modified:   inc/return.h
	modified:   inc/rs232c.h
	modified:   inc/stack.h
	modified:   inc/stream.h
	modified:   inc/stream.h%
	modified:   inc/stream.h2
	modified:   inc/sysatms.h
	modified:   inc/timeout.h
	modified:   inc/tos1defs.h
	modified:   inc/tosfns.h
	modified:   inc/tosret.h
	modified:   inc/tty.h
	modified:   inc/version.h
	modified:   inc/vmemsave.h
	modified:   inc/xbitmaps.h
	modified:   inc/xdefs.h
	modified:   src/Cldeetr.c
	modified:   src/allocmds.c
	modified:   src/arith2.c
	modified:   src/arith3.c
	modified:   src/arith4.c
	modified:   src/array.c
	modified:   src/array2.c
	modified:   src/array3.c
	modified:   src/array4.c
	modified:   src/array5.c
	modified:   src/array6.c
	modified:   src/asmbbt.c
	modified:   src/asmbitblt.c
	modified:   src/atom.c
	modified:   src/bbtSPARC.s
	modified:   src/bbtsub.c
	modified:   src/bin.c
	modified:   src/binds.c
	modified:   src/bitblt.c
	modified:   src/blt.c
	modified:   src/byteswap.c
	modified:   src/call-c.c
	modified:   src/car-cdr.c
	modified:   src/cdaudio.c
	modified:   src/cdrom.c
	modified:   src/chardev.c
	modified:   src/chatter.c
	modified:   src/codeconv.c
	modified:   src/codetbl.c
	modified:   src/colorbltfns.c
	modified:   src/common.c
	modified:   src/conspage.c
	modified:   src/cr
	modified:   src/dbgtool.c
	modified:   src/dir.c
	modified:   src/doscomm.c
	modified:   src/doskbd.c
	modified:   src/dosmouse.c
	modified:   src/draw.c
	modified:   src/dsk.c
	modified:   src/dspif.c
	modified:   src/dspsubrs.c
	modified:   src/ejlisp.c
	modified:   src/eqf.c
	modified:   src/ether.c
	modified:   src/findkey.c
	modified:   src/foreign.c
	modified:   src/fp.c
	modified:   src/fvar.c
	modified:   src/gc.c
	modified:   src/gc2.c
	modified:   src/gcarray.c
	modified:   src/gccode.c
	modified:   src/gcfinal.c
	modified:   src/gchtfind.c
	modified:   src/gcmain3.c
	modified:   src/gcoflow.c
	modified:   src/gcr.c
	modified:   src/gcrcell.c
	modified:   src/gcscan.c
	modified:   src/gvar2.c
	modified:   src/hacks.c
	modified:   src/hardrtn.c
	modified:   src/imagefile.c
	modified:   src/imagefile2.c
	modified:   src/inet.c
	modified:   src/initdsp.c
	modified:   src/initkbd.c
	modified:   src/initsout.c
	modified:   src/intcall.c
	modified:   src/kbdif.c
	modified:   src/kbdsubrs.c
	modified:   src/keyevent.c
	modified:   src/keylib.c
	modified:   src/keymaker.c
	modified:   src/keytst.c
	modified:   src/keytstno.c
	modified:   src/kprint.c
	modified:   src/launch.asm
	modified:   src/ldeboot.c
	modified:   src/ldeether.c
	modified:   src/ldsout.c
	modified:   src/lineblt8.c
	modified:   src/lisp2c.c
	modified:   src/llcolor.c
	modified:   src/llstk.c
	modified:   src/loader.c
	modified:   src/loopsops.c
	modified:   src/lowlev1.c
	modified:   src/lowlev2.c
	modified:   src/lpdual.c
	modified:   src/lpkit.c
	modified:   src/lplexyy.c
	modified:   src/lpmain.c
	modified:   src/lpread.c
	modified:   src/lpsolve.c
	modified:   src/lptran.c
	modified:   src/lpwrite.c
	modified:   src/lpytab.c
	modified:   src/lsthandl.c
	modified:   src/main.c
	modified:   src/misc7.c
	modified:   src/miscn.c
	modified:   src/mkatom.c
	modified:   src/mkcell.c
	modified:   src/mkkey.c
	modified:   src/mkvdate.c
	modified:   src/mnwevent.c
	modified:   src/mnxmeth.c
	modified:   src/mouseif.c
	modified:   src/mvs.c
	modified:   src/ocr.c
	modified:   src/ocrproc.c
	modified:   src/oether.c
	modified:   src/oldeether.c
	modified:   src/optck.c
	modified:   src/osmsg.c
	modified:   src/perrno.c
	modified:   src/picture.c
	modified:   src/rawcolor.c
	modified:   src/rawrs232c.c
	modified:   src/return.c
	modified:   src/rpc.c
	modified:   src/rplcons.c
	modified:   src/rs232c.c
	modified:   src/setsout.c
	modified:   src/shift.c
	modified:   src/socdvr.c
	modified:   src/storage.c
	modified:   src/subr.c
	modified:   src/subr0374.c
	modified:   src/sxhash.c
	modified:   src/testdsp.c
	modified:   src/testtool.c
	modified:   src/timeoday.c
	modified:   src/timeofday.c
	modified:   src/timer.c
	modified:   src/truecolor.c
	modified:   src/tstsout.c
	modified:   src/tty.c
	modified:   src/typeof.c
	modified:   src/ubf1.c
	modified:   src/ubf2.c
	modified:   src/ubf3.c
	modified:   src/ufn.c
	modified:   src/ufs.c
	modified:   src/unixcomm.c
	modified:   src/unixfork.c
	modified:   src/unwind.c
	modified:   src/uraid.c
	modified:   src/usrsubr.c
	modified:   src/uutils.c
	modified:   src/vars3.c
	modified:   src/vesafns.asm
	modified:   src/vesainit.c
	modified:   src/vgainit.c
	modified:   src/vmemsave.c
	modified:   src/xbbt.c
	modified:   src/xc.c
	modified:   src/xc.c.orig
	modified:   src/xcursor.c
	modified:   src/xinit.c
	modified:   src/xlspwin.c
	modified:   src/xmkicon.c
	modified:   src/xrdopt.c
	modified:   src/xscroll.c
	modified:   src/xwinman.c
	modified:   src/z2.c
2020-08-11 18:39:45 -07:00

626 lines
22 KiB
C

/* $Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
static char *id = "$Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */
/* All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include <i32.h> /* Defines "#pragma interrupt" */
#include <stk.h> /* _XSTACK struct definition */
#include <dos.h> /* Defines REGS & other structs */
#include "lispemul.h"
#include "display.h"
#include "bb.h"
#include "dbprint.h"
#include "devif.h"
#include "keyboard.h"
#include "ifpage.h"
extern int eurokbd;
extern IOPAGE *IOPage68K;
extern MISCSTATS *MiscStats;
extern IFPAGE *InterfacePage;
extern int KBDEventFlg;
extern DspInterface currentdsp;
extern MouseInterface currentmouse;
extern KbdInterface currentkbd;
extern keybuffer *CTopKeyevent;
extern DLword *DisplayRegion68k;
extern DLword *Lisp_world;
extern LispPTR *KEYBOARDEVENTQUEUE68k;
extern LispPTR *KEYBUFFERING68k;
extern LispPTR *LASTUSERACTION68k;
#define MOUSE_MV 0x01 /* Mouse movement occurred */
#define LB_PRESS 0x02 /* Left button pressed */
#define LB_OFF 0x04 /* Left button released */
#define RB_PRESS 0x08 /* Right button pressed */
#define RB_OFF 0x10 /* Right button released */
#define CB_PRESS 0x20 /* Center button released */
#define CB_OFF 0x40 /* Center button pressed */
#pragma interrupt(TwoButtonHandler)
#pragma interrupt(ThreeButtonHandler)
#pragma interrupt(ButtonTimer)
void ButtonTimer();
void MouseButtonSignal();
void EnterDosMouse(MouseInterface mouse, DspInterface dsp)
{
union REGS regs;
probemouse();
_dpmi_lockregion((void *)&MouseButtonSignal, 4096);
/* Set up the ringbuffer */
if (eurokbd)
mouse->keyeventsize = EUROKEYEVENTSIZE;
else
mouse->keyeventsize = NOEUROKEYEVENTSIZE;
mouse->eurokbd = eurokbd;
/* Offset of the end of the ring buffer */
mouse->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * mouse->keyeventsize));
/* Lock myself */
_dpmi_lockregion((void *)mouse, sizeof(*mouse));
_dpmi_lockregion((void *)&currentmouse, sizeof(currentmouse));
/* Lock the handler routines */
_dpmi_lockregion((void *)mouse->Handler, 4096);
if (mouse->Button.TwoButtonP) { _dpmi_lockregion((void *)&ButtonTimer, 4096); }
/* Lock the structures used, both pointers to 'em & the whole structure. */
_dpmi_lockregion((void *)&IOPage68K, sizeof(IOPage68K));
_dpmi_lockregion((void *)IOPage68K, sizeof(IOPAGE));
_dpmi_lockregion((void *)&InterfacePage, sizeof(InterfacePage));
_dpmi_lockregion((void *)InterfacePage, sizeof(IFPAGE));
_dpmi_lockregion((void *)&MiscStats, sizeof(MiscStats));
_dpmi_lockregion((void *)MiscStats, sizeof(MISCSTATS));
/* Lock the flags */
_dpmi_lockregion((void *)&KBDEventFlg, sizeof(KBDEventFlg));
_dpmi_lockregion((void *)&MachineState, sizeof(MachineState));
/* Lock the pointers into the sysout */
_dpmi_lockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k));
/* Lock the regions of the sysout that the pointers points to */
/* KEYBUFFERINF68k points to the value cell for a symbol */
_dpmi_lockregion((void *)KEYBUFFERING68k, sizeof(LispPTR));
/* CTopKeyevent points to the ring-buffer of keyboard events */
_dpmi_lockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent));
_dpmi_lockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent));
/* Now Lock the lastuseraction machine. */
/* _dpmi_lockregion(mouse->timestamp, sizeof(LispPTR)); */ /* Lisp_world itself */
regs.w.eax = 0x0001; /* Function 1 = turn on mouse cursor */
int86(0x33, &regs, &regs);
regs.w.eax = 0x0002; /* Function 2 = hide mouse cursor */
int86(0x33, &regs, &regs);
regs.w.eax = 0x0C; /* Function 0C = set user-defined mouse handler */
regs.w.ecx = LB_PRESS | LB_OFF | CB_PRESS | CB_OFF | RB_PRESS | RB_OFF | MOUSE_MV;
regs.w.edx = FP_OFF(*(mouse->Handler)); /* Address of our mouse handler routine */
int86(0x33, &regs, &regs); /* Install our handler to process events */
if (regs.w.eax == 'MERR')
VESA_errorexit("Unable to install mouse handler - not enough low memory.\n", -1);
regs.x.ax = 0x7; /* Set mouse horizontal range */
regs.x.cx = 0x0;
regs.x.dx = (short)(dsp->Display.width - 1);
int86(0x33, &regs, &regs);
regs.x.ax = 0x8; /* Set mouse vertical range */
regs.x.cx = 0x0;
regs.x.dx = (short)(dsp->Display.height - 1);
int86(0x33, &regs, &regs);
/* See if turning this off fixes the "mouse granularity" problem */
/* Nope. It didn't. */
regs.x.ax = 0xf; /* Set mickey per pixel range */
regs.x.cx = 0x8;
regs.x.dx = 0x8;
int86(0x33, &regs, &regs);
mouse->Button.NextHandler = _dos_getvect(0x1c);
_dos_setvect(0x1c, ButtonTimer);
mouse->device.active = TRUE;
}
void ExitDosMouse(MouseInterface mouse)
{
if (mouse->device.active) {
/* Unlock myself */
_dpmi_unlockregion((void *)mouse, sizeof(*mouse));
_dpmi_unlockregion((void *)&currentmouse, sizeof(currentmouse));
/* Unlock the handler routines */
_dpmi_unlockregion((void *)mouse->Handler, 4096);
_dpmi_unlockregion((void *)&ButtonTimer, 4096);
_dpmi_unlockregion((void *)&MouseButtonSignal, 4096);
/* Unlock the structures used. */
_dpmi_unlockregion((void *)&IOPage68K, sizeof(IOPage68K));
_dpmi_unlockregion((void *)&InterfacePage, sizeof(InterfacePage));
_dpmi_unlockregion((void *)&MiscStats, sizeof(MiscStats));
/* Unlock the flags */
_dpmi_unlockregion((void *)&KBDEventFlg, sizeof(KBDEventFlg));
_dpmi_unlockregion((void *)&MachineState, sizeof(MachineState));
/* Unlock the pointers into the sysout */
_dpmi_unlockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k));
/* _dpmi_unlockregion((void *)&KEYBOARDEVENTQUEUE68k, sizeof(KEYBOARDEVENTQUEUE68k)); */
/* Unlock the regions of the sysout that the pointers points to */
_dpmi_unlockregion((void *)KEYBUFFERING68k, sizeof(LispPTR));
_dpmi_unlockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent));
_dpmi_unlockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent));
/* _dpmi_unlockregion(mouse->timestamp, sizeof(LispPTR)); */
_dos_setvect(0x1c, mouse->Button.NextHandler);
mouse->device.active = FALSE;
}
}
void DosMouseAfterRaid(MouseInterface mouse, DspInterface dsp)
{
union REGS regs;
/* Screen mode changed. We have to reinit the ranges. */
regs.x.ax = 0x7; /* Set mouse horizontal range */
regs.x.cx = 0x0;
regs.x.dx = (short)(dsp->Display.width - 1);
int86(0x33, &regs, &regs);
regs.x.ax = 0x8; /* Set mouse vertical range */
regs.x.cx = 0x0;
regs.x.dx = (short)(dsp->Display.height - 1);
int86(0x33, &regs, &regs);
mouse->device.active = TRUE;
}
void DosMouseBeforeRaid(MouseInterface mouse, DspInterface dsp)
{ mouse->device.active = FALSE; }
/***************************************************************/
/* d o s _ c u r s o r _ i n v i s s i b l e */
/* Since we only blit the cursor to the VESA/VGA displaybuffer */
/* and not to the emulator displaybuffer we can make the cursor*/
/* invisible just by updateing the area under the cursor! */
/***************************************************************/
void dos_cursor_invisible(DspInterface dsp, IOPAGE *iop)
{ (dsp->bitblt_to_screen)(dsp, DisplayRegion68k, iop->dlcursorx, iop->dlcursory, 16, 16); }
/***************************************************************/
/* d o s _ c u r s o r _ v i s s i b l e */
/* blit the mouse to the display ... */
/* The cursor should be blitted according to the following: */
/* ((backgroundbm AND maskbm) OR ((NOT mask) OR cursorbm)) */
/* ie. bltAND the mask to the background then bltOR the rest */
/* */
/* Hah!! this crappy machine doesn't have a mask!! /jarl */
/* ie. use the inverted bitmap as a mask!!!! */
/* */
/* More to the point. The mask is the image inverted. (sigh..) */
/* */
/***************************************************************/
set_DOSmouseposition(DspInterface dsp, int x, int y)
{
union REGS regs;
dsp->device.locked++;
currentmouse->device.active++;
#ifdef NEVER
/* int 33h, case 0004, cx=col, dx = row */
regs.w.eax = 4; /* Function 4 = move cursor */
regs.w.ecx = x;
regs.w.edx = y;
int86(0x33, &regs, &regs);
#endif /* NEVER */
/* Actually move the cursor image */
IOPage68K->dlmousex = x;
IOPage68K->dlmousey = y;
/* *(currentmouse->timestamp) = MiscStats->secondstmp; */
(currentdsp->mouse_invisible)(currentdsp, IOPage68K);
currentmouse->Cursor.New.x = IOPage68K->dlcursorx = x;
currentmouse->Cursor.New.y = IOPage68K->dlcursory = y;
(currentdsp->mouse_visible)(x, y);
dsp->device.locked--;
currentmouse->device.active--;
}
void docopy(int newx, int newy)
{
register DLword *srcbase, *dstbase;
static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg = 0;
static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0;
srcbase = IOPage68K->dlcursorbitmap;
dstbase = DisplayRegion68k + (newy * currentdsp->Display.width / 16);
sx = 0;
dx = newx;
w = currentmouse->Cursor.Last.width;
h = currentmouse->Cursor.Last.height;
srcbpl = 16;
dstbpl = currentdsp->Display.width;
op = 2; /* OR-in */
#ifdef NEWBITBLT
bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, 2, 0, 0, 0);
#else
new_bitblt_code;
#endif /* NEWBITBLT */
}
dostaking_mouse_up(int newx, int newy)
{
/* save hidden bitmap */
register DLword *srcbase, *dstbase;
static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg = 0;
static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0;
/* newx and newy are hotspot coordinates. */
/* newx -= currentmouse->Cursor.Hotspot.x; */
/* newy -= ( 15 - currentmouse->Cursor.Hotspot.y); */
/* save image */
srcbase = DisplayRegion68k + (newy * currentdsp->Display.width / 16);
dstbase = currentmouse->Cursor.Savebitmap;
sx = newx;
dx = 0;
if (currentdsp->Display.width < (newx + 16)) {
currentmouse->Cursor.Last.width = w = currentdsp->Display.width - newx;
} else {
currentmouse->Cursor.Last.width = w = 16;
};
if (currentdsp->Display.height < (newy + 16)) {
currentmouse->Cursor.Last.height = h = currentdsp->Display.height - newy;
} else {
currentmouse->Cursor.Last.height = h = 16;
};
srcbpl = currentdsp->Display.width;
dstbpl = 16;
op = 0; /* replace */
#ifdef NEWBITBLT
bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, 0, gray, num_gray,
curr_gray_line);
#else
new_bitblt_code;
#endif /* NEWBITBLT */
/* Copy Cursor Image */
docopy(newx, newy);
currentmouse->Cursor.Last.x = newx;
currentmouse->Cursor.Last.y = newy;
(currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, currentmouse->Cursor.Last.x,
currentmouse->Cursor.Last.y, w, h);
}
dostaking_mouse_down(DspInterface dsp, IOPAGE *iop)
{
register DLword *srcbase, *dstbase;
static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0;
static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0;
/* restore saved image */
srcbase = currentmouse->Cursor.Savebitmap;
dstbase =
DisplayRegion68k + ((currentmouse->Cursor.Last.y) * (dsp->Display.width / 16)); /* old y */
sx = 0;
dx = currentmouse->Cursor.Last.x; /* old x */
w = currentmouse->Cursor.Last.width;
h = currentmouse->Cursor.Last.height;
srcbpl = 16;
dstbpl = dsp->Display.width;
op = 0;
#ifdef NEWBITBLT
bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, 0, 0, 0, 0);
#else
new_bitblt_code;
#endif /* NEWBITBLT */
(dsp->bitblt_to_screen)(dsp, DisplayRegion68k, currentmouse->Cursor.Last.x,
currentmouse->Cursor.Last.y, w, h);
}
/************************************************************************/
/* */
/* M o u s e B u t t o n S i g n a l */
/* */
/* Tell LISP about a mouse event by putting an entry on the ring buf- */
/* fer of mouse/kbd events, with the new mouse-button state in it. */
/* */
/* */
/************************************************************************/
void MouseButtonSignal(MouseInterface mouse)
{
DLword w, r;
KBEVENT *kbevent;
/* In the mouse device TRUE means button pressed */
/* In the IOPage 0 means button pressed */
/* Hence the ! in the lines below. */
PUTBASEBIT68K(&(IOPage68K->dlutilin), MOUSE_LEFT, !mouse->Button.Left);
PUTBASEBIT68K(&(IOPage68K->dlutilin), MOUSE_MIDDLE, !mouse->Button.Middle);
PUTBASEBIT68K(&(IOPage68K->dlutilin), MOUSE_RIGHT, !mouse->Button.Right);
r = CTopKeyevent->ring.vectorindex.read;
w = CTopKeyevent->ring.vectorindex.write;
if (r != w) {
kbevent = (KBEVENT *)((DLword *)CTopKeyevent + w);
/* Copy the Hardware bits. */
kbevent->W0 = IOPage68K->dlkbdad0;
kbevent->W1 = IOPage68K->dlkbdad1;
kbevent->W2 = IOPage68K->dlkbdad2;
kbevent->W3 = IOPage68K->dlkbdad3;
kbevent->W4 = IOPage68K->dlkbdad4;
kbevent->W5 = IOPage68K->dlkbdad5;
kbevent->WU = IOPage68K->dlutilin;
/* If queue was empty, update the read pointer */
if (r == 0) CTopKeyevent->ring.vectorindex.read = w;
/* Update the write pointer */
if (w >= mouse->maxkeyevent)
CTopKeyevent->ring.vectorindex.write = MINKEYEVENT;
else
CTopKeyevent->ring.vectorindex.write += mouse->keyeventsize;
}
if (*KEYBUFFERING68k == NIL) *KEYBUFFERING68k = ATOM_T;
KBDEventFlg++; /* Signal the emulator to tell Lisp */
Irq_Stk_Check = 0;
Irq_Stk_End = 0;
}
/***************************************************************/
/* B u t t o n T i m e r */
/* This function is used with the mouse chording machinery. */
/* This function is the timer interrupt handler. When a button */
/* event happens we will wait to report it until the next */
/* timeout happens. We will thus obtain the ``rubbery feeling''*/
/* that proponents of chording so desire. */
/***************************************************************/
void ButtonTimer() {
if (currentmouse->Button.RunTimer)
if (currentmouse->Button.tick-- <= 0) {
currentmouse->Button.RunTimer = FALSE; /* Turn the timer off. */
currentmouse->Button.Left |= currentmouse->Button.StateLeft;
currentmouse->Button.Right |= currentmouse->Button.StateRight;
/* Mouse chording code. If at the end of the timeout
the left and right buttons are down we signal middle
button and bring the others up. */
/* Are L & R down? */
if (currentmouse->Button.StateLeft && currentmouse->Button.StateRight) {
currentmouse->Button.Left = FALSE;
currentmouse->Button.Right = FALSE;
currentmouse->Button.Middle = TRUE;
}
currentmouse->Button.StateLeft = FALSE;
currentmouse->Button.StateRight = FALSE;
/* Did L & R go up after a simulated M */
/* if((currentmouse->Button.Middle &&
!(currentmouse->Button.StateLeft ||
currentmouse->Button.StateRight)))
{
currentmouse->Button.Left = FALSE;
currentmouse->Button.Right = FALSE;
currentmouse->Button.Middle = FALSE;
}
*/
MouseButtonSignal(currentmouse);
}
_chain_intr(currentmouse->Button.NextHandler);
}
/***************************************************************/
/* T w o B u t t o n H a n d l e r */
/* This function is ther interrupt handler for the mouse. */
/* This function sets the state of the mouse structure and */
/* signals the dispatch loop to care of the matter. This */
/* akward solution is due to the severe braindamage in DOS. */
/***************************************************************/
void TwoButtonHandler(void) {
_XSTACK *stk_ptr;
/* First save the stack frame. */
stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */
stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */
if (!currentmouse->device.active) return;
if (stk_ptr->eax & LB_PRESS)
if (currentmouse->Button.RunTimer) /* Prior right-down seen... */
{
currentmouse->Button.RunTimer = FALSE;
currentmouse->Button.FakeMiddle = TRUE;
currentmouse->Button.Middle = TRUE;
currentmouse->Button.StateLeft = TRUE;
MouseButtonSignal(currentmouse);
} else if (currentmouse->Button.Right) {
currentmouse->Button.Left = TRUE;
currentmouse->Button.StateLeft = TRUE;
MouseButtonSignal(currentmouse);
} else /* No other button down... */
{
currentmouse->Button.StateLeft = TRUE;
currentmouse->Button.tick = currentmouse->Button.StartTime;
currentmouse->Button.RunTimer = TRUE;
}
if (stk_ptr->eax & LB_OFF) /* Left button released, and */
if (currentmouse->Button.RunTimer) /* Timer had been running */
{
currentmouse->Button.RunTimer = FALSE;
currentmouse->Button.Left = TRUE;
MouseButtonSignal(currentmouse);
currentmouse->Button.StateLeft = FALSE;
/* currentmouse->Button.Left = FALSE;
MouseButtonSignal(currentmouse); */
} else /* timer wasn't running */
{
currentmouse->Button.StateLeft = FALSE;
currentmouse->Button.Left = FALSE;
currentmouse->Button.FakeMiddle = FALSE;
currentmouse->Button.Middle = currentmouse->Button.StateMiddle;
MouseButtonSignal(currentmouse);
}
if ((stk_ptr->eax & CB_PRESS) || (stk_ptr->eax & CB_OFF)) {
currentmouse->Button.Middle =
((stk_ptr->eax & CB_PRESS) && TRUE) || currentmouse->Button.FakeMiddle;
currentmouse->Button.StateMiddle = (stk_ptr->eax & CB_PRESS) && TRUE;
currentmouse->Button.RunTimer = FALSE;
MouseButtonSignal(currentmouse);
}
if (stk_ptr->eax & RB_PRESS) /* Right button pressed, and */
if (currentmouse->Button.RunTimer) /* Timer was running... */
{
currentmouse->Button.RunTimer = FALSE;
currentmouse->Button.FakeMiddle = TRUE;
currentmouse->Button.Middle = TRUE;
currentmouse->Button.StateRight = TRUE;
MouseButtonSignal(currentmouse);
} else if (currentmouse->Button.Left) {
currentmouse->Button.Right = TRUE;
currentmouse->Button.StateRight = TRUE;
MouseButtonSignal(currentmouse);
} else {
currentmouse->Button.StateRight = TRUE;
currentmouse->Button.tick = currentmouse->Button.StartTime;
currentmouse->Button.RunTimer = TRUE;
}
if (stk_ptr->eax & RB_OFF) /* Right button released */
if (currentmouse->Button.RunTimer) /* Timer had been running */
{
currentmouse->Button.RunTimer = FALSE;
currentmouse->Button.Right = TRUE;
MouseButtonSignal(currentmouse);
currentmouse->Button.StateRight = FALSE;
/* currentmouse->Button.Right = FALSE;
MouseButtonSignal(currentmouse); */
} else {
currentmouse->Button.StateRight = FALSE;
currentmouse->Button.Right = FALSE;
currentmouse->Button.FakeMiddle = FALSE;
currentmouse->Button.Middle = currentmouse->Button.StateMiddle;
MouseButtonSignal(currentmouse);
}
/* The dude moved the mouse. Set the chordstate NOW. */
/* And turn the timer off. */
if ((stk_ptr->eax & MOUSE_MV) && (!currentdsp->device.locked)) {
currentmouse->Button.RunTimer = FALSE;
/* Are L & R down? */
/* if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight)
{
currentmouse->Button.Left = FALSE;
currentmouse->Button.Right = FALSE;
currentmouse->Button.Middle = TRUE;
}
*/
/* currentmouse->Cursor.New.x = (DLword)stk_ptr->ecx & 0xFFFF;
currentmouse->Cursor.New.y = (DLword)stk_ptr->edx & 0xFFFF; */
currentmouse->Cursor.Moved = TRUE;
if (currentmouse->Button.StateLeft && currentmouse->Button.StateRight) {
currentmouse->Button.Left = FALSE;
currentmouse->Button.Right = FALSE;
currentmouse->Button.Middle = TRUE;
} else {
currentmouse->Button.Left |= currentmouse->Button.StateLeft;
currentmouse->Button.Right |= currentmouse->Button.StateRight;
}
currentmouse->Button.StateLeft = currentmouse->Button.StateRight = FALSE;
MouseButtonSignal(currentmouse);
}
}
/***************************************************************/
/* T h r e e B u t t o n H a n d l e r */
/* This function is ther interrupt handler for the mouse. */
/* This function sets the state of the mouse structure and */
/* signals the dispatch loop to care of the matter. This */
/* akward solution is due to the severe braindamage in DOS. */
/***************************************************************/
void ThreeButtonHandler()
{
_XSTACK *stk_ptr;
unsigned long mouse_flags;
/* First save the stack frame. */
stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */
stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */
if (currentmouse->device.active) {
mouse_flags = stk_ptr->eax; /* Save event flags from mouse driver */
/* Decode the transition bits. */
if (mouse_flags & LB_PRESS) currentmouse->Button.Left = TRUE;
if (mouse_flags & LB_OFF) currentmouse->Button.Left = FALSE;
if (mouse_flags & CB_PRESS) currentmouse->Button.Middle = TRUE;
if (mouse_flags & CB_OFF) currentmouse->Button.Middle = FALSE;
if (mouse_flags & RB_PRESS) currentmouse->Button.Right = TRUE;
if (mouse_flags & RB_OFF) currentmouse->Button.Right = FALSE;
if ((!currentdsp->device.locked) && (mouse_flags & MOUSE_MV)) {
currentmouse->Cursor.Moved = TRUE;
Irq_Stk_Check = 0;
Irq_Stk_End = 0;
}
if (mouse_flags & (LB_PRESS | LB_OFF | CB_PRESS | CB_OFF | RB_PRESS | RB_OFF))
MouseButtonSignal(currentmouse);
}
}