/*static char *SCCSID = "@(#)bmsmain.h  6.2 91/04/05";*/

/****************************************************************************/
/*                                                                          */
/*                       IBM/Microsoft Confidential                         */
/*                                                                          */
/*                 Copyright (c) IBM Corporation  1987, 1990                */
/*                 Copyright (c) Microsoft Corp.  1987, 1990                */
/*                           All Rights Reserved                            */
/*                                                                          */
/****************************************************************************/

/*********************** START OF SPECIFICATIONS *****************************/
/*                                                                           */
/* Source File Name: BMSMAIN.H                                               */
/*                                                                           */
/* Descriptive Name: Provides equates and structure formats used throughout  */
/*                   the mouse subsystem.                                    */
/*                                                                           */
/* CopyRight: (c) IBM Corp. 1987, 1989                                       */
/*                                                                           */
/* Status: OS/2 Release 2.00                                                 */
/*                                                                           */
/* Function: Provides the control block format of the mouse subsystem screen */
/*           group data and provides stack frame formats for                 */
/*           MOUOPEN, and MOUXXXX calls.                                     */
/*                                                                           */
/* Entry Points: None                                                        */
/*                                                                           */
/* External References:                                                      */
/* Routines:   None                                                          */
/*                                                                           */
/* Data: None                                                                */
/*                                                                           */
/* Notes:                                                                    */
/*   Dependencies: Format and length of the Fast Safe RAM                    */
/*                                                                           */
/*   Restrictions:                                                           */
/*                                                                           */
/*********************** END OF SPECIFICATIONS *******************************/

/*****************************************************************************/
/*      Declaration of Constants                                             */
/*****************************************************************************/
#define WAIT                    3     /* Wait option                         */
#define INITDONE                1     /* Global init done for Mouse Exists   */
#define LOADMODULEDONE          4     /* PM modules loaded                   */
#define MAX_SHAPE_STRUCT_LEN    4     /* Maximum length of Shape Structure   */
#define MAX_THRESH_STRUCT_LEN   10    /* Maximum length of Threshold Struc   */
#define MIN_THRESH_STRUCT_LEN   2     /* Minimum length of Threshold Struc   */
#define READ_EVENT_FLAG         2     /* MouSynch flag for ReadEventQue call */
#define NON_READ_EVENT_FLAG     0     /* MouSynch flag for NonReadEventQue   */
#define SYNCH_WAIT_FLAG         1     /* Flag set to WAIT INDEFINITE         */
#define READ_EVENT_FUNC_CODE    4     /* MouReadEventQue function code       */

/*****************************************************************************/
/*      MOU call function code equates                                       */
/*****************************************************************************/
#define MOUGETNUMBUTTONS        0x0
#define MOUGETNUMMICKEYS        0x1
#define MOUGETDEVSTATUS         0x2
#define MOUGETNUMQUEEL          0x3
#define MOUREADEVENTQUE         0x4
#define MOUGETSCALEFACT         0x5
#define MOUGETEVENTMASK         0x6
#define MOUSETSCALEFACT         0x7
#define MOUSETEVENTMASK         0x8
#define MOUGETTHRESHOLD         0x9
#define MOUSETTHRESHOLD         0xA
#define MOUOPEN                 0xB
#define MOUCLOSE                0xC
#define MOUGETPTRSHAPE          0xD
#define MOUSETPTRSHAPE          0xE
#define MOUDRAWPTR              0xF
#define MOUREMOVEPTR            0x10
#define MOUGETPTRPOS            0x11
#define MOUSETPTRPOS            0x12
#define MOUFLUSHQUE             0x14
#define MOUSETDEVSTATUS         0x15

/*****************************************************************************/
/*      Mouse IOCTL function code equates (Also see IoctlTable in BMSMAIN.C) */
/*****************************************************************************/
#define MOUSECONTROL            0x7     /* Category code for MOUSE IOCtl's   */
#define MICKEYS                 0x61    /* Get mouse mickey count            */
#define BUTTONS                 0x60    /* Get mouse button count            */
#define VERSION                 0x6A    /* Get mouse version number          */
#define SETDRAW                 0x5A    /* Set pointer draw routine address  */
#define GETSHAPE                0x68    /* Get current pointer shape         */
#define GETTHRESH               0x69    /* Get Current threshold values      */

/*****************************************************************************/
/*      Pointer draw IOCTL function code equates                             */
/*****************************************************************************/
#define PTRCONTROL              0x3   /* Category code for POINTERDRAW IOCtl */
#define GETDRAW                 0x72    /* Get pointer draw routine address  */

/*****************************************************************************/
/*      Stackframe for general MouXxx calls                                  */
/*****************************************************************************/

typedef struct STACKFRAME {
  USHORT Local[2];                      /* Stuff that BMSMAIN pushes         */
  USHORT PushAll[10];
  ULONG  MouRetAddr;                    /* Far address back to MouRout()     */
  USHORT CallerDS;                      /* Original caller's DS              */
  USHORT NearIP;                        /* Address back to MouXXX worker     */
  USHORT FunctionNum;                   /* Function number passed from Mouxxx*/
  ULONG  CallerRetAddr;                 /* Far return addr of original caller*/
  USHORT DeviceHandle;                  /* Mouse device handle               */
  PUSHORT *Parm1of2;                    /* 1st of 2 parameter arguments      */
                                        /*   or 2nd of 3 parameter arguments */
  PUSHORT *Parm1of3;                    /* 1st of three parameter arguments  */
} _STACKFRAME;
typedef _STACKFRAME far *PSTACKFRAME;

/*****************************************************************************/
/*      Stackframe for MOUOPEN calls                                         */
/*****************************************************************************/
struct OPENPROT {
  USHORT Local[2];                      /* Stuff that BMSMAIN pushes         */
  USHORT PushAll[10];
  ULONG  MouRetAddr;                    /* Far address back to MouRout()     */
  USHORT CallerDS;                      /* Original caller's DS              */
  USHORT NearIP;                        /* Address back to MouXXX worker     */
  USHORT FunctionNum;                   /* Function number passed from Mouxxx*/
  ULONG  CallerRetAddr;                 /* Far return addr of original caller*/
  ULONG  HandleAddress;                 /* Address to return mouse handle    */
  ULONG  DrawNamePtr;                   /* Pointer draw name address         */
};

typedef struct SGCB far *PSGCB;         /* Far Pointer to Screen Group CB    */

#define TextCBSize   sizeof(struct TextCB)
#define AMSCBSize    sizeof(struct AMSCB)

/*****************************************************************************/
/*      Get Pointer Draw Entry and Data Segment Address                      */
/*****************************************************************************/
typedef struct _DrawData
 {
   USHORT          Error;               /* Draw routine return code  **      */
   ULONG           DrawAddress;         /* Draw routine address      ** KEEP */
   USHORT          DrawDS;              /* Draw routine Data Selector** THIS */
   USHORT          Reserved;            /* Reserved (=0) for IOMW_SD ** ORDER*/
                                        /*   and IOMW_RS IOCTLs      **      */
 } DrawData;
typedef DrawData FAR *PDrawData;        /* Defect 060982 Pointer to struct */

/*****************************************************************************/
/* Instance data externs (defined in bmscalls.asm)                           */
/*****************************************************************************/
extern USHORT currSG;              /* Current screen group #            */
extern USHORT currTYPE;            /* Current screen group Type         */
extern USHORT currPID;             /* Current process ID                */
extern USHORT hConsole;            /* Console handle for windowed VIO   */
extern USHORT MouOpenCnt;          /* Number times mouse opened         */
extern USHORT WTMouseHandle;       /* Mouse Handle for windowed VIO     */
extern struct SGCB far *sgdata_el; /* Screen group data pointer         */
#pragma same_seg(currSG, currTYPE, currPID,\
                 hConsole, MouOpenCnt, WTMouseHandle, sgdata_el)
