c++ - Detect if WM_MOUSEMOVE is caused by touch/pen -


i experimenting wm_touch , want detect if mouse events synthesized touch/pen events or due actual mouse event.

the official solution according msdn check if result of getmessageextrainfo() has upper 24 bits set 0xff515700.

this works. most of time. if use 1 finger, , good, if use more one, releasing last 1 causes mouse move getmessageextrainfo() == 0. also, when window loses focus via touch, 3 mouse move messages getmessageextrainfo() == 0 generated.

is there reliable way of disambiguating between mouse, touch , pen inputs?

the link posted show reliable way discern between mouse messages generated physical mouse, , synthesized in response touch , pen input.

for completeness, here working code. code relies on state valid while handling mouse message. calling @ other time has undefined behavior:

bool istouchevent() {     const long_ptr c_signature_mask = 0xffffff00;     const long_ptr c_mouseeventf_fromtouch = 0xff515700;      long_ptr extrainfo = getmessageextrainfo();     return ( ( extrainfo & c_signature_mask ) == c_mouseeventf_fromtouch ); } 

the additional wm_mousemove messages observing, artifact of how system implements internal bookkeeping. example, if window shown or hidden, mouse cursor may on different window now, , needs recalculated. this, system synthesizes artificial wm_mousemove message.

this effect explained in raymond chen's blog: why spurious wm_mousemove messages?.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -