MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / SetGrabMouse

Method SetGrabMouse

Source/UserInput/input.cpp:291–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291void Input::SetGrabMouse(bool grab) {
292 if (grab_mouse_ == grab) return;
293 if (grab && in_focus_) {
294 grab_mouse_ = true;
295 Graphics::Instance()->SetWindowGrab(true);
296 cursor->SetVisible(false);
297 if (use_raw_input) {
298 // If we further wish to do this "correctly" we can use this hint: https://wiki.libsdl.org/SDL_HINT_MOUSE_RELATIVE_MODE_WARP
299 SDL_SetRelativeMouseMode(SDL_TRUE);
300 } else {
301 SDL_SetRelativeMouseMode(SDL_FALSE);
302 }
303 } else {
304 grab_mouse_ = false;
305 Graphics::Instance()->SetWindowGrab(false);
306 cursor->SetVisible(true);
307 SDL_SetRelativeMouseMode(SDL_FALSE);
308 }
309}
310
311void Input::HandleEvent(const SDL_Event& event) {
312 PROFILER_ZONE(g_profiler_ctx, "Input::HandleEvent");

Callers 6

UpdateMethod · 0.80
LoadLevelMethod · 0.80
OSDisplayErrorFunction · 0.80
OSDisplayErrorFunction · 0.80
AS_SetGrabMouseFunction · 0.80
DebugLoopMethod · 0.80

Calls 2

SetWindowGrabMethod · 0.80
SetVisibleMethod · 0.45

Tested by

no test coverage detected