Skurdt / SK.Libretro

Libretro wrapper written in C# with support for the Unity game engine
MIT License
27 stars 13 forks source link

Input Processor requires Singleton and can not be instances with multiple cores running #12

Closed XenuIsWatching closed 1 week ago

XenuIsWatching commented 1 year ago

The Input Processor requires the PlayerInputManager which is a singleton class. This means that only one can exist. So if multiple LibretroInstances are running at the same time the OnPlayerJoined will be called at the same time for all running instances whenever a player wants to join a specific instance.

Essentially what happens if the player presses "Start Button", all instances will receive the "Start Button" Action.

How I have this set is with a PlayerInputManager with the "Join Behavior" set to "Join Players Manually", where the player can walk up in the virtual environment to a console/arcade and press a button and it will join them to that libretro instance, but whats happening is that it will joing them to ALL libretro instances.

XenuIsWatching commented 1 year ago

Video showing what's going on here

https://youtu.be/ncOWxODxG1M

Skurdt commented 1 year ago

In the current implementation there's no way to "disconnect" a player, say you join as player 1 on a keyboard, then you're the player 1 on keyboard for all instances. The join behavior is basically scene based rather than libretro instance based. This should be pretty easy to modify so you can join and quit manually, going the way you started handling it.

Outside of player joining, the implemented way to enable or disable input for one instance is to set the EnableInput property to true or false on the bridge instance. Under the hood it queues a EnableInputThreadCommand command to the bridge, which simply disables input processing on the wrapper (aka the actual core callback from the core), or rather returns false for all inputs as far as the core is concerned.

XenuIsWatching commented 1 year ago

Thanks, I just went through your suggestion and use the enable input property with toggling that bool

stefanoditore commented 5 months ago

hi. I can't use the quest 2 controller as input device to play with the games. Can you explaine me how you have set the controller to play with the emulator games?