Código PHP:
int originalmouseparms[3], newmouseparms[3] = { 0, 0, 1 }, newmouseparmsXP[3] = {0, 0, 0};
void IN_ActivateMouse(void)
{
int width, height;
BOOL success;
OSVERSIONINFO osver;
// NiceAss: reset mouse settings if m_xp changes
if( m_xp->modified )
{
mouseactive = false;
m_xp->modified = false;
}
if (!mouseinitialized)
return;
if (!in_mouse->value)
{
mouseactive = false;
return;
}
if (mouseactive)
return;
mouseactive = true;
memset(&osver, 0, sizeof(OSVERSIONINFO));
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
success = GetVersionEx(&osver);
if (mouseparmsvalid)
{
// WinXP is NT and version 5.1
if (success && osver.dwPlatformId == VER_PLATFORM_WIN32_NT && osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1 && m_xp->value)
{
restore_spi = SystemParametersInfo(SPI_SETMOUSE, 0, newmouseparmsXP, 0);
}
else
{
restore_spi = SystemParametersInfo(SPI_SETMOUSE, 0, newmouseparms, 0);
}
}
width = GetSystemMetrics(SM_CXSCREEN);
height = GetSystemMetrics(SM_CYSCREEN);
GetWindowRect(cl_hwnd, &window_rect);
if (window_rect.left < 0)
window_rect.left = 0;
if (window_rect.top < 0)
window_rect.top = 0;
if (window_rect.right >= width)
window_rect.right = width - 1;
if (window_rect.bottom >= height - 1)
window_rect.bottom = height - 1;
window_center_x = (window_rect.right + window_rect.left) / 2;
window_center_y = (window_rect.top + window_rect.bottom) / 2;
SetCursorPos(window_center_x, window_center_y);
old_x = window_center_x;
old_y = window_center_y;
SetCapture(cl_hwnd);
ClipCursor(&window_rect);
while (ShowCursor(FALSE) >= 0);
}