The*_*ark 2 c++ keyboard winapi raw-input
我刚刚开始为我的应用程序使用Raw Input。直截了当地问这个问题,可以在旧WM_KEYDOWN消息lParam中检查以获得有关按键的其他信息。像这些-
Bits Meaning
0-15 The repeat count for the current message.
The value is the number of times the keystroke is autorepeated as a
result of the user holding down the key. If the keystroke is
held long enough, multiple messages are sent. However, the repeat
count is not cumulative.
16-23 The scan code. The value depends on the OEM.
24 Indicates whether the key is an extended key, such as the right-hand
ALT and CTRL keys that appear on an enhanced 101- or 102-key
keyboard. The value is 1 if it is an extended key; otherwise, it is
0.
25-28 Reserved; do not use.
29 The context code. The value is always 0 for a WM_KEYDOWN message.
30 The previous key state. The value is 1 if the key is down before the
message is sent, or it is zero if the key is up.
31 The transition state. The value is always 0 for a WM_KEYDOWN
message.
Run Code Online (Sandbox Code Playgroud)
我想知道WM_INPUT消息是否针对重复的键,因此我可以忽略该消息。(请关闭keyrepeat。)
我遇到的麻烦是找不到该WM_INPUT消息的信息。的lParam所述的WM_INPUT消息中包含的句柄RAWINPUT结构。经过研究,我发现其中RAWINPUT::header包含一个名为wparam的成员,MSDN将其描述为
wParam类型:在消息WPARAM的wParam参数中传递的值WM_INPUT。
我可以在这里找到所需的信息还是在其他地方?
RAW输入API不提供重复计数。它是直接来自键盘的原始数据。WM_KEY...生成消息时,将在更高级别上计算重复计数。使用WM_INPUT,您将必须手动跟踪每个键的向下/向上状态,以确定您自己的重复计数。当某个键失效时,开始计算WM_INPUT该键的每条消息。当钥匙升起时,停止计数。