MonoGame / MonoGame

One framework for creating powerful cross-platform games.
http://www.monogame.net
Other
11.24k stars 2.89k forks source link

Joystick.LastConnectedIndex does not update properly #8315

Open SebDaMuffin opened 3 months ago

SebDaMuffin commented 3 months ago

Prerequisites

MonoGame Version

MonoGame 3.8.1.303

Which MonoGame platform are you using?

MonoGame Cross-Platform Desktop Application (mgdesktopgl)

Operating System

Linux

Description

Joystick.LastConnectedIndex returns the highest index in the joystick dictionary and this is not necessarily the last connected joystick. https://github.com/MonoGame/MonoGame/blob/81ed391a4d0fd81e3ee4bfe2492ad9a0e7f4cfc5/MonoGame.Framework/Platform/Input/Joystick.SDL.cs#L29-L33 https://github.com/MonoGame/MonoGame/blob/81ed391a4d0fd81e3ee4bfe2492ad9a0e7f4cfc5/MonoGame.Framework/Platform/Input/Joystick.SDL.cs#L73-L77

Steps to Reproduce

Plug in joystick 0 Plug in joystick 1 Unplug joystick 0 Replug joystick 0 Joystick.LastConnectedIndex returns 1 instead of 0

Minimal Example Repo

No response

Expected Behavior

Joystick.LastConnectedIndex should return the index of the last joystick that was connected, or the name of the property should be changed to reflect this.

Resulting Behavior

Joystick.LastConnectedIndex returns the highest index of all the connected joysticks.

Files

No response

TimerbaevRR commented 1 month ago

Maybe LastConnectedIndex should increase every time when joystick plugged? I mean after replug joystick 0 (last step of reproduce) LastConnectedIndex should be 2?