3932: Reset relative mouse motion on toggle r=def- a=Jupeyy

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2021-07-01 12:20:06 +00:00 committed by GitHub
commit 5d73c31863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,6 +89,8 @@ void CInput::MouseModeRelative()
m_InputGrabbed = 1;
SDL_SetRelativeMouseMode(SDL_TRUE);
Graphics()->SetWindowGrab(true);
// Clear pending relative mouse motion
SDL_GetRelativeMouseState(0x0, 0x0);
}
int CInput::MouseDoubleClick()
@ -334,8 +336,6 @@ int CInput::Update()
MouseModeRelative();
m_MouseFocus = true;
IgnoreKeys = true;
// We should do this call to reset relative mouse position after alt+tab
SDL_GetRelativeMouseState(0x0, 0x0);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
m_MouseFocus = false;