Simulated keystrokes - problem with repeats

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
capnstoobie
New User
Posts: 6
Joined: Thu Nov 05, 2009 1:05 am

Simulated keystrokes - problem with repeats

Post by capnstoobie » Thu Nov 05, 2009 1:19 am

I am trying to use my left and right tilt wheel buttons to do CTRL PGUP and CTRL PGDN (for switching tabs in Firefox). The problem is that is very easy to send multiple keystrokes (and therefore move through multiple Firefox tabs) even though I have only pressed the tilt wheel once. If I'm very careful and I lightly touch the tilt wheel I can get just one keystroke (which is what I want), but in normal use and I end up triggering 2 or 3 keystrokes.

If you use the keyboard to do CTRL PGUP, when you hold it down it does the first keystroke, then pauses, and only after about 500ms does it start to repeat. This is normal when holding down any button on a keyboard. If XMBC could do this, it would probably fix my problem.

I have tried the {WAIT} command but this did not fix my problem.

I am using version 1.48.1 on Win7(64bit). I've got a Dell Premium mouse.

Many thanks :)

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Thu Nov 05, 2009 2:44 am

Hi,

Sorry to hear of this problem :(. I think the problem is because the tilt wheel not not actually treated like a button with a discrete down and up, but more like the wheel, it continuously sends a single "scroll" message.

When XMBC recieves such a message, it sends a simulated DOWN + UP to make it behave internally like a button. I guess that the repeat nature of the tilt is causing more than one down+up sequence. This is probably why you get the keystrokes repeated, your "single" click is probably internally translated as more than one scroll message.

My logitech mouse tilt does not send the messages all that quickly but I guess each mouse driver does it differently.

The proper solution would be to change the current logic, and look at the tilt timings to see if it is being held down or not and only send one down, and one up message AFTER it has been released, or maybe only repeat if it is held for more than 500 ms (otherwise scrolling would potentially break).

I will see what I can do here and try and get a solution into the next version.

Thanks for the feedback.
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)

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Thu Nov 05, 2009 3:25 am

Yep, easy :)

I have throttled the *first* repeated tilt (if you hold the tilt down) to the system default key repeat delay (500ms by default I think). After that, it will repeat until the tilt is released.

This means that in the first 500ms you will get only one simulated keystroke/button/whatever you have mapped to tilt left/right.
That seems to do the trick here.

I'm right in the middle of some big changes (for multi-layer) so I don't want to do a full release right now, but your welcome to a rough untested beta if you want to check it out (let me know and I'll PM you the link tomorrow.)

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)

capnstoobie
New User
Posts: 6
Joined: Thu Nov 05, 2009 1:05 am

Re: Simulated keystrokes - problem with repeats

Post by capnstoobie » Thu Nov 05, 2009 4:09 am

Wow - I wasn't expecting such a quick response. :D

If you could PM me the beta that would be great!

By way of background, I was previously using the Dell Mouse Suite to programme the tilt wheel, but I recently upgraded to Win7 and I couldn't get the Mouse Suite to work anymore.

Thanks.

capnstoobie
New User
Posts: 6
Joined: Thu Nov 05, 2009 1:05 am

Re: Simulated keystrokes - problem with repeats

Post by capnstoobie » Thu Nov 05, 2009 11:25 pm

Thanks a lot for the beta. It improved the situation greatly but there are still issues.

- A single click of the tilt wheel works fine (provided there is a one second gap between clicks)
- A double click only actually executes a single command
- A triple click seems to execute the first command immediately, then pauses, then executes the second and third command quickly.

I don't think the first click should be throttled to 500ms. It should work like a keyboard, where if you press a key 10 times really quickly it will display on the screen 10 times, exactly in sync as you press each key. That 500ms delay should only be when you press and hold.

I'm not a programmer though, so I don't know if the tilt wheel works in a different way...

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Fri Nov 06, 2009 12:42 am

The problem is that there is no distinction between press and hold and press multiple times.
When you hold the tilt wheel, it just sends a repeat message, nothing to say that its the first or a repeat.

With a key press, you get distinct DOWN and UP. For repeats, you get DOWN REPEAT REPEAT ... REPEAT UP
With the TILT all I get is TILT TILT TILT TILT TILT TILT...

To behave exactly like the keyboard I would need TILT DOWN | TILT UP and TILT DOWN REPEAT .... TILT UP.

EDIT: Its not like a mouse button either which has a DOWN, UP and DBLCLICk. There is no such thing as a double click on the tilt wheel.... just like there is no such thing as a double click on the scroll bit of the wheel.

All my change does is introduce a repeat delay like the delay when you press a key before it repeats. It can not distinctly detect that the tilt was pressed or released :(.

I hope that makes some sense.
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)

capnstoobie
New User
Posts: 6
Joined: Thu Nov 05, 2009 1:05 am

Re: Simulated keystrokes - problem with repeats

Post by capnstoobie » Fri Nov 06, 2009 12:46 am

Thanks - I understand what you mean. Thanks again for your efforts!

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Fri Nov 06, 2009 12:51 am

I do understand your problem, I just cant think of any better solution given the way the mouse driver sends tilt messages to the system :(

If I have any fantastic ideas, I will let you know, but for now I will leave it as it is.

For what its worth, the actual repeat rate of the tilt message seems to be about 100ms (thats about 10 messages per second)... So I could reduce the 500 to 250 but that probably wont help all that much.

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)

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Fri Nov 06, 2009 3:02 am

OK I have been tinkering.
Can you try downloading that beta again (I've updated it to 1.48.4.1 but the link is the same)

On further research, I have determined that the first repeat message happens about 400ms after the initial tilt is pressed, and thereafter, every 100ms (ish).

I've tried to overcome the problems with some code that takes this time into account - there is a chance that if you time your second "click" of the tilt badly that it will be ignored but generally it will allow multiple clicks (as long as they are faster than 350ms or slower than 450ms).

Basically if I get a second message between 370 and 430 I treat is as a repeat and ignore it, allowing further repeats. But if I get a second message < 370ms or >430ms then its allowed. All 100ms repeats are also allowed (in-case you genuinely hold the tilt wheel down).

Its more complicated but probably gives a better result. Let me know if it works, and which version you prefer and I will go with that in the next release.

Obviously I'm assuming this applies to all tilt wheel mice and not just my logitech G9 - which is perhaps a bad assumption to make!

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)

capnstoobie
New User
Posts: 6
Joined: Thu Nov 05, 2009 1:05 am

Re: Simulated keystrokes - problem with repeats

Post by capnstoobie » Mon Nov 09, 2009 12:23 am

Ok, I'm a bit confused now :) I tried 1.48.4.1, and from my end whenever I do a single click of the tilt wheel I get a double click (ie 2 x CTRL PGUP). However when I tried to revert to 1.48.4 it still seemed to give me a double click. How can I be sure what version of the XMBC I'm using? I can't seem to get back to the version where a single click worked fine but the multi clicks were problematic (which I think was 1.48.4).

Also, does it matter which option I choose for "how to send simulated keystrokes" (ie as mouse button is pressed, as mouse button is released...)

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Mon Nov 09, 2009 12:37 am

OK, Easy way to be sure what version your running, right click the icon and open the log file... Scroll to the end and look at the last startup - it should log the version. If not, find the EXE in \program files\highresolution enterprises, right click it and open properties and the version should be on the details tab,

It might be useful to enable debug logging and try a few tilt clicks to see what gets logged - may help me work out why its different for you than for me - but probably your mouse has different timings than mine (which I feared). If you try this, send me a snippet of the log (or the whole log) afterwards. I guess I could make the timings configurable but thats going to be problematic and difficult to control (and no guarantee that they will be accurate as its not a driver but a user program with no real time timing).

It shouldnt matter what option you select, send on button donw or up would be the same, during may not work at all and the thread options would proably be pointless in this scenareo.

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)

capnstoobie
New User
Posts: 6
Joined: Thu Nov 05, 2009 1:05 am

Re: Simulated keystrokes - problem with repeats

Post by capnstoobie » Mon Nov 09, 2009 1:19 am

I've PM'd the log file to you. I did one left click (that was processed as a double click), and one really quick right click (that was processed as a single click). The log file shows 1.48.4 regardless - only the exe properties seem to show whether it's 1.48.4 or 1.48.4.1.

At this stage I probably prefer the treatment in 1.48.4 as I would more regularly do a single click of the tilt wheel than a multi click.

thanks!

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

Re: Simulated keystrokes - problem with repeats

Post by phil » Mon Nov 09, 2009 2:06 am

OK interesting, the log is of some use, it shows that your left tilt that performs two send keystrokes is happening faster than I expected (94ms apart).

What's not so clear is why.

On my mouse, the second tilt message (if its held down) happens about 391-400 ms after the first, and from there on, it repeats at about 100ms (as I mentioned before). But it would seem that your mouse is different, because the first repeat (second message) happens only 94ms after the first. This obviously voids my logic and thinking but maybe, with some extra configuration my changes can work for both of us.

I am going to give you another version with more debug logging to make sure this is not a freak occurrence, I will enable this logging all the time so there will be no need to enable debug logging - and it should help work out a pattern that I can detect and code for (hopefully configurably so it works for any mouse).

I will also try and make the version in the log clear - this is the first time I made a x.x.x.x version so I guess the log ignores the final build number! I will PM you when the new version is ready.

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)

Post Reply