From abc056ab29d14a27f5cef32583c000d8eaaf67bd Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 21 Jul 2024 09:10:04 +0900 Subject: [PATCH] internal/gamepad: refactoring --- internal/gamepad/gamepad_desktop_windows.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/gamepad/gamepad_desktop_windows.go b/internal/gamepad/gamepad_desktop_windows.go index f199be235..8674e4410 100644 --- a/internal/gamepad/gamepad_desktop_windows.go +++ b/internal/gamepad/gamepad_desktop_windows.go @@ -312,10 +312,13 @@ func (g *nativeGamepadsDesktop) dinput8EnumDevicesCallback(lpddi *_DIDEVICEINSTA // lpddi.guidInstance is not reliable as a unique identity when the same multiple devices are connected (#3046). // Use HID Path instead. getDInputPath := func(device *_IDirectInputDevice8W) (string, error) { - var prop _DIPROPGUIDANDPATH - prop.diph.dwHeaderSize = uint32(unsafe.Sizeof(_DIPROPHEADER{})) - prop.diph.dwSize = uint32(unsafe.Sizeof(_DIPROPGUIDANDPATH{})) - prop.diph.dwHow = _DIPH_DEVICE + prop := _DIPROPGUIDANDPATH{ + diph: _DIPROPHEADER{ + dwHeaderSize: uint32(unsafe.Sizeof(_DIPROPHEADER{})), + dwSize: uint32(unsafe.Sizeof(_DIPROPGUIDANDPATH{})), + dwHow: _DIPH_DEVICE, + }, + } if err := device.GetProperty(_DIPROP_GUIDANDPATH, &prop.diph); err != nil { return "", err }