From 97ec70da939ace8fa7a076fa31f0d1548e489ba1 Mon Sep 17 00:00:00 2001 From: pixel Date: Thu, 13 Mar 2003 00:58:29 +0000 Subject: lock mouse effect --- lib/engine.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/engine.cc') diff --git a/lib/engine.cc b/lib/engine.cc index 2d53beb..53be179 100644 --- a/lib/engine.cc +++ b/lib/engine.cc @@ -5,7 +5,7 @@ bool mogltk::engine::inited = false, mogltk::engine::postsetuped = false; bool mogltk::engine::appactive = false, mogltk::engine::cursorvisible = false, mogltk::engine::quitrequest = false; int mogltk::engine::mx, mogltk::engine::my, mogltk::engine::mbuttons; -int mogltk::engine::frames; +int mogltk::engine::frames, mogltk::engine::locked = 0; double mogltk::engine::curfps = -1; Uint32 mogltk::engine::curticks; @@ -160,6 +160,11 @@ void mogltk::engine::pollevents() { break; case SDL_MOUSEMOTION: printm(M_INFO, "Mouse slept over the screen - (%i, %i)\n", event.motion.x, event.motion.y); + if (locked) { + if (!((event.motion.x == mx) && (event.motion.y == my))) { + SDL_WrapMouse(mx, my); + } + } if (cursorvisible) hastoreturn = true; break; @@ -217,3 +222,12 @@ int mogltk::engine::mousebuttons() { double mogltk::engine::FPS() { return curfps; } + +void mogltk::engine::lockmouse() { + locked = 1; +} + +void mogltk::engine::unlockmouse() { + locked = 0; +} + -- cgit v1.2.3