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

Peripheral API v3.0.2: Stable peripheral locations #24392

Merged
merged 2 commits into from
Jan 6, 2024

Conversation

garbear
Copy link
Member

@garbear garbear commented Jan 2, 2024

Description

This PR introduces a small backwards-compatible addition to the Peripheral binary add-on API. It adds simple comparison operators to the utility class.

This change is required by xbmc/peripheral.joystick#294.

Motivation and context

By enabling comparison, we can assign the same peripheral index when a controller is unplugged/replugged. This feature will be important in my upcoming Player Manager.

How has this been tested?

Tested on Ubuntu 22.04.

I made a quick change so that peripheral locations would show in the Player Viewer instead of the driver name:

--- a/xbmc/games/agents/windows/GUIAgentList.cpp
+++ b/xbmc/games/agents/windows/GUIAgentList.cpp
@@ -209,7 +209,7 @@ void CGUIAgentList::OnEvent(const ADDON::AddonEvent& event)
 void CGUIAgentList::AddItem(const CGameAgent& agent)
 {
   // Create the list item from agent properties
-  const std::string label = agent.GetPeripheralName();
+  const std::string label = agent.GetPeripheralLocation();
   const ControllerPtr controller = agent.GetController();
   const std::string& path = agent.GetPeripheralLocation();

I unplugged/replugged controllers randomly and observed that their location was preserved.

What is the effect on users?

  • Player assignment will be slightly more stable when unplugging/replugging controllers during gameplay

Screenshots (if appropriate):

Screenshot from 2024-01-01 20-10-46

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • None of the above (please explain below)

@garbear
Copy link
Member Author

garbear commented Jan 5, 2024

jenkins build this please

@garbear garbear merged commit a24a80f into xbmc:master Jan 6, 2024
2 checks passed
@garbear garbear deleted the peripheral-locations branch January 6, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant