From 29946d037be5b22624e75edf48b8dbf3d87e7e61 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 20 Jul 2024 22:30:36 +0900 Subject: [PATCH] internal/gamepad: bug fix: crash when XInput and DInput gamepads were connected Closes #3047 --- internal/gamepad/gamepad_desktop_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/gamepad/gamepad_desktop_windows.go b/internal/gamepad/gamepad_desktop_windows.go index 405796f3c092..ff89e4f5690e 100644 --- a/internal/gamepad/gamepad_desktop_windows.go +++ b/internal/gamepad/gamepad_desktop_windows.go @@ -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