From: <cn...@us...> - 2009-07-13 05:33:33
|
Revision: 421 http://hgengine.svn.sourceforge.net/hgengine/?rev=421&view=rev Author: cnlohr Date: 2009-07-13 05:33:28 +0000 (Mon, 13 Jul 2009) Log Message: ----------- enable/disable mouse grabbing. This is nonintuitive at first, as HG1 only enabled grabbed input, however many non-FPS games (Even some 3rd person games) do not grab the mouse. This enables users to intuitively use their mouse at their own will for these games. Modified Paths: -------------- Mercury2/src/MercuryWindow.cpp Mercury2/src/MercuryWindow.h Mercury2/src/X11Window.cpp Modified: Mercury2/src/MercuryWindow.cpp =================================================================== --- Mercury2/src/MercuryWindow.cpp 2009-07-10 03:36:11 UTC (rev 420) +++ Mercury2/src/MercuryWindow.cpp 2009-07-13 05:33:28 UTC (rev 421) @@ -1,7 +1,8 @@ #include "MercuryWindow.h" MercuryWindow::MercuryWindow(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen) - :m_title(title), m_width(width), m_height(height), m_bits(bits), m_depthBits(depthBits), m_fullscreen(fullscreen) + :m_title(title), m_width(width), m_height(height), m_bits(bits), m_depthBits(depthBits), m_fullscreen(fullscreen), + m_bGrabbed(true) { } Modified: Mercury2/src/MercuryWindow.h =================================================================== --- Mercury2/src/MercuryWindow.h 2009-07-10 03:36:11 UTC (rev 420) +++ Mercury2/src/MercuryWindow.h 2009-07-13 05:33:28 UTC (rev 421) @@ -32,10 +32,13 @@ inline int Width() const { return m_width; } inline int Height() const { return m_height; } + void SetGrabbedMouseMode( bool bGrabbed ) { m_bGrabbed = bGrabbed; } + bool GetGrabbedMouseMode( ) { return m_bGrabbed; } protected: static Callback0R< MercuryWindow* > genWindowClbk; static MercuryWindow* m_windowInstance; + bool m_bGrabbed; MString m_title; int m_width, m_height; uint8_t m_bits, m_depthBits; Modified: Mercury2/src/X11Window.cpp =================================================================== --- Mercury2/src/X11Window.cpp 2009-07-10 03:36:11 UTC (rev 420) +++ Mercury2/src/X11Window.cpp 2009-07-13 05:33:28 UTC (rev 421) @@ -223,7 +223,7 @@ { XFocusChangeEvent*e = (XFocusChangeEvent*)&event; inFocus = (event.type == FocusIn); - if (inFocus) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2); + if (inFocus && m_bGrabbed ) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2); break; } } @@ -263,14 +263,20 @@ left = e->state & Button1Mask; right = e->state & Button3Mask; center = e->state & Button2Mask; - x = m_width/2 - e->x; - y = m_height/2 - e->y; - if (x!=0 || y!=0) //prevent recursive XWarp + if( m_bGrabbed ) { - MouseInput::ProcessMouseInput(x, y, - left, right, center); - XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2); + x = m_width/2 - e->x; + y = m_height/2 - e->y; + if (x!=0 || y!=0) //prevent recursive XWarp + { + MouseInput::ProcessMouseInput(x, y, left, right, center); + XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2); + } } + else + { + MouseInput::ProcessMouseInput(e->x, e->y, left, right, center); + } break; } default: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |