gpt4 book ai didi

windows - #include 什么关于窗口的代码,原始鼠标数据

转载 作者:可可西里 更新时间:2023-11-01 09:37:46 24 4
gpt4 key购买 nike

我发现以下帖子对我自己的项目非常有用。那么新手问题是:我必须包含什么才能使其正常工作?

链接: How to accurately measure mouse movement in inches or centimetres for a mouse with a known DPI

内容:

The following code registers the RAWINPUTDEVICE so it can be used in WM_INPUT.

RAWINPUTDEVICE Rid[1];
Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
Rid[0].dwFlags = RIDEV_INPUTSINK;
Rid[0].hwndTarget = hWnd;
RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]);

以下代码实际上使用 Rid 变量来确定自上次启动 WM_INPUT 以来鼠标移动了多少像素。

case WM_INPUT: 
{
UINT dwSize = 40;
static BYTE lpb[40];

GetRawInputData((HRAWINPUT)lParam, RID_INPUT,
lpb, &dwSize, sizeof(RAWINPUTHEADER));

RAWINPUT* raw = (RAWINPUT*)lpb;

if (raw->header.dwType == RIM_TYPEMOUSE)
{
int xPosRelative = raw->data.mouse.lLastX; // Could be 1, or could be more than 1
int yPosRelative = raw->data.mouse.lLastY; // Could be 1, or could be more than 1!
}
break;
}

最佳答案

我刚找到它。
#include "hidusage.h"

这里有一些定义

#define HID_USAGE_GENERIC_POINTER ((USAGE) 0x01)
#define HID_USAGE_GENERIC_MOUSE ((USAGE) 0x02)
#define HID_USAGE_GENERIC_JOYSTICK ((USAGE) 0x04)
#define HID_USAGE_GENERIC_GAMEPAD ((USAGE) 0x05)
#define HID_USAGE_GENERIC_KEYBOARD ((USAGE) 0x06)
#define HID_USAGE_GENERIC_KEYPAD ((USAGE) 0x07)
#define HID_USAGE_GENERIC_SYSTEM_CTL ((USAGE) 0x80)

typedef USHORT USAGE,*PUSAGE;

关于windows - #include 什么关于窗口的代码,原始鼠标数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25823457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com