Feature request: filter out mouse events generated from touches

x64 Replacement/Alternative to Microsoft's IntelliMouse application.
Forum rules
Please read the forum rules before posting for the first time.
The more information you can provide, the quicker and more accurately someone can help.
NOTE: To reduce spam, new users can not post links or images until they have at least 4 posts.
Post Reply
Lurker
New User
Posts: 3
Joined: Fri Jul 19, 2019 10:42 am

Feature request: filter out mouse events generated from touches

Post by Lurker » Fri Jul 19, 2019 11:16 am

XMBC Version: 2.18.7
Windows Version: 10
Mouse Information (brand/model): No
Computer Information: One Netbook One Mix 3
How long have you used XMBC?: 2 days
What language and keyboard layout do you use in Windows?: English

Clear description of the problem:
This small notebook has a touch sensor, which randomly generates mouse left clicks events when I try to position mouse cursor. This is a common problem of such sensors, regardless of manufacturers. The notebook also have two physical buttons for left and right mouse buttons. Unfortunately, it is impossible to disable clicks from the sensor only.

Then I found XMouse Button Control, and set up a Button Held actions:
  • Normal click: Disable
  • Held for 50 ms: Left Click
  • Held for 500ms: Sticky Left Button (I found no a better way to keep "drag/select" functionality, but it's quite handy).
Now the problem is: Windows simulates mouse events along with sending WM_TOUCH message, and then touch-unaware apps (Windows controls!) don't receive mouse clicks events, because they are generated with very small (0?) delay between down and up.

The solution I ask for: optionally, look for WM_TOUCH events, and pass through mouse events which happen too soon after touch events. This way mouse events simulated from touches should work as expected.

From my experience (I'm a programmer, have an experience with touch events under Windows), less than 50ms is enough for "too soon", but it can be adjustable.

Currently, I have to use "tap and click" instead of just tap in most of Windows controls. Frankly, there are situations when I like this approach, because it saves me from accidental touches! But it is always good to have a choice ;)

One more note: If I could set less than 50ms in the "Held for" field, it would be good as well!

Thanks in advance!

User avatar
phil
Site Admin
Posts: 6037
Joined: Sun Apr 06, 2003 11:12 pm

Re: Feature request: filter out mouse events generated from touches

Post by phil » Fri Jul 19, 2019 1:07 pm

Unfortunately the mouse hook that XMBC uses only sees mouse messages, not all windows messages.
Maybe I'm wrong, but I suspect that the WM_TOUCH messages would only be sent to the focus application (not XMBC/global) so unless XMBC injects into every process to monitor their message queues, I don't think this will be possible... and injecting into every process has its own troubles and when I have done things like that in the past, its been less than ideal, causing problems etc.

I can probably reduce the minimum number of ms, although Im not sure how accurate/high precision the time is in the hook events - but it should be ok to go lower than 50ms (its not like WM_TIMER which is only accurate to about 50ms).

Regards,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

Lurker
New User
Posts: 3
Joined: Fri Jul 19, 2019 10:42 am

Re: Feature request: filter out mouse events generated from touches

Post by Lurker » Fri Jul 19, 2019 4:34 pm

OK, the task looks simpler, because you don't actually need to hook touch events. Instead, you need to pass through mouse events produced from touch events.

SetWindowsHookEx with WH_MOUSE_LL, then

Code: Select all

#define MOUSEEVENTF_FROMTOUCH 0xFF515700
if ((((MSLLHOOKSTRUCT*)lParam)->dwExtraInfo & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH)
pass it through. Instead, proceed as you usually do. It should work for both finger touch and pen.

Does it contradict existing XMBC logic?

User avatar
phil
Site Admin
Posts: 6037
Joined: Sun Apr 06, 2003 11:12 pm

Re: Feature request: filter out mouse events generated from touches

Post by phil » Wed Jul 24, 2019 10:42 pm

OK that looks promising...
So if that flag is set then basically just return from the hook without doing anything that XMBC currently does. That shouldn't be a problem!

I'll have to have a play around (I have a surface pro 2 which should generate the required events to test with!).
Consider it added to the TODO list for 2.19 beta 1 (no promises on time though because Ive had no time recently to spend on XMBC Im afraid!).

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

Lurker
New User
Posts: 3
Joined: Fri Jul 19, 2019 10:42 am

Re: Feature request: filter out mouse events generated from touches

Post by Lurker » Thu Jul 25, 2019 12:17 pm

I've already written an app that solves my problem. I've published it along with the source code, so you can check the logic behind it. Feel free to extend your app with new features, if you find them useful for your users :) AFAIK my app currently is the only solution for the problem with touch sensors.

I can't publish an URL here (your forum restriction), so you have to visit GitHub, find Lurker00 and the repository is TouchSensorClickFilter.

Best wishes!

User avatar
phil
Site Admin
Posts: 6037
Joined: Sun Apr 06, 2003 11:12 pm

Re: Feature request: filter out mouse events generated from touches

Post by phil » Thu Jul 25, 2019 12:38 pm

Thanks.

URL can be posted after 4 or so posts (to try and prevent spam).
For reference: https://github.com/Lurker00/TouchSensorClickFilter
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

Post Reply