Skip to content

Commit

Permalink
internal/gamepad: bug fix: crash when XInput and DInput gamepads were…
Browse files Browse the repository at this point in the history
… connected

Closes #3047
  • Loading branch information
hajimehoshi committed Jul 20, 2024
1 parent e5bb046 commit 29946d0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/gamepad/gamepad_desktop_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29946d0

Please sign in to comment.