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

Games: Stable player assignment #23482

Merged
merged 4 commits into from Jul 11, 2023
Merged

Games: Stable player assignment #23482

merged 4 commits into from Jul 11, 2023

Conversation

garbear
Copy link
Member

@garbear garbear commented Jul 6, 2023

Description

In #22036, I pulled in some work from my Player Manager, but unintentionally pulled in an unfinished change that causes a regression in v20.

The change in behavior has to do with how players are sorted into controller ports. In v19, the most recently active controller got port 1, etc. However, in the refactor, new, unfinished behavior was introduced, and the behavior contained an error that caused joysticks to never be sorted; they're simply given a port depending on when they were detected by the OS.

As a result, on some Android boxes, "virtual" joysticks were now sorted in front of legit joysticks, causing input to be dropped.

This PR restores the old behavior of sorting ports by last activated joystick. It's a stop gap measure to solve the phantom joystick problem until the Player Manager is ready to allow control over port mappings.

I also added new logging when the port mapping changes to help debug future issues.

Motivation and context

Reported several places, most recently here: https://forum.kodi.tv/showthread.php?tid=373412

How has this been tested?

Test builds available here: https://github.com/garbear/xbmc/releases

Example logging with 5 controllers connected and a Multitap in port 2:

debug <general>: ===== Peripheral Map =====
debug <general>: /1/game.controller.snes.mouse:
debug <general>:     peripheral.joystick/0 [Xbox 360-compatible controller]
debug <general>:
debug <general>: /2/game.controller.snes.multitap/1/game.controller.snes:
debug <general>:     peripheral.joystick/1 [Xbox 360-compatible controller]
debug <general>:
debug <general>: /2/game.controller.snes.multitap/2/game.controller.snes:
debug <general>:     peripheral.joystick/2 [Xbox 360-compatible controller]
debug <general>:
debug <general>: /2/game.controller.snes.multitap/3/game.controller.snes:
debug <general>:     peripheral.joystick/3 [Xbox 360-compatible controller]
debug <general>:
debug <general>: /2/game.controller.snes.multitap/4/game.controller.snes:
debug <general>:     peripheral.joystick/4 [Wireless Controller]
debug <general>: ==========================

Example logging when the Multitap in port 2 is changed to a SNES controller:

debug <general>: ===== Peripheral Map =====
debug <general>: /1/game.controller.snes:
debug <general>:     peripheral.joystick/0 [Xbox 360-compatible controller]
debug <general>: 
debug <general>: /2/game.controller.snes:
debug <general>:     peripheral.joystick/1 [Xbox 360-compatible controller]
debug <general>: 
debug <general>: Disconnected:
debug <general>:     peripheral.joystick/2 [Xbox 360-compatible controller]
debug <general>:     peripheral.joystick/3 [Xbox 360-compatible controller]
debug <general>:     peripheral.joystick/4 [Wireless Controller]
debug <general>: ==========================

I also created a stripped-down version of the Player manager that I call "View Players" that simply allows you to view player mappings without changing anything:

screenshot00012

The View Players window is included in my test builds, but not in this PR.

What is the effect on users?

  • Fixed game controllers not working when "virtual" joysticks are detected

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)
  • None of the above (please explain below)

@garbear
Copy link
Member Author

garbear commented Jul 7, 2023

Rechi
Rechi previously requested changes Jul 7, 2023
xbmc/games/addons/input/GameClientInput.cpp Outdated Show resolved Hide resolved
xbmc/games/addons/input/GameClientInput.cpp Outdated Show resolved Hide resolved
@Rechi Rechi dismissed their stale review July 8, 2023 06:19

compiler warnings fixed

Example log output is:

  debug <general>: ===== Peripheral Map =====
  debug <general>: /1/game.controller.snes.mouse:
  debug <general>:     peripheral.joystick/0 [Xbox 360-compatible controller]
  debug <general>:
  debug <general>: /2/game.controller.snes.multitap/1/game.controller.snes:
  debug <general>:     peripheral.joystick/1 [Xbox 360-compatible controller]
  debug <general>:
  debug <general>: /2/game.controller.snes.multitap/2/game.controller.snes:
  debug <general>:     peripheral.joystick/2 [Xbox 360-compatible controller]
  debug <general>:
  debug <general>: /2/game.controller.snes.multitap/3/game.controller.snes:
  debug <general>:     peripheral.joystick/3 [Xbox 360-compatible controller]
  debug <general>:
  debug <general>: /2/game.controller.snes.multitap/4/game.controller.snes:
  debug <general>:     peripheral.joystick/4 [Wireless Controller]
  debug <general>: ==========================
@garbear garbear changed the title Games: Sort controllers by last activation time Games: Stable player assignment Jul 9, 2023
@garbear
Copy link
Member Author

garbear commented Jul 9, 2023

I've pushed a new commit. It accomplishes a long-time goal of stable player sorting. When ports or controllers change around, players maintain their port. Even if multitaps are swapped out, when they're swapped back in, the port is remembered.

I'll wait for a confirmation that Android joysticks still work with the stable player sorting.

@garbear
Copy link
Member Author

garbear commented Jul 11, 2023

Android joysticks confirmed working, will merge when I'm ready.

@garbear garbear merged commit 933035c into xbmc:master Jul 11, 2023
2 checks passed
@garbear garbear deleted the sort-controllers branch July 11, 2023 22: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

2 participants