Jump to content
  • Advertisement
Sign in to follow this  

Buffered joystick input always empty

This topic is 3854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;

	for(int i=0; i < num_joysticks; i++){
		status = pads->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), buffer, &buffsize,0);
		if(status == DI_BUFFEROVERFLOW)
		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?

Share this post

Link to post
Share on other sites

so lame misstake, buffer size variable has to be reset per device in for-loop :-)

DWORD buffsize = BUFFERSIZE; <-- had to be in for loop before call to GetDeviceData; I can't believe I was so blind ...

It works awesome, and it solves problem of multiple keypresses, if you remember my previous post about polling gamepad :-).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!