⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmouse.h

📁 A 2D game engine for C++ and an example : Aero Blasters
💻 H
字号:
#define MOUSE_INT               0x33


void ScanMouse 		(int *x,int *y,int *buttons);
void SenseMouse		(int x,int y);
void ShowMouse 		(void);
void FeelMouse 		(int *x,int *y);
void HideMouse 		(void);
void WaitMouse 		(void);
int  GetButton          (void);

int GetButton   (void)
 {
   int a,b,c;
   ScanMouse(&a,&b,&c);
   return(c);
 }

  void WaitMouse (void)
    {
    int x,y,b;
    b=0;
    while(!(b>0))
    { ScanMouse(&x,&y,&b); if (kbhit) { break; } }

    }

void HideMouse (void)
		{
		// this function decrements the inrternal show.mouse
		// counter. When it's equal to -1, the mouse is
		// hidden.
		union REGS inregs,outregs;
		inregs.x.ax = 0x02;
		// subfunction 2: decrement the show flag
		int86(MOUSE_INT,&inregs,&outregs);
		}

void ScanMouse(int *x,int *y,int *buttons)
{
  union REGS inregs,outregs;

  inregs.x.ax = 0x03;
  int86(MOUSE_INT,&inregs,&outregs);
		*x       = outregs.x.cx;
		*y       = outregs.x.dx;
		*buttons = outregs.x.bx;
 }

void SenseMouse(int x,int y)
		{
		union REGS inregs,outregs;
		// this function sets the overall "sensitivity" of
		// the mouse. Each axis can have a sensitivity of
		// from 1-100, so the caller should put 1-100 in both
		// x and y before calling. Also "buttons" is used to
		// send in the double speed value, which also ranges
		// from 1-100.

		inregs.x.bx = x;
		inregs.x.cx = y;

		inregs.x.ax = 0x1A;
		// subfunction 26: set sensitivity
		int86(MOUSE_INT,&inregs,&outregs);
		}

	 void ShowMouse(void)
		{
	 union REGS inregs,outregs;

		inregs.x.ax = 0x01;
		int86(MOUSE_INT,&inregs,&outregs);
		}



	 void FeelMouse (int *x,int *y)
		{
	      union REGS inregs,outregs;
		// this function gets the relative mouse motions from
		// the last call and puts them in the variable x,y.
		inregs.x.ax = 0x0B;
		// subfunction 11: get relative motion
		int86(MOUSE_INT,&inregs,&outregs);

		// extract the info and send it back to caller by
		// using pointers.
		*x       = outregs.x.cx;
		*y       = outregs.x.dx;

		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -