Skip to main content
Up and Coming
April 17, 2016

Raw input events rather than polling for tracking data

I have been trying to monitor when new tracking data may be available via RAW INPUT via WM_INPUT.  By trying to connect to the HID that has usage page 3, and usage 5, dwFlags as 0 in the RAWINPUTDEVICE struct, as I assumed this is the rift.

Firstly for whatever reason that makes my program hang for a while on startup which isn't good.  Then while running there are no WM_INPUT's seemingly from the headset?

Note I am simply trying to efficiently get the availability of new tracking data which I timestamp with queryperfcounter - that is used for additional control input, _NOT_ the actual rendering of the view (which I do the way Oculus intended so don't worry about that).

The idea being if I detect a WM_INPUT for the Rift that I would call ovr_GetTrackingState() as there is likely new data available.  Doing similar works for the mouse and keyboard, and I can also do the same for XINPUT to decide when to sample the gamepad via those WM_INPUT messages.  This works well and efficiently as I can use the nicely blocking GetMessage() in the message pump loop.

It all gives me much more responsive movement control in games.  So how do I get that to work for the Rift to?  As otherwise I have to spin up another thread and do lots of hacky stuff with sleep()'s when I should just be able to use raw input to listen in instead for the actual events.


If I list the HID devices on that machine I get:

page: 3 usage: 5 IS THIS NOT THE RIFT?
\\?\HID#VID_2833&PID_0021#8&29e8566b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 13 usage: 1
\\?\HID#VID_056A&PID_00B9&Col03#7&2dbb02f6&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 65280 usage: 10
\\?\HID#VID_056A&PID_00B9&Col02#7&2dbb02f6&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 12 usage: 1
\\?\HID#VID_046D&PID_C31D&MI_01&Col03#8&41092b8&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 12 usage: 1
\\?\HID#VID_046D&PID_C31D&MI_01&Col01#8&41092b8&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 65280 usage: 2
\\?\HID#VID_046D&PID_C07D&MI_01&Col05#8&94177c4&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 65280 usage: 1
\\?\HID#VID_046D&PID_C07D&MI_01&Col04#8&94177c4&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 12 usage: 1
\\?\HID#VID_046D&PID_C07D&MI_01&Col02#8&94177c4&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 1 usage: 5 GAMEPAD
\\?\HID#VID_045E&PID_028E&IG_02#8&2a93bed&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

page: 1 usage: 5 GAMEPAD
\\?\HID#VID_045E&PID_028E&IG_00#8&13d58e91&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}



Again just so no one gets confused what I am asking for:  I want to be able to listen on the WM_INPUT messages from the Rift sensors to decide when to sample tracking data.  I am ok with not actually parsing the raw input data - just knowing that there is an update should be enough to notify me to call the Oculus SDK to get updated tracking state.

I would much prefer to get this notification via WM_INPUT listening than any kind of new SDK callback, as it would unify and simplify the whole thing efficiently in the way that ideally it should be done.