Trouble with MS SDK function

Pages: 12
I am trying to write a c++ program so i can get a gaze tracker to work like a mouse moving the cursor. However, when I used the function WM_INPUT it says i need ";" and to declare a type. i understand why i need to but i dont get why MS gave me something that doesnt work.

http://msdn.microsoft.com/en-us/library/ms645590(VS.85).aspx

here's the link to that function.

Thanks so much in advance
WM_INPUT isn't a function, can you post your code?
- see http://msdn.microsoft.com/en-us/library/ms644928%28VS.85%29.aspx -
Hi thanks. i understand better now. but i have encountered a problem with compiling saying this:
error C2664: 'RegisterRawInputDevices' : cannot convert parameter 1 from 'RAWINPUTDEVICE' to 'PCRAWINPUTDEVICE'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

my code:
void register_device ()
{
RAWINPUTDEVICE GazeTracker;
{
GazeTracker.usUsagePage = 0x01;
GazeTracker.usUsage = 0x02;
GazeTracker.dwFlags = RIDEV_NOLEGACY;
GazeTracker.hwndTarget = 0;
}

RegisterRawInputDevices (GazeTracker, 1, sizeof (GazeTracker));
}

any help on that error? Thanks
RegisterRawInputDevices takes a pointer to RAWINPUTDEVICE so add an & before GazeTracker in that line:
RegisterRawInputDevices (&GazeTracker, 1, sizeof (GazeTracker));
Thanks mate!! that did the trick. thanksss
ok furthering the question. With the previous code, i now add this to the code:

if (GetRegisteredRawInputDevices (&GazeTracker, 1, sizeof (GazeTracker)) = -1)
{
cout << GetLastError ();
}

The question is the "1" that's in the new code should be a PUINT and should be a pointer to the earlier UINT "1" in RegisterRawInputDevice. Am i correct?

If so how do i alter the code so that it does not hav a compile error.

Thanks
The question is the "1" that's in the new code should be a PUINT and should be a pointer to the earlier UINT "1" in RegisterRawInputDevice. Am i correct?
Yes, I missed it ( MS names suck ) you need to declare an UINT:
1
2
UINT num = 1;
/*call function ... */ , &num, // ... 


if ( ... = -1) in C++ = is for assignment, so replace it with == which is for comparison
thank you so much.

o the = -1, i missed = :P

thanks for pointing that out.
Hi, more help on amending code. Thanks

RAWINPUTDEVICELIST DeviceList;

DeviceList.hDevice = 0;
DeviceList.dwType = RIM_TYPEHID;

PRAWINPUTDEVICELIST pRawInputDeviceList;

if (GetRawInputDeviceList (pRawInputDeviceList, &uiNumDevices, sizeof (DeviceList)) == FALSE)
{
cout << GetLastError();
}
else
{
cout << "Get Raw Input Device List successful\n" << GetRawInputDeviceList (pRawInputDeviceList, &uiNumDevices, sizeof (DeviceList)) << "\n";
}

free (pRawInputDeviceList);

ok so the problem now is the compiler reports back warning in the function GetRawInputDevice :

warning C4700: uninitialized local variable 'pRawInputDeviceList' used

How can i solve this problem?
You are not allocating pRawInputDeviceList with new or malloc
- if you use new you will have to use delete instead of free -
also for the next function i would be using GetRawInputDeviceInfo ()

where do i get the values for hDevice, pData and pcbSize

http://msdn.microsoft.com/en-us/library/ms645597(VS.85).aspx

for the uiCommand if i want to use RIDI_DevceName I would just write:

GetRawInputDeviceInfo (x, RIDI_DEVICENAME, y, z)

correct?

Thank you for your help
closed account (z05DSL3A)
I think you set pRawInputDeviceList to null.
You the call GetRawInputDeviceList, this will fail but tell you how many devices there are via uiNumDevices. Assign enough space to pRawInputDeviceList and call GetRawInputDeviceList again, this time you should have all the devices.
It depends on which type y is pointing to
Bazzy - I dont really understand what you are saying there. sorry

Grey wolf - what do you mean? so where do i assign the space? and how??

Examples would be great.

Thanks so much
bazzy - how do i know what y is pointing to?
closed account (z05DSL3A)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
UINT nDevices;
PRAWINPUTDEVICELIST pRawInputDeviceList;
if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST)) != 0) 
{ 
    // Error
}
if ((pRawInputDeviceList = malloc(sizeof(RAWINPUTDEVICELIST) * nDevices)) == NULL) 
{
    // Error
}
if (GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST)) == -1) 
{
    //Error
}
// ...

// when finished, free the RAWINPUTDEVICELIST
free(pRawInputDeviceList);
thats the format that i copied from msdn if i remember right, but the same error is still showing.
o and the second if

it says that it cannot convert void to pRawInputDeviceList.
closed account (z05DSL3A)
What error do you get with that?


it says that it cannot convert void to pRawInputDeviceList.
try:
if ((pRawInputDeviceList = (PRAWINPUTDEVICELIST) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices)) == NULL)
Last edited on
error C2440: '=' : cannot convert from 'void *' to 'PRAWINPUTDEVICELIST'

thanks so much for helping me out
Pages: 12