DirectInput: Object instance dwOffset

Started by
0 comments, last by Archi 19 years, 5 months ago
My input subsystem is initialized as follows:

InitializeDirectInput();
DirectInputObject->EnumDevices(...);
And within the device enumeration callback:

DirectInputObject->CreateDevice(ThisDevice->DirectInputDevice);
ThisDevice->SetCooperativeLevel(...);
ThisDevice->SetDataFormat(...);
ThisDevice->DirectInputDevice->GetCaps(...);
ThisDevice->DataBuffer=new long[Caps->dwDataSize>>2];
ThisDevice->Buttons=new InputObject_t[Caps->dwButtons];
ThisDevice->Axes=new InputObject_t[Caps->dwAxes];
ThisDevice->DirectInputDevice->EnumObjects(BUTTONS);
ThisDevice->DirectInputDevice->EnumObjects(AXES);
And within the object enumeration callback, the key line is:

ThisDevice->ThisObject->Data=(byte*)(ThisDevice->DataBuffer)+ThisObject->dwOffset;
So in checking for a button to be down, it's a matter of checking:

(Device->Buttons[n]->Data)&0x80;
The problem is some buttons are coming back permanently 0xFF and thus appearing as "always down" and tripping up my input processing. Is the dwOffset member in the ObjectInstance passed to the EnumObjectsCallback valid even when you've done SetDataFormat, and if not, is there a way to be able to use the dwOffset field with the raw device data?
Advertisement
Quote:Original post by Omaha
ThisDevice->DirectInputDevice->EnumObjects(BUTTONS);ThisDevice->DirectInputDevice->EnumObjects(AXES);



Well I can't imagine why are you using EnumObjects():

=== cut MSDN ==
Applications should not rely on this method to determine whether certain keyboard keys or indicator lights are present, as these objects might be enumerated even though they are not present. Although the basic set of available objects can be determined from the device subtype, there is no reliable way of determining whether extra objects such as the menu key are available.
=== end cut ===

This topic is closed to new replies.

Advertisement