I'm in the middle of adding custom Windows Touchpad handling into my Windows C++ desktop application. From a high level, the app has its own cursor and objects that can be clicked. The cursor needs to be directly controlled by a Windows Precision Touchpad, and completely decoupled from the standard Windows mouse. I'm accomplishing this via processing raw input from WM_INPUT messages, and using low level mouse hooks to prevent controlling the normal mouse pointer.
I'm able to interpret single and multi-finger gestures just fine using the WM_INPUT data, but haven't figured out how to get "clicks" or "taps" from the touchpad. Legacy Mouse Input events will obviously not work for my use case since they:
Are clicks/taps contained in the WM_INPUT reports, and I'm just not able to find them, or is there another way I can capture raw clicks from only the touchpad in my application?
您可以使用 PostMessage(applicationWinhandle,WM_INPUT,wparam,mouseDeviceHandle) 向您的应用程序发送 WM_INPUT 消息,然后挂钩 GetRawInputData 或 GetRawInputBuffer 发送数据。
RAWMOUSE struct that comes with WM_INPUT
mouse message contains usButtonFlags
with mouse button up/down transition state.
You cannot get clicks/taps because AFAIK classic Win32 API is not suitable for touch input at all - it just emulating mouse in case of touchpad.
According to touchpad spec all compatible Windows Precision Touchpad
's are HID devices that are sending touchpad data in their Input Reports
. They should contain corresponding Top Level Collection Page 0x0D
(Digitizers), Usage 0x05
(Touch Pad) - and this will be seen as separate HID device from Win32 user-mode. See sample HID Report Descriptor .
Knowing this you can register to receive touchpad data with RegisterRawInputDevices
call. After that you'll receive WM_INPUT
message with RAWHID struct for each tounchpad input report - this needs to be handled manually (according to device's Preparsed HID Report Descriptor Data etc).
It's not easy but doable.
See example code here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.