Multiple keyboards and low-level hooks

前端 未结 2 941
粉色の甜心
粉色の甜心 2020-12-05 05:52

I have a system where I have multiple keyboards and really need to know which keyboard the key stroke is coming from. To explain the set up:

  1. I have a normal P
2条回答
  •  春和景丽
    2020-12-05 06:26

    Yes I stand corrected, my bad, learning something new every day.

    Here's my attempt at making up for it :) :

    • Register the devices you want to use for raw input (the two keyboards) with ::RegisterRawInputDevices().

    • You can get these devices from GetRawInputDeviceList()

    • After you've registered your devices, you will start getting WM_INPUT messages.

    • The lParam of the WM_INPUT message contains a RAWKEYBOARD structure that you can use to determine the keyboard where the input came from, plus the virtual keycode and the type of message (WM_KEYDOWN, WM_KEYUP, ...)

    • So you can set a flag of where the last message came from and then dispatch it to the regular keyboard input handlers.

提交回复
热议问题