Reputation: 166
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?
Upvotes: 2
Views: 1641
Reputation: 1431
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.
Update: Also there are WM_TOUCH and WM_GESTURE messages available since Windows 7. Maybe its what you're looking for. Sample code.
Upvotes: 5
Reputation: 1
you can use PostMessage(applicationWinhandle, WM_INPUT, wparam, mouseDeviceHandle)
send WM_INPUT
message to your application, and then hook GetRawInputData
or GetRawInputBuffer
to send data.
Upvotes: 0