<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Mouse_capture</id>
	<title>Mouse capture - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Mouse_capture"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=Mouse_capture&amp;action=history"/>
	<updated>2026-09-19T15:45:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://g1r-mp.com/wiki/index.php?title=Mouse_capture&amp;diff=900&amp;oldid=prev</id>
		<title>QCherry: Document upcoming 0.1.4 weapon confirmation and mouse camera APIs</title>
		<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=Mouse_capture&amp;diff=900&amp;oldid=prev"/>
		<updated>2026-09-19T13:53:43Z</updated>

		<summary type="html">&lt;p&gt;Document upcoming 0.1.4 weapon confirmation and mouse camera APIs&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Mouse capture =&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Since 0.1.4 — in development. Not available in public 0.1.3. Matching client and server are required. Live game acceptance tests are still required.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Client Lua can acquire relative mouse motion for camera scripts without replacing GUI click handling. One resource owns capture; another resource cannot steal it. Acquisition is asynchronous: &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; from [[setMouseCapture]] means acceptance, not active input.&lt;br /&gt;
&lt;br /&gt;
== API ==&lt;br /&gt;
* [[setMouseCapture]]: &amp;lt;code&amp;gt;boolean setMouseCapture(boolean enabled)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* [[getMouseCaptureState]]: &amp;lt;code&amp;gt;string getMouseCaptureState()&amp;lt;/code&amp;gt;, returning inactive, pending, active or suspended for the calling resource.&lt;br /&gt;
* [[onClientMouseMove]]: &amp;lt;code&amp;gt;function(dx, dy, elapsedMs)&amp;lt;/code&amp;gt;. Relative raw counts, positive X right and positive Y down, not pixels or degrees. Apply sensitivity; do not multiply displacement by elapsed time. Only non-zero movement is delivered, at most approximately 60 events/second. Absolute tablet input is not included.&lt;br /&gt;
* [[onClientMouseCaptureChanged]]: &amp;lt;code&amp;gt;function(state, reason)&amp;lt;/code&amp;gt;, delivered to the owning resource only.&lt;br /&gt;
* [[UpdateCameraPose]] / &amp;lt;code&amp;gt;updateCameraPose&amp;lt;/code&amp;gt;: coalesced updates for an already acquired scripted camera.&lt;br /&gt;
&lt;br /&gt;
== Ownership and safety ==&lt;br /&gt;
Capture suspends on loss of game focus, GUI or keyboard capture, detected native menu/input blocking, death or missing game state. It resumes after the blocker clears and native confirmation arrives. Resource stop and IPC loss release capture. A 750 ms native lease expires when heartbeats stop. Native look locking balances only this feature&amp;#039;s own lock; it does not reset another subsystem&amp;#039;s lock.&lt;br /&gt;
&lt;br /&gt;
Capture does not imply a camera lease. Acquire the camera with existing &amp;lt;code&amp;gt;RequestCameraState&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SetCameraPose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;onClientCameraCommandResult&amp;lt;/code&amp;gt; before streaming poses. Release it separately with &amp;lt;code&amp;gt;ResetCameraPos&amp;lt;/code&amp;gt;. GUI interaction pauses capture; simultaneous GUI dragging is not provided by this API.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Acquire your camera first and wait for its successful command result.&lt;br /&gt;
local yaw, pitch = 0, -12&lt;br /&gt;
addEventHandler(&amp;quot;onClientMouseMove&amp;quot;, resourceRoot, function(dx, dy, elapsedMs)&lt;br /&gt;
    yaw = (yaw + dx * 0.12) % 360&lt;br /&gt;
    pitch = math.max(-80, math.min(80, pitch - dy * 0.12))&lt;br /&gt;
    UpdateCameraPose({yaw = yaw, pitch = pitch})&lt;br /&gt;
end)&lt;br /&gt;
setMouseCapture(true)&lt;br /&gt;
-- Later: setMouseCapture(false); ResetCameraPos(250)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Development test ==&lt;br /&gt;
The gothic_rp test commands require a spawned, authenticated character, enabled test tools and &amp;lt;code&amp;gt;admin.players&amp;lt;/code&amp;gt; permission:&lt;br /&gt;
* &amp;lt;code&amp;gt;/mousetest camera&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/mousetest orbit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/mousetest observe&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;/mousetest gui&amp;lt;/code&amp;gt; checks suspension and return from GUI input.&lt;br /&gt;
* F8 or &amp;lt;code&amp;gt;/mousetest stop&amp;lt;/code&amp;gt; releases capture and restores the test camera. Automatic stop after 60 seconds.&lt;br /&gt;
&lt;br /&gt;
Verify Alt-Tab, native menus/inventory, chat, GUI clicks, resource restart and disconnect in the live game. Automated tests do not establish that every native G1R menu/custom input path respects the look gate.&lt;br /&gt;
[[Category:Lua API]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>