I've been trying to get IDirectInputDevice8::EnumObjects working with joysticks (have it working fine with mouse and keyboard), but I run into a problem with the offset values as returned in the EnumObjects callback (using either DIJOYSTATE or DIJOYSTATE2, or even a home-brewed one). An example of an incorrect offset I'm getting is 0 returned for the POV, or 33 for the first digital button enumerated - regardless of which data format I'm using. However, the device state structure is filled in correctly, when calling GetDeviceState.
This seems to be a problem regardless of joystick type - but for reference, I'm using the Logitech Cordless Rumblepad.
Any ideas on what's going on? I've seen a similar post (by Jeff Bell) on the newsgroups, but that was posted almost 3 years ago, and without response. I'm loathe to start querying the DIJOYSTATE/2 structures by member, as it removes the abstraction built into the current code.
Other information - running on Windows XP, with latest SPs, using DirectX v8.1 (haven't upgraded yet to 9.0/b, as there don't seem to be significant DirectInput changes).
Cheers,
Alex.
Mai Dao [MSFT]
--------------
This posting is provided "AS IS" with no warranties, and confers no righ.
"Alex Green" <anon...@discussions.microsoft.com> wrote in message
news:B77694D8-078C-4793...@microsoft.com...
Thanks for the response.
Cheers,
Alex.
----- Mai Dao [MSFT] wrote: -----
SetDataFormat tells DirectInput where to copy objects' data into the
DIJOYSTATE/2 structure. If you know the structure of DIJOYSTATE/2, you can
figure out the offsets of the objects. For example: DIJOFS_X, DIJOFS_Y, ...
DIJOFS_BUTTON0, DIJOFS_BUTTON1, ...
Mai Dao [MSFT]
--------------
This posting is provided "AS IS" with no warranties, and confers no righ.
"Alex Green" <anon...@discussions.microsoft.com> wrote in message
news:3DF4B096-1213-4346...@microsoft.com...
So the offset returned by EnumObjects is essentially useless (unless I want access to the raw data)?
Taken from the DirectX 8.1 help (for DIDEVICEOBJECTINSTANCE):
"dwOfs
Offset within the data format at which data is reported for this object. This value can be used to identify the object in method calls and structures that accept the DIPH_BYOFFSET flag."
Then under remarks:
"Warning The value in dwOfs is the offset within the raw data returned by the device, regardless of whether or not the data format has been set for the device." Which is consistent with what you've been indicating.
My interpretation, now, is that the statement "Offset within the data format at which data is reported for this object" is no longer true - is this correct? Also, I've tested this with a Microsoft SideWinder joystick, and even that doesn't match the DIJOYSTATE/2 format...
Yeah, as mentioned previously, the data in the DIJOYSTATE/2 structure reflects the state of the buttons correctly - it's just that using the offset is a cleaner method of accessing the data (for me, at least), without having to build in explicit knowledge of the DIJOYSTATE/2 structures. Again, it works well for mouse and keyboard, but not joysticks. That inconsistency is somewhat baffling.
Oh, and on a related note to the original post, I found further documentation that indicates the dwOfs should be the offset with in the DIJOYSTATE/2 structure - under the help section of DIDEVICEOBJECTDATA:
"dwOfs
For GetDeviceData, the offset into the current data format of the object whose data is being reported; that is, the location in which the dwData would have been stored if the data had been obtained by a call to the IDirectInputDevice8::GetDeviceState method. If the device is accessed as a mouse, keyboard, or joystick, the dwOfs member is one of the mouse device constants, keyboard device constants, or joystick device constants. If a custom data format has been set, it is an offset relative to the custom data format."
Cheers,
Alex.
----- John Devoy wrote: -----
Hello,
Is there a sample anywhere that shows how to access raw joystick data, i'm a relative newbie so the only way i know is the DIJOYSTATE2 method shown in the docs.
Thanks