internal/gamepad: refactoring

This commit is contained in:
Hajime Hoshi 2024-07-21 09:10:04 +09:00
parent faa0172521
commit abc056ab29

View File

@ -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). // lpddi.guidInstance is not reliable as a unique identity when the same multiple devices are connected (#3046).
// Use HID Path instead. // Use HID Path instead.
getDInputPath := func(device *_IDirectInputDevice8W) (string, error) { getDInputPath := func(device *_IDirectInputDevice8W) (string, error) {
var prop _DIPROPGUIDANDPATH prop := _DIPROPGUIDANDPATH{
prop.diph.dwHeaderSize = uint32(unsafe.Sizeof(_DIPROPHEADER{})) diph: _DIPROPHEADER{
prop.diph.dwSize = uint32(unsafe.Sizeof(_DIPROPGUIDANDPATH{})) dwHeaderSize: uint32(unsafe.Sizeof(_DIPROPHEADER{})),
prop.diph.dwHow = _DIPH_DEVICE dwSize: uint32(unsafe.Sizeof(_DIPROPGUIDANDPATH{})),
dwHow: _DIPH_DEVICE,
},
}
if err := device.GetProperty(_DIPROP_GUIDANDPATH, &prop.diph); err != nil { if err := device.GetProperty(_DIPROP_GUIDANDPATH, &prop.diph); err != nil {
return "", err return "", err
} }