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

Listener returns hot-plugged devices twice #69

Open
henryso opened this issue Sep 13, 2023 · 4 comments
Open

Listener returns hot-plugged devices twice #69

henryso opened this issue Sep 13, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@henryso
Copy link

henryso commented Sep 13, 2023

I am running under Linux, and if I plug in a controller while my program is running, Listener returns the Controller twice. If the controller is plugged in before the program starts, I only get the Controller once. There appears to be nothing in the structure returned that will allow me to de-duplicate the Controller instances. Both of them fire the same events, and I only have one such controller plugged in so, both structures represent the same exact device.

I am using stick 0.13.0 with pasts 0.14.3.

@AldaronLau
Copy link
Member

@henryso Thanks for opening an issue! I haven't yet tried with that combination of versions. If possible, an example would be useful (and if you wanted to make a PR, less work for me on #66 😄). One thing that would be useful to verify as well is whether this also happens with the current examples in the stick repo (on the old pasts version). What Linux distribution are you on?

@AldaronLau AldaronLau added the bug Something isn't working label Sep 15, 2023
@henryso
Copy link
Author

henryso commented Sep 15, 2023

@AldaronLau Yes, it behaves the same with the example at https://docs.rs/stick/0.13.0/stick/index.html, only using stick 0.13 instead of 0.12. I am using Gentoo Linux, kernel version 6.1.19 (a little old, yes). I don't have a fix, so I can't offer a PR, at least not yet. I'm currently working around it by ignoring any duplicate controllers (with the same id()) received within 50ms.

@AldaronLau
Copy link
Member

@henryso Sorry, I should have been clearer. I meant a PR for the example using a newer pasts version (as I don't think it would trivial with the current stick version - but, eventually, I'll change the API to make it easier). I'll look into the bug when I can.

@henryso
Copy link
Author

henryso commented Sep 16, 2023

Because of the way pasts 0.14.3 works, I had to implement a custom Notify for my collection of Controller which returns an extended event with some way of identifying the Controller along with the Event. Additionally, I had to add some extra code which removes the Controller from the collection when Event::Disconnect is returned or that Controller will essentially return Event::Disconnect forever. As this adds a lot of baggage to the code, I don't think it's great for a short-form example.

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

2 participants