mou_win32---.c
来自「使用miniGUI模拟器的简单开发例子(值得参考)」· C语言 代码 · 共 133 行
C
133 行
//-----------------------
//mou_win32.c
/*
* Copyright (c) 2005, Wilson Loi wlsloi@msn.com
* WIN32 screen driver for Microwindows
*/
#include <stdio.h>
//#include "device.h"
#include "common.h"
#include "ial.h"
#include "gal.h"
#include "Native.h"
//#include <windows.h>
//#include <windowsx.h>
//extern HWND rootWindow;
#define SCALE 3 /* default scaling factor for acceleration */
#define THRESH 5 /* default threshhold for acceleration */
static int Mou_Open(MOUSEDEVICE *pmd);
static void Mou_Close(void);
static int Mou_GetButtonInfo(void);
static void Mou_GetDefaultAccel(int *pscale,int *pthresh);
static int Mou_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp);
static int Mou_Poll(void);
MOUSEDEVICE mousedev = {
Mou_Open,
Mou_Close,
Mou_GetButtonInfo,
Mou_GetDefaultAccel,
Mou_Read,
Mou_Poll,
MOUSE_NORMAL /* flags*/
};
/*
* Poll for events
*/
static int
Mou_Poll(void)
{
return 1;
}
/*
* Open up the mouse device.
*/
static int
Mou_Open(MOUSEDEVICE *pmd)
{
// return -2; /* no mouse*/
return 1;
}
/*
* Close the mouse device.
*/
static void
Mou_Close(void)
{
}
/*
* Get mouse buttons supported
*/
static int
Mou_GetButtonInfo(void)
{
return MWBUTTON_L | MWBUTTON_M | MWBUTTON_R;
}
/*
* Get default mouse acceleration settings
*/
static void
Mou_GetDefaultAccel(int *pscale,int *pthresh)
{
*pscale = SCALE;
*pthresh = THRESH;
}
/*
* Attempt to read bytes from the mouse and interpret them.
* Returns -1 on error, 0 if either no bytes were read or not enough
* was read for a complete state, or 1 if the new state was read.
* When a new state is read, the current buttons and x and y deltas
* are returned. This routine does not block.
*/
typedef struct _tagMSG { // msg
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG_W;
extern MSG_W *winMsg;
///houhh 20061119...
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
//////
static int
Mou_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp)
{
if (winMsg)
{
*dx = GET_X_LPARAM(winMsg->lParam);
*dy = GET_Y_LPARAM(winMsg->lParam);
*dz = 0;
*bp = 0;
if (winMsg->wParam & 1)
{
*bp |= MWBUTTON_L;
}
if (winMsg->wParam & 16)
{
*bp |= MWBUTTON_M;
}
if (winMsg->wParam & 2)
{
*bp |= MWBUTTON_R;
}
return 2;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?