Add files via upload

This commit is contained in:
TimothyLottes
2016-11-10 08:32:25 -05:00
committed by GitHub
parent 09d705fa3d
commit 733d114815
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
<html><head><link rel="stylesheet" href="style.css"></head><body><div class="page">
<h1>20130325 - Understanding WIN32 GetRawInputBuffer()</h1>
<br>
This is a re-post, for some reason bringing back the prior link is no longer working, have not figured out why yet.
Direct link to docs: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms645595(v=vs.85).aspx">GetRawInputBuffer()</a>.
<br />
<br />
<b>On XP at least (have not tested Vista/Win7/Win8 yet),</b><br />The entire RawInput system is built on-top of WM_INPUT events in the standard Window's message queue. When processing messages, WM_INPUT messages must not be removed in order to use GetRawInputBuffer() as GetRawInputBuffer() will use then remove those events. In my usage case I'm doing this to drain out the message queue without disrupting GetRawInputBuffer(), and relying on the fact that for events like WM_ACTIVATEAPP (ALT+TAB), PeekMessage() automatically calls the WinProc() without returning the message to the application directly,<br /><br><pre>while(1) {<br /> if(PeekMessage(&msg, 0, 0, WM_INPUT-1, PM_NOYIELD | PM_REMOVE) == 0) break;<br /> DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam); }<br />while(1) {<br /> if(PeekMessage(&msg, 0, WM_INPUT+1, 0xFFFFFFFF, PM_NOYIELD | PM_REMOVE) == 0) break;<br /> DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam); }</pre><br /><b>GetRawInputBuffer()</b><br />Docs on GetRawInputBuffer() are confusing, here is a less confusing example,<br /><br /><pre>// Some temp global buffer, 1KB is overkill.<br />static uint64_t rawBuffer[1024/8];<br />...<br />// Then in some function,<br />const uint32_t bytes = sizeof(rawBuffer);<br />// Loop through reading raw input until no events are left,<br />while(1) {<br /> // Fill up buffer,<br /> int32_t count = GetRawInputBuffer((PRAWINPUT)rawBuffer, &bytes, sizeof(RAWINPUTHEADER));<br /> if(count <= 0) return;<br /> ...<br /> // Process all the events, <br /> const RAWINPUT* restrict raw = (const RAWINPUT* restrict) rawBuffer;<br /> while(1) {<br /> // Process raw event.<br /> ...<br /> // Goto next raw event.<br /> count--;<br /> if(count <= 0) break;<br /> raw = NEXTRAWINPUTBLOCK(raw); } }</pre>
</div></body></html>
+2
View File
@@ -103,10 +103,12 @@ Below this is active random migration (416 prior posts still to filter through)
<a href="20140715.html">20140715 - Infinte Projection Matrix Notes</a><br>
<a href="20140506.html">20140506 - The Other Project</a><br>
<a href="20140328.html">20140328 - Related to Filtering for VR</a><br>
<a href="20140110.html">20140110 - Portable Read-Only Thumb Linux</a><br>
<br>
<b>2013</b><br>
<a href="20131126.html">20131126 - Random Next Generation Notes</a><br>
<a href="20130825.html">20130825 - Modern Memory Mapping</a><br>
<a href="20130325.html">20130325 - Understanding WIN32 GetRawInputBuffer()</a><br>
<br>
<b>2012</b><br>
<a href="20121203.html">20121203 - Simple Custom Web Server Tricks</a><br>