Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mid-session unplug/replug events sometimes cause LinearMouse to not work properly. #48

Closed
jiroumu opened this issue Jan 7, 2022 · 13 comments
Labels
bug Something isn't working

Comments

@jiroumu
Copy link

jiroumu commented Jan 7, 2022

Hey lujjjh,

first of all I'd like to thank you for the great work you've been doing with LinearMouse, it has been a treat so far.

During a session LinearMouse starts working fine after sign-on. When I unplug and later replug my mouse (I use a USB-switch to use the same mouse between computers, effectively constituting a plug-cycle as far as I can tell), LinearMouse will sometimes not function properly and won't apply the set preferences. Plug-cycling the mouse again sometimes brings function back. When it works, it keeps working without intermittent failure, only plug-cycling triggers it.

I've found that when plug-cycling and NOT touching the mouse for a few seconds until I'm sure the device switch is completed, LinearMouse again tends to work more often than not. When moving the mouse during a plug-cycle, LinearMouse seems to work less often coming back. Might just be my imagination, though.

@lujjjh
Copy link
Collaborator

lujjjh commented Jan 8, 2022

Hi @jiroumu,

Thank you for submitting this!

LinearMouse will sometimes not function properly and won't apply the set preferences.

Do you mean that when you plug your mouse, the cursor acceleration and sensitivity aren't updated correctly?

That's possible. LinearMouse scans mice and adjusts their cursor acceleration and sensitivity every 5 seconds. So if you move your mouse right after plugging it in, LinearMouse may not have updated its cursor settings. When I get time, I'll improve this.

However, everything should works fine in 5 seconds without replugging the mouse. Could you please verify this?

@collinkreutzer
Copy link

I have had similar issues before where LinearMouse would not apply acceleration and sensitivity correctly before replugging the usb receiver of my mouse. Restarting LinearMouse or waiting did not solve the issue. Only replugging did. Sadly i don't know how to reproduce this behavior reliably yet and it occurred only very sporadically.

This might have to do with my Thunderbolt Dock though, as my USB audio interface is also sometimes reset to full volume after waking my MacBook connected to the Dock.

@lujjjh
Copy link
Collaborator

lujjjh commented Jan 8, 2022

Thank you, @collinkreutzer! I'm trying to reproduce this issue.

If someone has reproduced it, the logs might assist me in determining what's going on.

@lujjjh lujjjh added the bug Something isn't working label Jan 8, 2022
@jiroumu
Copy link
Author

jiroumu commented Jan 8, 2022

Do you mean that when you plug your mouse, the cursor acceleration and sensitivity aren't updated correctly?

That's correct. For me, the issue only occurs when I unplug my mouse and replug it, then sometimes it won't be updated correctly, but it's hard to actually reproduce consistently.

However, everything should works fine in 5 seconds without replugging the mouse. Could you please verify this?
If someone has reproduced it, the logs might assist me in determining what's going on.

I was trying just now as per your instructions regarding the console. Will update when I've been successful in reproducing the issue or catching misbehavior in the console.

@lujjjh
Copy link
Collaborator

lujjjh commented Jan 8, 2022

I've optimized the code. LinearMouse now receives notifications of device additions and removals. After plugging in USB receivers, cursor acceleration and sensitivity will be applied immediately. You may try the binary here.

I'm not sure if this issue has been fixed as I couldn't reproduce it. If it still exists in this version, please let me know.

Thank you!

@jiroumu
Copy link
Author

jiroumu commented Jan 8, 2022

I'm not sure if this issue has been fixed as I couldn't reproduce it. If it still exists in this version, please let me know.

Your efforts are much appreciated. I've installed and will report back with my findings.

Cheers.

@jiroumu
Copy link
Author

jiroumu commented Jan 13, 2022

Alright, I managed to reproduce the issue on the newest version. See the attached screenshot of the Console log. The log starts in a state where I just plug-cycled the mouse and LinearMouse wouldn't update sensitivity/acceleration due to it mistaking the mouse as a trackpad. After unplugging and replugging again, everything goes back to working as expected again, as can be seen in the later half of the log.

Hope this helps
console
.

@lujjjh
Copy link
Collaborator

lujjjh commented Jan 13, 2022

@jiroumu Thank you very much for the screenshot!

It seems that there are two devices named “Orochi V2”, one is treated as a mouse and the other a trackpad. It could be possible, I think, though my USB receiver registers only one mouse device.

Could you please check the log when everything works as expected? I couldn't see the log after the two “Orochi V2” are detected.

@jiroumu
Copy link
Author

jiroumu commented Jan 13, 2022

Sure, find the attached screenshot of Console in a state where everything works as expected. Also attached is a screenshot from System Information listing the USB tree including the mouse receiver
console3
USB
.

@lujjjh
Copy link
Collaborator

lujjjh commented Jan 13, 2022

Thank you for providing this helpful information! At least, I know that both “Orochi V2” are expected to be mice.

It's odd that one of the “Orochi V2” service sometimes doesn't contain the mouse acceleration value by which LinearMouse detects trackpads:

guard let _ = IOHIDServiceClientCopyProperty(service, kIOHIDMouseAccelerationTypeKey as CFString) else {
os_log("%{public}@ is skipped as it might be a trackpad", log: Self.log, type: .debug, product)
continue
}

I'll experiment with changing the method LinearMouse identifies trackpads to see whether it works in this case.

Perhaps I should create a user interface for debugging as well.

@lujjjh
Copy link
Collaborator

lujjjh commented Feb 15, 2022

I've rework the mouse detection algorithm in #82. Would you like to try this build and see if this issue still exists?

@jiroumu
Copy link
Author

jiroumu commented Feb 15, 2022

I've rework the mouse detection algorithm in #82. Would you like to try this build and see if this issue still exists?

Thanks for still taking the time. To be honest, for whatever reason the issue hasn't reoccured for me for the last month or so. Not sure if it's connected to a macOS update or something else you've been doing/adding since then (I keep LinearMouse up to date via brew). So I'm not sure if I'd even be able to verify the proposed fix in your new build as of now :o

@lujjjh
Copy link
Collaborator

lujjjh commented Feb 16, 2022

I guess the credit should be given to macOS updates. Anyway, I'm glad you got rid of the problem :)

I'm closing this issue. Feel free to reopen it anytime if you need additional help.

@lujjjh lujjjh closed this as completed Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants