internal/gamepad: bug fix: crash when XInput and DInput gamepads were connected

Closes #3047
This commit is contained in:
Hajime Hoshi 2024-07-20 22:30:36 +09:00
parent e5bb046a11
commit 29946d037b

View File

@ -329,7 +329,12 @@ func (g *nativeGamepadsDesktop) dinput8EnumDevicesCallback(lpddi *_DIDEVICEINSTA
var findErr error
if gamepads.find(func(g *Gamepad) bool {
path, err := getDInputPath(g.native.(*nativeGamepadDesktop).dinputDevice)
// A DInput device can be nil when the device is an XInput device (#3047).
d := g.native.(*nativeGamepadDesktop).dinputDevice
if d == nil {
return false
}
path, err := getDInputPath(d)
if err != nil {
findErr = err
return true