Windows键重复设置会影响原始输入消息 [英] Windows key repeat settings affecting Raw Input messages

查看:93
本文介绍了Windows键重复设置会影响原始输入消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该是直接从设备输入的RAW,奇怪的是它受到以下设置的影响:

直到延迟之后,它才会收到WM_INPUT消息.重复率也会影响它.我也尝试过用NO_LEGACY标志注册原始输入设备,没有区别.这与DirectX11应用程序有关,我遇到了这个问题.

case WM_INPUT: {Input::handleInput(uMsg, wParam, lParam); break; }

解决方案

显然没有办法解决它,gamedev教程解释说,您只需要使用自己复杂的解决方法在代码中进行处理即可.原始输入我的a $ se Microsoft.

发生的事情是,当您按住一个键时,WM_INPUT将发送一个按下消息,等待直到Windows键重复延迟"结束,然后继续以Windows的键重复速度"设置发送键消息. /p>

我发现,与其使用Makecode或Vkey成员,不如使用keyboard.flags成员更容易,因为(对于大多数键)当某个键按下时,此标志将为零;当该键按下时,该标志将为零.设置为1,则可以通过以下方式对其进行反转:

 switch (mpRawInput->data.keyboard.VKey)
        {
        case VK_W: Input::mIsKeyDown[VK_W] = !mpRawInput->data.keyboard.Flags;  break;
        case VK_A: Input::mIsKeyDown[VK_A] = !mpRawInput->data.keyboard.Flags; break;
        case VK_S: Input::mIsKeyDown[VK_S] = !mpRawInput->data.keyboard.Flags; break;
        case VK_D: Input::mIsKeyDown[VK_D] = !mpRawInput->data.keyboard.Flags; break;
        case VK_SPACE: Input::mIsKeyDown[VK_SPACE] = !mpRawInput->data.keyboard.Flags;
        }      

使用keyboard.flag 0或1值表示当您按下一个键时,您会得到0的标志消息,因此将与它相反的消息发送给"isKeyDown" bool.松开该键时,标志将设置为1.

对于其他键,您需要解决方法,例如,在num lock处于打开状态时,箭头键的标志值是3;在num lock处于关闭状态时,其标志值是正常的.其他按键的行为完全不同,例如打印屏幕"和暂停/中断".真是一团糟.

It's supposed to be RAW input direct from the device, this is strange that it's affected by these settings:

It won't get a WM_INPUT message until after the delay. Also the repeat rate is affecting it. I've tried also registering the raw input device with NO_LEGACY flag, no difference. This is with a DirectX11 application I'm having this problem.

case WM_INPUT: {Input::handleInput(uMsg, wParam, lParam); break; }

解决方案

There is no way to get around it apparently, a gamedev tutorial explained that you just have to handle it in your code with your own convoluted workarounds. Raw Input my a$se Microsoft.

What happens is when you press and hold a key WM_INPUT will send one key down message, wait until the Windows "key repeat delay" has elapsed, and then continue sending key messages at the Windows "key repeat speed" setting.

I found that instead of using the Makecode or Vkey member, it's just easier to use the keyboard.flags member, because (for most keys) when a key is down this flag will be zero, and when it's up the flag will be set to 1, so you can just invert it by:

 switch (mpRawInput->data.keyboard.VKey)
        {
        case VK_W: Input::mIsKeyDown[VK_W] = !mpRawInput->data.keyboard.Flags;  break;
        case VK_A: Input::mIsKeyDown[VK_A] = !mpRawInput->data.keyboard.Flags; break;
        case VK_S: Input::mIsKeyDown[VK_S] = !mpRawInput->data.keyboard.Flags; break;
        case VK_D: Input::mIsKeyDown[VK_D] = !mpRawInput->data.keyboard.Flags; break;
        case VK_SPACE: Input::mIsKeyDown[VK_SPACE] = !mpRawInput->data.keyboard.Flags;
        }      

Using the keyboard.flag 0 or 1 value means when you press a key you get a flag message of 0, so you send the opposite of that to "isKeyDown" bool. When that key is lifted the flag will be set to 1.

For other keys keys you need workarounds, for example the arrow keys have a flag value of 3 when the num lock is on, and normal when it's off. Other keys behave entirely different like "Print Screen" and "Pause/Break". What a total mess.

这篇关于Windows键重复设置会影响原始输入消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆