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?