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

feat(CompositeDevice): Add persist option #285

Merged
merged 4 commits into from
Feb 15, 2025

Conversation

blindedone1458
Copy link
Contributor

  • Add CompositeDevice config bool option 'persist'
  • If persist is true then continue running CompositeDevice when all SourceDevices have been removed
  • Update clear_state for Gamepad targets to default all inputs to stop all input from continuing

This improvement is to handle cases where a SourceDevice is disconnected to maintain the existing TargetDevice

* Add CompositeDevice config bool option 'persist' 
* If persist is true then continue running CompositeDevice when all SourceDevices have been removed
* Update clear_state for Gamepad targets to default all inputs to stop all input from continuing
Copy link
Contributor

@ShadowApex ShadowApex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change! I think this is a great option to include :)

There are just a few small things in this to address and I think we can include this.

… or usb virtual devices to reset their state
@blindedone1458
Copy link
Contributor Author

Thanks for the feedback @ShadowApex ! I've made the updates for the hidraw and usb targets, I totally missed that their tracked state was being used in that way. I do agree that applying InputValue::Bool(false) for all capabilities is a bit inelegant, but it has been working as expected in my testing in that it properly re-centers the joysticks and the triggers are back to zero.

@ShadowApex
Copy link
Contributor

Oh, nice! I thought that might cause issues. Let me also do some testing to double check that this will re-center those joysticks. If everything works, we should be able to merge this in. Thanks!

@pastaq
Copy link
Contributor

pastaq commented Feb 12, 2025

I have a few questions on usability. It seems this is only implemented as a config option. That makes me think there are a few cases we need to consider. Don't consider any of these blocking necessarily, but I want to discuss and have a plan at a minimum before we merge.

  • As of feat(Manager): add gamepad reordering #284, suspend will stop all target devices and they will be restarted in player order on resume. What will happen to a composite device during suspend that has no sources or targets?
  • If the expectation is to use this in a config, what is the expectation for the default configs in /usr? What are the consequences of we enabled this by default on the gamepad configs? I.e. if a user is playing a game and their controller dies, so they plug it in or swap it. Both cases will detect as a new device (different bus type at a minimum) and create a second controller. Should we have some logic to try and connect any of the same type to the original device? If it's a different typ e(ds4 to Xbox for example) and the original controller is persistent, the new controller will be player 2 and player 1 will be permanently unable to be used unless some client sends a StopComposteDevice over dbus. Is there a graceful way to handle clearing this if we get a new controller?
  • IMO this would be most useful as selectively enableable from client software. I'd like to see a dbus & CLI option to turn it on/off on the composite device
  • Doing the above adds another consideration. What happens if a device has this set to on, has no sources, and it is then set to off?

@blindedone1458
Copy link
Contributor Author

Definitely some more things to think about @pastaq and probably not for me to necessarily answer as a new contributor. It did give me a few more ideas for edge cases to test for though like if you plug in the controller when was connected via wireless, which currently would create a second persistent CompositeDevice though I have a fix in mind for that.
I do think having a CompositeDevice with no sources active shouldn't remain stuck as Player 1 (which with persist: true would be the case as you point out) so I'll look into having the ordering take that into account as well.

Copy link
Contributor

@ShadowApex ShadowApex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works great! Once the merge conflict has been resolved, we should be able to merge this in!

Thanks!

@ShadowApex ShadowApex merged commit b2feb73 into ShadowBlip:main Feb 15, 2025
1 check passed
Copy link

🎉 This PR is included in version 0.47.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants