Is there a way to开发者_开发知识库 have one raw input buffer per device?
So I would like to have a buffer for mouse and another one for keyboard. Is it possible?
Yes, try SetWindowsHookEx. You will have to convert WM_KEY* messages to WM_CHAR yourself, though.
The answer to your question is YES
The RAWINPUTDEVICE struct permits this via usUsagePage and usUsage
usUsagePage is a value for the type of device (this is a partial list below). 1 is for 'generic desktop controls' and covers all the usual input devices. The usUsage value specifies the device within the 'generic desktop controls' group.
1 - generic desktop controls // we use this
2 - simulation controls
3 - vr
4 - sport
5 - game
6 - generic device
7 - keyboard
8 - LEDs
9 - button
usUsage values when usUsagePage is 1:
0 - undefined
1 - pointer
2 - mouse
3 - reserved
4 - joystick
5 - game pad
6 - keyboard // we use this
7 - keypad
8 - multi-axis controller
9 - Tablet PC controls
I wrote this article on Code Project that may be helpful.
精彩评论