Multiple keyboards and low-level hooks

前端 未结 2 938
粉色の甜心
粉色の甜心 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:16

    No way to do this. Windows abstracts this for you. As mentioned, you need to write/modify a device driver.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题