[QL] Mouse unlock

mowl

Coders
Mouse unlocking

QuakeLive uses the browser mouse. We can simply unlock but checking the plugin dll.
Since we all know we show/hide a cursor with an API provided function called ShowCursor, and we know we can center and lock a cursor with ClipCursor.

Open up quakelive.dll in IDA or any other disasm you like.
Search for ClipCursor, reference the call in a function.

Code:
.text:100BCE16                 lea     edx, [esp+24h+Rect]
.text:100BCE1A                 push    edx             ; lpRect
.text:100BCE1B                 call    ds:ClipCursor

Scroll up to where you got the coordinates set, at SetCursorPos.

Code:
.text:100BCDEA                 mov     X, ecx
.text:100BCDF0                 mov     Y, eax
.text:100BCDF5                 call    ds:SetCursorPos
.text:100BCDFB                 test    dword_108F3EA4, 0FFFFFFEBh ; what we need.
.text:100BCE05                 jnz     short loc_100BCE21
.text:100BCE07                 mov     eax, dword_1075A9B0
.text:100BCE0C                 test    eax, eax

Now unlock mouse and lock keyinput.
Code:
*(int*)( ( DWORD ) Main.dwQuakeLiveHandle + 0x8F3EA4 ) = 0x0002 /* unlock mouse */ | 0x0008 /* lock keyinput */ ;

Mouse position retrieval
We don't need to hook any UI function, all coords are passed through GetCursorPos.

Code:
void CGui::SetupMouse()
{
	if (!cgameVar.isRender)
		return;

	POINT mousePos;
	GetCursorPos( &mousePos );

	Gui.mouseX = mousePos.x / ( cgameVar.refdef->width / 640.0f );
	Gui.mouseY = mousePos.y / ( cgameVar.refdef->height / 480.0f );
}

Kind regards,
mOwl
 
Top