I'm trying to filter raw input devices (with some mapped functions) by vendor id and product id and insert the new ones into an unsigned int array by which I can then see how many devices (keyboards, mice, dualshock controllers etc) are actually present as opposed to each sub device being reported ias though it were a seperate device. The first list in the output is just the values about to be compared, the second list is to confirm duplicate vendor id and product id combinations are filtered out - unfortunatly at the end of that list I somehow get a duplicate which is not what should happen.
Well, in the code you've shown you're not doing any duplicate checking, as far as I can see. Without knowing what framework or library you're working with, the assertion "there should be no duplicates" is an unfounded assumption.
As a matter of fact, in what I guess is the input data to your filter, I can see a duplicate:
You need to work on your communication skills. Remember that other people aren't psychic. It's impossible to understand a question if no context is given.
continue; is no good in this case since I need to skip the outer loop from a sub loop as you can see toward the bottom of the outer loop.
Also I do NOT want c++, c# or objc solutions, c89/c99 only since this is planned to be wrapped around by an optional c++ layer (I'm one those compartmentising types).
Also I won't upload to github yet until I'm happy it's working correctly on the core part, extendid code will begin at that point.
I'd tell you to post b2b_getdevinfo() also, but it looks like it's going to be a fairly complex function, so to avoid an endless back-and-forth, I'll just tell you my suspicion:
I don't think the final array contains any actual duplicates. I think the array contains
where the first number is the VID and the second number is the PID.
I think the problem is that b2bgetdevinfo() is not modifying the contents of info when both VID and PID are zero, so you end just printing the previous element again.
dst is a ptr to an object existing in the calling function (in this case main()). The info array is allocated and released within this called function for the sole purpose of identifying VIDs & PIDs and going back to identify what has already been found. I have since modified the array slightly (and ripped out the b2btprintfs) to this:
1 2 3 4 5 6 7 8 9 10 11 12
if ( vid == 0 && pid == 0 )
{
for ( j = 0; j < i; ++j )
{
ink = &info[j];
if (ini->hid.dwVendorId == ink->hid.dwVendorId)
{
if (ini->hid.dwProductId == ink->hid.dwProductId)
goto omit;
}
}
}
I was referring to the structure of type b2bdevinfo_t named info that gets passed to b2bgetdevinfo(), not to the array named info. (At this point, I think it's worthwhile to complain about the choice of names.)
As you can see by the code I posted last night on windows I have mapped it directly to the API I based it off, also I've just modified the function to this:
Okay was getting the same result only because I didn't notice that compile was skipped because of a typo, fixed it and now the list ends with zeroed out values instead of a duplicate