CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jun 2007
    Location
    Vercelli, Italy
    Posts
    87

    [RESOLVED] RegisterRawInputDevices fails with no error

    Hi everyone,

    I want to use the RawInput API in my program to handle HIDs. However, I can't even register any device, as RegisterRawInputDevices fails (returns FALSE). When I call GetLastError(), I get 0, which means no error.

    Here's my code, which is a minimal variation of the example taken from the MSDN:
    Code:
    #include <windows.h>
    
    int main(int argc, char** argv)
    {
    	RAWINPUTDEVICE Rid[2];
    	    
    	Rid[0].usUsagePage = 0x01; 
    	Rid[0].usUsage = 0x02; 
    	Rid[0].dwFlags = RIDEV_NOLEGACY;   // adds HID mouse and also ignores legacy mouse messages
    	Rid[0].hwndTarget = 0;
    
    	Rid[1].usUsagePage = 0x01; 
    	Rid[1].usUsage = 0x06; 
    	Rid[1].dwFlags = RIDEV_NOLEGACY;   // adds HID keyboard and also ignores legacy keyboard messages
    	Rid[1].hwndTarget = 0;
    
    	if (RegisterRawInputDevices(Rid, 2, sizeof(Rid[0])) == FALSE) 
    	{
    		DWORD err = GetLastError();
    	}
    
    	return 0;
    }
    I've tried similar code (I don't have it here, so I can't make an accurate line-to-line comparison) on another machine, and there it worked. On my laptop, it worked for a while, then it stopped working.

    I suspect this has something to do with my specific setup; in particular, in (apparently) unrelated news, I installed and configured (and re-configured) software such as PPJoy in order to use a Wiimote as a HID. However, my software didn't work before installing PPJoy, started working after some tentative configurations of PPJoy, then stopped working again.

    I will perform tests on other machines, to check if my experiments broke something, but before that I would like to know if some of you have had a similar experience. I find it especially weird that RegisterRawInputDevices fails without marking any error...
    Last edited by Sk#; June 8th, 2010 at 05:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured