Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
 
Other projects
   Altirra

Archives

Blog Archive

Bug in XInput/DirectInput detection sample

MSDN has code to detect whether a controller device enumerated by the DirectInput API is also an XInput device, so that programs can avoid reporting the same controller twice when both APIs are supported:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014%28v=vs.85%29.aspx

Be warned, there is a memory leak in the supplied IsXInputDevice() function: the VARIANT returned by IWbemClassObject::Get() needs to be freed with VariantClear() after the device string is checked. This is hard to notice if you just drop in the code, as it only triggers on device enumeration and that likely only happens on startup or when a device change notification is received. I only noticed it because I temporarily modified my device enumeration code to run in a loop to see how fast (or slow) the WMI-based check would be.

Comments

This blog was originally open for comments when this entry was first posted, but was later closed and then removed due to spam and after a migration away from the original blog software. Unfortunately, it would have been a lot of work to reformat the comments to republish them. The author thanks everyone who posted comments and added to the discussion.