Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Generals/Code/GameEngine/Include/GameClient/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class Mouse : public SubsystemInterface

void setCursorCaptureMode(CursorCaptureMode mode); ///< set the rules for the mouse capture
void refreshCursorCapture(); ///< refresh the mouse capture
Bool isCursorCaptured(); ///< true if the mouse is captured in the game window

// access methods for the mouse data
const MouseIO *getMouseStatus( void ) { return &m_currMouse; } ///< get current mouse status
Expand Down Expand Up @@ -348,12 +349,13 @@ class Mouse : public SubsystemInterface
protected:

void initCapture();
Bool canCapture() const;
void unblockCapture(CursorCaptureBlockReason reason);
void blockCapture(CursorCaptureBlockReason reason);
Bool canCapture() const; ///< true if the mouse can be captured
void unblockCapture(CursorCaptureBlockReason reason); // unset a reason to block mouse capture
void blockCapture(CursorCaptureBlockReason reason); // set a reason to block mouse capture
void onCursorCaptured(Bool captured); ///< called when the mouse was successfully captured or released

virtual void capture( void ) = 0; ///< capture the mouse
virtual void releaseCapture( void ) = 0; ///< release mouse capture
virtual void capture( void ) = 0; ///< capture the mouse in the game window
virtual void releaseCapture( void ) = 0; ///< release the mouse capture

/// you must implement getting a buffered mouse event from you device here
virtual UnsignedByte getMouseEvent( MouseIO *result, Bool flush ) = 0;
Expand Down Expand Up @@ -398,6 +400,7 @@ class Mouse : public SubsystemInterface
relative coordinate changes */

Bool m_visible; // visibility status
Bool m_isCursorCaptured;

MouseCursor m_currentCursor; ///< current mouse cursor

Expand Down
13 changes: 13 additions & 0 deletions Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ Mouse::Mouse( void )
else
m_currentRedrawMode = RM_W3D;//RM_WINDOWS;
m_visible = FALSE;
m_isCursorCaptured = FALSE;
m_tooltipFontName = "Times New Roman";
m_tooltipFontSize = 12;
m_tooltipFontIsBold = FALSE;
Expand Down Expand Up @@ -1039,6 +1040,12 @@ void Mouse::refreshCursorCapture()
}
}

// ------------------------------------------------------------------------------------------------
Bool Mouse::isCursorCaptured()
{
return m_isCursorCaptured;
}

// ------------------------------------------------------------------------------------------------
void Mouse::loseFocus()
{
Expand Down Expand Up @@ -1118,6 +1125,12 @@ void Mouse::blockCapture(CursorCaptureBlockReason reason)
CursorCaptureBlockReasonNames[reason], m_captureBlockReasonBits, (Int)canCapture()));
}

// ------------------------------------------------------------------------------------------------
void Mouse::onCursorCaptured( Bool captured )
{
m_isCursorCaptured = captured;
}

//-------------------------------------------------------------------------------------------------
/** Draw the mouse */
//-------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,21 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
}

// TheSuperHackers @tweak Ayumi/xezon 26/07/2025 Enables edge scrolling in windowed mode.
if (m_isScrolling)
if (TheMouse->isCursorCaptured())
{
if ( m_scrollType == SCROLL_SCREENEDGE && (m_currentPos.x >= edgeScrollSize && m_currentPos.y >= edgeScrollSize && m_currentPos.y < height-edgeScrollSize && m_currentPos.x < width-edgeScrollSize) )
if (m_isScrolling)
{
stopScrolling();
if ( m_scrollType == SCROLL_SCREENEDGE && (m_currentPos.x >= edgeScrollSize && m_currentPos.y >= edgeScrollSize && m_currentPos.y < height-edgeScrollSize && m_currentPos.x < width-edgeScrollSize) )
{
stopScrolling();
}
}
}
else
{
if ( m_currentPos.x < edgeScrollSize || m_currentPos.y < edgeScrollSize || m_currentPos.y >= height-edgeScrollSize || m_currentPos.x >= width-edgeScrollSize )
else
{
setScrolling(SCROLL_SCREENEDGE);
if ( m_currentPos.x < edgeScrollSize || m_currentPos.y < edgeScrollSize || m_currentPos.y >= height-edgeScrollSize || m_currentPos.x >= width-edgeScrollSize )
{
setScrolling(SCROLL_SCREENEDGE);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,10 @@ void Win32Mouse::capture( void )
rect.right = rightBottom.x;
rect.bottom = rightBottom.y;

::ClipCursor(&rect);
if (::ClipCursor(&rect))
{
onCursorCaptured(true);
}

} // end capture

Expand All @@ -482,6 +485,9 @@ void Win32Mouse::capture( void )
void Win32Mouse::releaseCapture( void )
{

::ClipCursor(NULL);
if (::ClipCursor(NULL))
{
onCursorCaptured(false);
}

} // end releaseCapture
13 changes: 8 additions & 5 deletions GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class Mouse : public SubsystemInterface

void setCursorCaptureMode(CursorCaptureMode mode); ///< set the rules for the mouse capture
void refreshCursorCapture(); ///< refresh the mouse capture
Bool isCursorCaptured(); ///< true if the mouse is captured in the game window

// access methods for the mouse data
const MouseIO *getMouseStatus( void ) { return &m_currMouse; } ///< get current mouse status
Expand Down Expand Up @@ -349,12 +350,13 @@ class Mouse : public SubsystemInterface
protected:

void initCapture();
Bool canCapture() const;
void unblockCapture(CursorCaptureBlockReason reason);
void blockCapture(CursorCaptureBlockReason reason);
Bool canCapture() const; ///< true if the mouse can be captured
void unblockCapture(CursorCaptureBlockReason reason); // unset a reason to block mouse capture
void blockCapture(CursorCaptureBlockReason reason); // set a reason to block mouse capture
void onCursorCaptured(Bool captured); ///< called when the mouse was successfully captured or released

virtual void capture( void ) = 0; ///< capture the mouse
virtual void releaseCapture( void ) = 0; ///< release mouse capture
virtual void capture( void ) = 0; ///< capture the mouse in the game window
virtual void releaseCapture( void ) = 0; ///< release the mouse capture

/// you must implement getting a buffered mouse event from you device here
virtual UnsignedByte getMouseEvent( MouseIO *result, Bool flush ) = 0;
Expand Down Expand Up @@ -399,6 +401,7 @@ class Mouse : public SubsystemInterface
relative coordinate changes */

Bool m_visible; // visibility status
Bool m_isCursorCaptured;

MouseCursor m_currentCursor; ///< current mouse cursor

Expand Down
13 changes: 13 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ Mouse::Mouse( void )
else
m_currentRedrawMode = RM_W3D;//RM_WINDOWS;
m_visible = FALSE;
m_isCursorCaptured = FALSE;
m_tooltipFontName = "Times New Roman";
m_tooltipFontSize = 12;
m_tooltipFontIsBold = FALSE;
Expand Down Expand Up @@ -1039,6 +1040,12 @@ void Mouse::refreshCursorCapture()
}
}

// ------------------------------------------------------------------------------------------------
Bool Mouse::isCursorCaptured()
{
return m_isCursorCaptured;
}

// ------------------------------------------------------------------------------------------------
void Mouse::loseFocus()
{
Expand Down Expand Up @@ -1118,6 +1125,12 @@ void Mouse::blockCapture(CursorCaptureBlockReason reason)
CursorCaptureBlockReasonNames[reason], m_captureBlockReasonBits, (Int)canCapture()));
}

// ------------------------------------------------------------------------------------------------
void Mouse::onCursorCaptured( Bool captured )
{
m_isCursorCaptured = captured;
}

//-------------------------------------------------------------------------------------------------
/** Draw the mouse */
//-------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,21 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
}

// TheSuperHackers @tweak Ayumi/xezon 26/07/2025 Enables edge scrolling in windowed mode.
if (m_isScrolling)
if (TheMouse->isCursorCaptured())
{
if ( m_scrollType == SCROLL_SCREENEDGE && (m_currentPos.x >= edgeScrollSize && m_currentPos.y >= edgeScrollSize && m_currentPos.y < height-edgeScrollSize && m_currentPos.x < width-edgeScrollSize) )
if (m_isScrolling)
{
stopScrolling();
if ( m_scrollType == SCROLL_SCREENEDGE && (m_currentPos.x >= edgeScrollSize && m_currentPos.y >= edgeScrollSize && m_currentPos.y < height-edgeScrollSize && m_currentPos.x < width-edgeScrollSize) )
{
stopScrolling();
}
}
}
else
{
if ( m_currentPos.x < edgeScrollSize || m_currentPos.y < edgeScrollSize || m_currentPos.y >= height-edgeScrollSize || m_currentPos.x >= width-edgeScrollSize )
else
{
setScrolling(SCROLL_SCREENEDGE);
if ( m_currentPos.x < edgeScrollSize || m_currentPos.y < edgeScrollSize || m_currentPos.y >= height-edgeScrollSize || m_currentPos.x >= width-edgeScrollSize )
{
setScrolling(SCROLL_SCREENEDGE);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,10 @@ void Win32Mouse::capture( void )
rect.right = rightBottom.x;
rect.bottom = rightBottom.y;

::ClipCursor(&rect);
if (::ClipCursor(&rect))
{
onCursorCaptured(true);
}

} // end capture

Expand All @@ -482,6 +485,9 @@ void Win32Mouse::capture( void )
void Win32Mouse::releaseCapture( void )
{

::ClipCursor(NULL);
if (::ClipCursor(NULL))
{
onCursorCaptured(false);
}

} // end releaseCapture
Loading