|
|
Microsoft OS/2 SDK 03-01-1988
/*** mouapi.c - A library of real mode mouse calls compatable with OS/2
*
* A subset of the OS/2 mouse api calls for real mode calls.
* The calls and features are designed specifically for LIFE.C.
* This is designed as a library to be linked with an application
* using BIND.EXE to allow full compatability between real and
* protect modes for programs using mouse calls.
* Most are merely dummy calls because DOS 3.x doesn't care about
* such things.
*
* Contains subsets of:
* MouOpen, MouReadEventQue, MouSetDevStatus,
* MouGetNumQueEl, MouSetPtrPos
*
* Created by Microsoft Corp. 1987
*/
#define INCL_SUB
#include <os2def.h>
#include <bsesub.h>
/* defines for int33h() calls. These are the offsets for the various registers
* in the register array. */
#define AX 0
#define BX 1
#define CX 2
#define DX 3
/*** MouOpen - initializes mouse
*
* Initializes mouse and returns -1 in handle if mouse is present, else
* if no mouse is present, returns 0 in handle and error code.
*/
unsigned APIENTRY
MouOpen (name, handle)
PSZ name;
PHMOU handle;
{
extern void int33h(); /* mouse interupt caller */
int registers[4]; /* register array for above */
registers[AX]=0; /* ax=0, mouse init */
int33h (registers); /* do mouse call */
if (registers[AX] == -1) { /* was mouse present? */
*handle=-1; /* if yes, give dummy handle */
registers[AX]=15; /* set mickey to pixel */
registers[CX]=8; /* ratio to 1:1 */
registers[DX]=8;
int33h(registers);
return (0); /* and return no error */
}
else {
*handle=0;
return (385); /* else, return no mouse err */
}
}
/*** MouReadEventQue - get mouse event
*
* Gets events like the OS/2 MouReadEventQue but this one ignores
* the event mask and EventType parameter, never waiting for events,
* just returning a 0 mask if nothing happened since last call.
* Returns position absolute pixel coordinates
*/
unsigned APIENTRY
MouReadEventQue (buffer, type, handle)
PMOUEVENTINFO buffer;
PUSHORT type;
HMOU handle;
{
extern void int33h(); /* mouse interupt caller */
int registers[4]; /* register array for above */
static lastrow; /* position at last call */
static lastcol;
buffer->Time=-1L; /* put in dummy time figure */
registers[AX]=3; /* ax=3, get mouse status */
int33h (registers); /* do mouse call */
buffer->fs=0; /* first, blank button info */
if (registers[DX]-lastrow || registers[CX]-lastcol) {
buffer->row=registers[DX]; /* return row */
buffer->col=registers[CX]; /* return column */
lastrow=registers[DX]; /* save for next time */
lastcol=registers[CX];
if (registers[BX] & 1) /* if the left button is down*/
(buffer->fs) |= 2; /* then set appropriate bit*/
if (registers[BX] & 2) /* if the right button down*/
(buffer->fs) |= 8; /* then set appropriate bit*/
else if (!(registers[BX] & 1)) /* if no buttons, but motion */
buffer->fs |= 1; /* then set apporpriate bit*/
}
if (registers[BX] & 1) /* if the left button is down*/
(buffer->fs) |= 4; /* then set appropriate bit*/
if (registers[BX] & 2) /* if the right button down*/
(buffer->fs) |= 16; /* then set appropriate bit*/
return (0); /* return no error */
}
/*** MouSetDevStatus - Dummy function, included for maximum compatibility
*/
unsigned APIENTRY
MouSetDevStatus (status, handle)
PUSHORT status;
HMOU handle;
{
}
/*** MouGetNumQueEl - Always returns 1 in .Events
*/
unsigned APIENTRY
MouGetNumQueEl (info, handle)
PMOUQUEINFO info;
HMOU handle;
{
info->cEvents = 1;
}
/*** MouSetPtrPos - Sets mouse pointer position
*/
unsigned APIENTRY
MouSetPtrPos (loc, handle)
PPTRLOC loc;
HMOU handle;
{
int registers[4]; /* for int33h() */
registers[AX]=4; /* int 33 set position funct */
registers[CX]=loc->col; /* new coordinates */
registers[DX]=loc->row;
int33h (registers); /* do it */
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.