I am trying to change my input from immidiate to buffered. I have setuped everything according to docs, but number of read items is always 0.
In my init joystick routine I have this code to set buffer size:
// Set BUFFERSIZE.
DIPROPDWORD dipbs;
dipbs.diph.dwSize = sizeof( dipdw );
dipbs.diph.dwHeaderSize = sizeof( dipdw.diph );
dipbs.diph.dwObj = 0;
dipbs.diph.dwHow = DIPH_DEVICE;
dipbs.dwData = BUFFERSIZE; // Arbitary buffer size
joystick->SetProperty( DIPROP_BUFFERSIZE, &dipbs.diph );
and then when I read input I have this code:
void buffered_joystick()
{
int status;
DWORD buffsize = BUFFERSIZE;
DIDEVICEOBJECTDATA buffer[BUFFERSIZE];
for(int i=0; i < num_joysticks; i++){
pads->Poll();
status = pads->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), buffer, &buffsize,0);
if(status == DI_BUFFEROVERFLOW)
puts("overflow");
if(status == DI_OK){
puts("read ok");
if(buffsize != 0)
printf("number of items: %l\n",buffsize);
for(int j = 0; j < buffsize; j++){
// do something here ....
}
}
}
(this is just very simplified version to illustrate my problem).
Now I do get DI_OK status all the time, but buffsize is always set to 0, which means 0 events are read.
I have no problems when reading with GetDeviceState.
What can be problem with buffered read?