赞
踩
//关于raw input 请查看msdn https://msdn.microsoft.com/en-us/library/windows/desktop/ms645536%28v=vs.85%29.aspx
//效率 比 键盘钩子高太多 ,但是BCB 中无法识别 RAWINPUTDEVICE 结构 和RAW相关的函数
//rawinput4.cpp : 定义应用程序的入口点。//#include"stdafx.h"#include"rawinput4.h"#include#include#include
using namespacestd;#define MAX_LOADSTRING 100
//全局变量:
HINSTANCE hInst; //当前实例
TCHAR szTitle[MAX_LOADSTRING]; //标题栏文本
TCHAR szWindowClass[MAX_LOADSTRING]; //主窗口类名
setkeys;//避免按住不放不停的响应keydown
boolIsInKeys(DWORD key)
{set::iterator itor =find(keys.begin(),keys.end(),key);bool result = false;if (itor ==keys.end())
{
keys.insert(key);
result= false;
}else{
result= true;
}returnresult;
}//松开的时候,将key从set中移除
voiderasekey(DWORD key)
{
keys.erase(key);
}//此代码模块中包含的函数的前向声明:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE,int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);voidRegKeyboardRawInput(HWND hwnd)
{
RAWINPUTDEVICE Rid[1];
Rid[0].usUsagePage = 0x01;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。