#define LEFTBUTTON 0x0001 #define RIGHTBUTTON 0x0002 #define MIDBUTTON 0x0004 #define MOUSEBUTTONMASK 0x00FF
#define SHIFTBUTTON 0x0100 #define CONTROLBUTTON 0x0200 #define ALTBUTTON 0x0400 #define METABUTTON 0x0800 #define KEYBUTTONMASK 0x0FFF #define KEYPAD 0x4000
(2)定义并初始化与输入事件相关的参数
static int mouse_fd = -1; //鼠标文件描述符 static int kbd_fd = -1; //键盘文件描述符 static POINT mouse_pt; //鼠标位置 static int mouse_buttons; //鼠标按键
static struct QVFbKeyData kbd_data; //键盘数据 static unsigned char kbd_state [NR_KEYS]; //键盘状态 static unsigned char keycode_scancode [256];//键盘扫描码 static unsigned char nr_changed_keys = 0;
(3)static void init_code_map (void)
函数作用:初始化键盘扫描码
(4)static unsigned char keycode_to_scancode (unsigned char keycode, BOOL asscii)
函数作用:将键盘扫描码转化为ASCII码
(5)static int mouse_update (void)
函数作用:更新鼠标信息mouse_pt和mouse_buttons
(6)static void mouse_getxy (int *x, int* y)
函数作用:获得鼠标的位置信息 *x = mouse_pt.x;
*y = mouse_pt.y;
(7)static int mouse_getbutton (void)
函数作用:获取鼠标的button信息
(8)static int keyboard_update (void)
函数作用:更新鼠标信息,返回nr_changed_keys;
(9)static int read_key (void)
函数作用:读取键盘按键
(10)static const char* keyboard_getstate (void)
函数作用:获取键盘状态,return (char*)kbd_state;
(11)static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)
函数作用:从文件描述符获得输入事件,返回输入事件的类型
(12)BOOL InitQVFBInput (INPUT* input, const char* mdev, const char* mtype)
函数作用:初始化输入引擎,设置键盘和鼠标的文件描述符,为确定输入引擎的对输入事件的处理函数。
(13)void TermQVFBInput (void)
函数作用:关闭鼠标和键盘描述符。
if (mouse_fd >= 0) close (mouse_fd); if (kbd_fd >= 0) close (kbd_fd);
9、window.h与窗口和消息相关的宏定义和数据结构
(1)宏定义各种消息类型 (2)消息的数据结构MSG
typedef struct _MSG {
/** The handle to the window which receives this message. */ /** The message identifier. */ HWND hwnd; int message;
/** The first parameter of the message (32-bit integer). */ WPARAM wParam;
/** The second parameter of the message (32-bit integer). */ LPARAM lParam; /** Time*/
unsigned int time; #ifndef _LITE_VERSION /** Addtional data*/ void* pAdd; #endif } MSG;
typedef MSG* PMSG;
(3)宏定义消息队列的相关参数
#define QS_NOTIFYMSG 0x10000000 #ifndef _LITE_VERSION
#define QS_SYNCMSG 0x20000000 #else
#define QS_DESKTIMER 0x20000000 #endif
#define QS_POSTMSG 0x40000000 #define QS_QUIT 0x80000000 #define QS_INPUT 0x01000000 #define QS_PAINT 0x02000000 #define QS_TIMER 0x0000FFFF #define QS_EMPTY 0x00000000
(4)获得消息时用到的宏定义
#define PM_NOREMOVE 0x0000 #define PM_REMOVE 0x0001 #define PM_NOYIELD 0x0002
(5)声明各种消息处理函数,如获得消息、等待消息等 (6)宏定义键盘分布的相关参数和键盘信息处理函数
#define KBD_LAYOUT_DEFAULT \ #define KBD_LAYOUT_FRPC \ #define KBD_LAYOUT_FR \ #define KBD_LAYOUT_DE \ #define KBD_LAYOUT_DELATIN1 \ #define KBD_LAYOUT_IT \ #define KBD_LAYOUT_ES \ #define KBD_LAYOUT_ESCP850 \
(7)宏定义hook相关的参数和函数 (8)宏定义窗口相关参数 (9)定义主窗口数据结构
typedef struct _MAINWINCREATE {
/** The style of the main window */ DWORD dwStyle;
/** The extended style of the main window */ DWORD dwExStyle;
/** The caption of the main window */ const char* spCaption;
/** The handle to the menu of the main window */ HMENU hMenu;
/** The handle to the cursor of the main window */ HCURSOR hCursor;
/** The handle to the icon of the main window */ HICON hIcon;
/** The hosting main window */ HWND hHosting;
/** The window callback procedure */
int (*MainWindowProc)(HWND, int, WPARAM, LPARAM);
/** The position of the main window in the screen coordinates */ int lx, ty, rx, by;
/** The pixel value of background color of the main window */ int iBkColor;
/** The first private data associated with the main window */ DWORD dwAddData;
/** Reserved, do not use */ DWORD dwReserved; }MAINWINCREATE;
typedef MAINWINCREATE* PMAINWINCREATE;
(10)声明窗口创建、显示、获取窗口信息等等与窗口相关的函数 (11)宏定义主窗口的限制参数并声明相关函数
#define MWM_MINWIDTH 0 #define MWM_MINHEIGHT 1 #define MWM_BORDER 2 #define MWM_THICKFRAME 3 。。。。。。
#define MWM_ITEM_NUMBER 31
(12)宏定义颜色信息并声明相关函数
#define BKC_CAPTION_NORMAL 0 #define FGC_CAPTION_NORMAL 1 #define BKC_CAPTION_ACTIVED 2 #define FGC_CAPTION_ACTIVED 3 。。。。。。
#define BKC_DESKTOP 34 #define BKC_DIALOG #define BKC_TIP
/* back compitabilty defines */
#define BKC_BUTTON_DEF WEC_3DBOX_NORMAL #define BKC_BUTTON_PUSHED WEC_3DBOX_DARK #define FGC_BUTTON_NORMAL WED_3DBOX_REVERSE #define FGC_BUTTON_PUSHED WED_3DBOX_REVERSE #define BKC_EDIT_DEF WEC_3DBOX_LIGHT #define BKC_EDIT_DISABLED WEC_3DBOX_NORMAL #define WEC_3DFRAME_LEFT_OUTER WED_3DBOX_REVERSE #define WEC_3DFRAME_LEFT_INNER WEC_3DBOX_DARK #define WEC_3DFRAME_TOP_OUTER WED_3DBOX_REVERSE #define WEC_3DFRAME_TOP_INNER WEC_3DBOX_DARK #define WEC_3DFRAME_RIGHT_OUTER WEC_3DBOX_LIGHT #define WEC_3DFRAME_RIGHT_INNER WEC_3DBOX_NORMAL
35 36
#define WEC_ITEM_NUMBER 37

