internal/gamepad: bug fix: memory leak on Xbox

Updates #2084
This commit is contained in:
Hajime Hoshi 2022-07-15 15:12:54 +09:00
parent c14403f195
commit 520a30f3c7
2 changed files with 5 additions and 0 deletions

View File

@ -246,3 +246,7 @@ func (i *_IGameInputReading) GetGamepadState() (_GameInputGamepadState, bool) {
r, _, _ := syscall.Syscall(i.vtbl.GetGamepadState, 2, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&state)), 0) r, _, _ := syscall.Syscall(i.vtbl.GetGamepadState, 2, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&state)), 0)
return state, int32(r) != 0 return state, int32(r) != 0
} }
func (i *_IGameInputReading) Release() {
syscall.Syscall(i.vtbl.Release, 1, uintptr(unsafe.Pointer(i)), 0, 0)
}

View File

@ -131,6 +131,7 @@ func (n *nativeGamepadXbox) update(gamepads *gamepads) error {
if err != nil { if err != nil {
return err return err
} }
defer r.Release()
state, ok := r.GetGamepadState() state, ok := r.GetGamepadState()
if !ok { if !ok {