Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Joystick events not always being received in commandlinedemo  (Read 2045 times)

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/

I changed the axisMoved function in the demo to actually display data:
Code: [Select]
bool axisMoved( const JoyStickEvent &arg, int axis ) {
if( arg.state.mAxes[axis].abX<1024 && arg.state.mAxes[axis].abX>-1024 &&
arg.state.mAxes[axis].abY<1024 && arg.state.mAxes[axis].abY>-1024)
return true;
std::cout << "\nJoy AxisMoved: " << axis << " Abs(" << arg.state.mAxes[axis].abX << "," << arg.state.mAxes[axis].abY << "," << arg.state.mAxes[axis].abZ << ")";
return true;
}


When I use my joystick, the buttons and axis return very odd data.

First of all, using the test in the game controllers dialog in the control panel works perfect, no delay, just perfect in every way.  The joystick demo in the DX SDK works identically to the game controllers, perfect.  This commandline demo however, runs oddly.  First of all, buttons are not always regestered as being pressed, and even more rare is it receiving a released signal.  It happens with all twenty buttons on the gamepad.  The axis also receives intermitent updates, not to mention it always returns zero for the axis, and the results of the two axis I have (X,Y and rudder(R),throttle(Z)) seem to be intermixed within this one axis it returns.  I have not yet tested this in my app as I was worried about this (I was verifing which axis went to which direction first).  Is it just something about the command line demo and my app should work fine (I always use buffered), or is something going on considering it works perfectly elsewhere?  The POV works most of the time, it only skips an event once in a while.  All other inputs on the system work fine.  Ideas?  This is last updated about two weeks ago.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Joystick events not always being received in commandlinedemo
« Reply #1 on: May 02, 2006, 09:07:13 AM »

Recently, I just upp'ed all the buffer values for DX Input. There is a thread on it here. Probably your problem if you are missing events. Previously (0.6 and below), the buffer sizes for keyboard/mouse/joystick was set to 17. So, likely, that was too low, and you are seeing issues.

I have since seperated the vales into three defines JOYSTICK_BUFFER MOUSE_BUFFER etc.. Whereas before, it was just DX_BUFF_SIZE or something similiar in ois/includes/win32/Win32Prereqs.h

You can bump up that one define to something higher (I bumped mouse up to 64, and joystick up to 120 in CVS), or you can try to check out anonymous CVS, hopefully, Sourceforge.net is syncing up the anonymous cvs with Dev cvs by now.. Last week, they were not, and had not been for over a month :/
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Joystick events not always being received in commandlinedemo
« Reply #2 on: May 02, 2006, 12:37:02 PM »

Last I checked SF is still not synced, so I will try to up the values myself when I get home this evening.  I am not sure it would be the buffer though, because no other inputs were coming in (was not touching keyboard or mouse), and it would just seem to ignore the joystick inputs randomly, even if I was only sending one change a second...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Joystick events not always being received in commandlinedemo
« Reply #3 on: May 02, 2006, 01:40:42 PM »

Each buffer is independent. So, this would not affect mouse or keyboard. But, 17 Events per capture is not that many for a devce with multiple possible axes, and more then a dozen buttons or so.

Considering, that a mouse with two (or three) axes, and at most three buttons would have unreliable values with a buffer size of 17 - 64 was determined to be more appropriate for the mouse. Hence, I also bumped up joysticks to twice that. So, that would appear to be your problem.

As, OIS just recieves events from DirectInput, and sends those to the client app. You could sprinkle some debuggin printf's, cout's or log messages inside that part of OIS to determine if it is just ignoring the events for whatever reason.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Joystick events not always being received in commandlinedemo
« Reply #4 on: May 02, 2006, 03:57:13 PM »

Found:
Code: [Select]

#define KEYBOARD_DX_BUFFERSIZE 17
#define MOUSE_DX_BUFFERSIZE 17
#define JOYSTICK_DX_BUFFERSIZE 17


Changed to:
Code: [Select]

#define KEYBOARD_DX_BUFFERSIZE 64
#define MOUSE_DX_BUFFERSIZE 64
#define JOYSTICK_DX_BUFFERSIZE 128


Testing now, will edit post after compile and test...

EDIT:  Yep, that was the cause of one of the two problems, no more missing events. :)

Now the other problem, why are both of the axis' on my gamepad being reported to OIS as 1 axis.  The joystick DX test app and the control panel thing both see them seperatly.  OIS is merging the data from the two into one axis giving pretty invalid data when both are moved at the same time...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Joystick events not always being received in commandlinedemo
« Reply #5 on: May 02, 2006, 07:39:34 PM »

That is the reason behind action mapping. Not everyone has the same layout controller. You cannot expect that everyone's axis will be the same.

Plus, i bet the DX Demo is using the plain vanillia Joystick structure (and not the extended version), which is slightly different in behavior. Anyway, you are free to sprinkle some debuggin cout's in the event handler, to see what DX is reporting, and what is filled into the OIS info.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Joystick events not always being received in commandlinedemo
« Reply #6 on: May 03, 2006, 12:03:52 AM »

Quote from: "pjcast"
That is the reason behind action mapping. Not everyone has the same layout controller. You cannot expect that everyone's axis will be the same.

Plus, i bet the DX Demo is using the plain vanillia Joystick structure (and not the extended version), which is slightly different in behavior. Anyway, you are free to sprinkle some debuggin cout's in the event handler, to see what DX is reporting, and what is filled into the OIS info.


The DX Demo I use is from the latest DX SDK (April 2k6) so you can see it for yourself if it does or not.  I will try to trace through OIS when I get some it. :)
Logged

skapie

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 12
    • View Profile
Joystick events not always being received in commandlinedemo
« Reply #7 on: July 03, 2006, 02:48:59 AM »

:D  :D  Hey, I also had trouble with axes and values getting messed up, but the DX SDK joystick demo worked perfectly. Anyway, I'm glad to report that I found the bug. In Win32JoyStick::_readBuffered() the code was:  
Code: [Select]
switch(diBuff->dwOfs)
I canged it to:
Code: [Select]
switch(diBuff[i].dwOfs)
The old line caused an incorrect dwOfs and that's why the input got assigned to the wrong axis.  :wink:

Cheers!
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Joystick events not always being received in commandlinedemo
« Reply #8 on: July 03, 2006, 07:59:16 AM »

Awesome find :shock:

This has been fixed and committed.. To bad it didn't make it to the 0.7.1 release though. But, thanks for you post :)
Logged