📄 mous0.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1997 - 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* MOUS0.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the InitMouse, QueryMouse, StopMouse, */
/* ReadMouse, LimitMouse, ScaleMouse, SetMouse & MaskMouse functions. */
/* */
/* AUTHOR */
/* */
/* Robert G. Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 11/22/99 Corrected mouse search algorithm */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
#include "wndo.h"
int StopMouse(void);
extern long mwIdevTbl[];
/* Function InitMouse looks up the passed input device code in our internal
table, inits the current mouse record accordingly, then opens it.
If the device code is USER, then it is not initialized (assumed to be by
the user) and is opened.
Returns 0 if ok, 1 if already inited, -1 if problems. */
int InitMouse(int argDEV)
{
short grafErrValue; /* error value */
short mrMgrFnct;
long memPntr;
long *mwIdevTblPtr;
void mwInputCB(void);
void nuSegInfo(void);
/* set call back vector to posting/tracking function */
curInput->mrCallBack = (long)mwInputCB;
if (argDEV != cUSER) /* if user device, skip init */
{ /* init device */
curInput->mrEvent.evntSource = argDEV; /* set device ID */
/* set default coordinate limits to match cursor bitmap */
curInput->mrLimits.Xmin = 0;
curInput->mrLimits.Ymin = 0;
curInput->mrLimits.Xmax = cursBlit.blitDmap->pixWidth;
curInput->mrLimits.Ymax = cursBlit.blitDmap->pixHeight;
/* set default position to center of limits */
curInput->mrEvent.evntX = (cursBlit.blitDmap->pixWidth >> 1);
curInput->mrEvent.evntY = (cursBlit.blitDmap->pixHeight >> 1);
/* set default scale to 1/1 */
curInput->mrScale.X = 1;
curInput->mrScale.Y = 1;
/* set default event mask to press,release, and position */
curInput->mrEventMask = mPRESS + mREL + mPOS;
/* set default event data */
curInput->mrEvent.evntChar = 0;
curInput->mrEvent.evntScan = 0;
curInput->mrEvent.evntState = 0;
curInput->mrEvent.evntButtons = 0;
/* try to find an internal manager for this device */
mwIdevTblPtr = &mwIdevTbl[0]; /* address to start of device tbl */
while (*mwIdevTblPtr != 0xffff) /* last entry? */
{
if (*mwIdevTblPtr == argDEV) goto srchFound; /* Device codes match? */
/* BobB 11/22/99 - corrected mouse search algorithm
mwIdevTblPtr += 3; */ /* no, keep looking */
mwIdevTblPtr += 2; /* no, keep looking */
}
grafErrValue = c_InitMous + c_BadDev; /* found nothing */
nuGrafErr(grafErrValue); /* report error */
return(-1);
srchFound:
mwIdevTblPtr++; /* point to next word*/
/* store manager vector */
curInput->mrInputMgr = *mwIdevTblPtr;
/* BobB 11/22/99 - corrected mouse search algorithm
mwIdevTblPtr++; */ /* point to last word*/
/* curInput->mrInputMgr |= (*mwIdevTblPtr << 16); */
}
if (curInput->mrFlags & mrOpenedSig) return(1); /* is it already opened? */
mrMgrFnct = IMOPEN;
mrMgrFnct = CallmrInputMgr(curInput, mrMgrFnct); /* open the device */
/* returns 0 if ok, -1 if can't open */
if (mrMgrFnct != 0) return(mrMgrFnct);
curInput->mrFlags = mrOpenedSig; /* ok, so flag as opened */
#if CPU386 /* lock memory used by Mouse ISR */
memPntr = (long) &ISR_STACK; /* lock grafdata */
CallmwLockMem(memPntr, 12000);
memPntr = (long) (curInput->mrInputMgr); /* lock ISR and related code */
CallmwLockMem(memPntr, 4000);
memPntr = (long) nuSegInfo; /* lock mwSegInfo */
CallmwLockMem(memPntr, 50);
memPntr = (long) mwInputCB; /* lock mwInputCB */
CallmwLockMem(memPntr, 100);
#endif
stpMouseIDV = StopMouse; /* Smart link StopMouse vector */
return(0); /* return ok */
}
/* Function QueryMouse returns;
0 = if the input device indicated by argIDEV is detected.
1 = detected as not there
-1 = can't tell for sure or don't know
2 = don't know what device you are talking about */
int QueryMouse(short argDEV)
{
long *mwIdevTblPtr;
short mrMgrFnct;
/* find the input device manager */
mwIdevTblPtr = &mwIdevTbl[0]; /* address to start of device tbl */
while (*mwIdevTblPtr != 0xffff) /* last entry? */
{
if (*mwIdevTblPtr == argDEV) goto srchFound; /* Device codes match? */
/* BobB 11/22/99 - corrected mouse search algorithm
mwIdevTblPtr += 3; */ /* no, keep looking */
mwIdevTblPtr += 2; /* no, keep looking */
}
return(2);
srchFound:
mwIdevTblPtr++; /* point to next word*/
/* store manager vector */
curInput->mrInputMgr = *mwIdevTblPtr;
/* BobB 11/22/99 - corrected mouse search algorithm
mwIdevTblPtr++; */ /* point to last word*/
/* curInput->mrInputMgr |= (*mwIdevTblPtr << 16); */
mrMgrFnct = IMQUERY; /* open the device */
mrMgrFnct = CallmrInputMgr(curInput, mrMgrFnct);
return(mrMgrFnct);
}
/* Function StopMouse closes the current input device Returns 0 if ok,
1 if already inited, -1 if problems. */
int StopMouse(void)
{
short mrMgrFnct;
/* was it ever opened? */
if (!(curInput->mrFlags & mrOpenedSig)) return(1); /* no, dont close it! */
curInput->mrFlags = 0; /* clear the flags */
mrMgrFnct = IMCLOSE; /* close the device */
mrMgrFnct = CallmrInputMgr(curInput, mrMgrFnct);
return(mrMgrFnct);
}
/* Function ReadMouse returns the current position and button information
for the current input device. */
void ReadMouse(int *argX, int *argY, int* argButtons)
{
*argX = curInput->mrEvent.evntX; /* place in passed vars */
*argY = curInput->mrEvent.evntY;
*argButtons = curInput->mrEvent.evntButtons;
return;
}
/* Function LimitMouse sets the current input devices limit rect. This is
the range of input values that the input device will return. */
void LimitMouse(int argX1, int argY1, int argX2, int argY2)
{
short mrMgrFnct;
/* call the current input devices manager to set the limits */
curInput->mrLimits.Xmin = argX1;
curInput->mrLimits.Ymin = argY1;
curInput->mrLimits.Xmax = argX2;
curInput->mrLimits.Ymax = argY2;
mrMgrFnct = IMLIMIT; /* call the device */
mrMgrFnct = CallmrInputMgr(curInput, mrMgrFnct);
return;
}
/* Function ScaleMouse sets the current input devices scale factors.
This sets the amount of movement per coordinate that the device returns.
Absolute positioning devices will not honor this call. */
void ScaleMouse(int argRX, int argRY)
{
short mrMgrFnct;
/* call the current input devices manager to set scaling */
curInput->mrScale.X = argRX;
curInput->mrScale.Y = argRY;
mrMgrFnct = IMSCALE; /* call the device */
mrMgrFnct = CallmrInputMgr(curInput, mrMgrFnct);
return;
}
/* Function SetMouse sets the passed mouse record as the current input
device. */
void SetMouse(mouseRcd *argMouseR)
{
/* test for null (= set internal default) */
if (argMouseR == 0) argMouseR = &defMouse;
curInput = argMouseR; /* set current input */
return;
}
/* Function MaskMouse sets the mask for the current input device. */
void MaskMouse(int argMask)
{
curInput->mrEventMask = argMask; /* set mask */
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -