Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Pages: [1] 2

Author Topic: joystick axis problem  (Read 5095 times)

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« on: November 16, 2006, 06:43:14 AM »

Hi,

I have some problem with the joystick axis. Actually the symptoms are the following:

Moving the first joystick along the X axis has no effect.

When I move my Y axis, the value is set to the X axis.

Actually, changing the following line:

Code: [Select]
std::map<int, int>::iterator it = mAxisMapping.find( diBuff[i].dwOfs);

with this one:

Code: [Select]
std::map<int, int>::iterator it = mAxisMapping.find( diBuff[i].dwOfs + 4);

resolve my problem. However, I have no idea where the problem comes from.

Actually, in the DIEnumDeviceObjectsCallback() method, the first X Axis already comes with an offset of 4 (lpddoi->dwOfs), so I guess the problem is coming from here...

I am using the CVS HEAD (from yesterday) and the latest June 2006 DirectX SDK. I will try to upgrade to the new one. I am using Visual Studio 2005.

The consol application sample produces the same result...

I have no alignment instructions anywhere.

Does anybody have the same problem ?
Logged

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« Reply #1 on: November 16, 2006, 07:24:02 AM »

some more information

actually all the axis are wrong.

They are enumerated like this (decimal) :

X0 = 4
Y0 = 8
X1 = 12
Y1 = 16

But then they are triggered as :

X0 = 0
Y0 = 4
X1 = 20
Y1 = 24

I think it is similar to another post. I am using a Thrustmaster Gamepad.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #2 on: November 16, 2006, 08:08:33 AM »

Odd, I'll dig into this a little bit to try to find an answer that works across the board.
Logged

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« Reply #3 on: November 16, 2006, 08:11:05 AM »

Actually I have tried to compile the DirectInput sample. the enum callback report the same values as in OIS.
However, they are using GetDeviceState() instead of GetDeviceData(), so I guess the problem (or the solution ;) may be there...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #4 on: November 16, 2006, 09:03:53 AM »

IDirectInputDevice8::GetDeviceState is for non-buffered reading of devices. It does not give you a list of events, it only gives you the current state of the device.
Logged

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« Reply #5 on: November 16, 2006, 09:17:03 AM »

yes I know, but you could generate the events yourself by comparing the states between two successive captures..

I don't know if it would work, I just know that this GetDeviceState() method works with my joypad in the directinput sample, so I wanted to share the information
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #6 on: November 16, 2006, 09:21:02 AM »

I don't think I really want to be comparing old state versus new state. However, thanks for the info anyway ;) Hopefully there is another way around the issue.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #7 on: November 16, 2006, 09:28:35 AM »

Actually, I might be able to use the UINT_PTR uAppData member to store a map entry value for lookup... I won't be able to test this today likely, so if you want to give it a shot, feel free :)
Logged

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« Reply #8 on: November 16, 2006, 09:31:04 AM »

but how do you know that x0=4 (enum) maps to x0=0 (GetDeviceData()) ??
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #9 on: November 16, 2006, 09:35:56 AM »

The map is used to store two values, the key is the axis number (which is just an incremented value assigned as they are enumerated), and the value of the axis's offset as used in the reading of the value. Technically, the offset should be the same in both enumeration and triggering... But, it appears they are not (always).

And, I just had another thought about the user pointer member, it is probably per device, and not axis, so I guess that is not a viable solution either.
Logged

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« Reply #10 on: November 16, 2006, 09:46:26 AM »

actually I guess their is a misundertood.

the value I am talking about is the "dwOfs" field, which you used in your map to link with the internal OIS axis ID.

The problem is, this "dwOfs" is not consistent (i.e. does not have the same value) between the Enumeration and the GetDeviceData() for the SAME PHYSICAL AXIS.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #11 on: November 16, 2006, 10:31:23 AM »

Oh, I understood what you were talking about... I thing I just noticed and had not noticed before is that the dwOfs member as enumerated (according to the DI docs) is not the same offset into the data format structure (as used in capture). The dwOfs member is the offset into the native device data when in the enumeration method... So, I guess here at least, my XBox controlelr driver was using the same data format that DirectInput was using, so I had no problems. However, you and others with different devices had a different native format from directinput - so you saw conflicting values.

I discovered that I can possibly use the app data pointer, so I am working up a patch now and will post it in a few for you to try.
Logged

gjaegy

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 29
    • View Profile
joystick axis problem
« Reply #12 on: November 16, 2006, 10:33:25 AM »

oh great ;) is it written in the DI doc ? i didn't find it...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #13 on: November 16, 2006, 10:35:10 AM »

Yeah, in the DIDEVICEOBJECTINSTANCE page. There are in fact 2 warnings, don't know how I missed them before - I guess I just considered that the dwOfs member was the only member in both structures that were the same name, and possible only way to link the enumerated axis with the triggered event axis.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
joystick axis problem
« Reply #14 on: November 16, 2006, 11:04:19 AM »

Well, I've sort of got it working.. However, my joystick (at least) seems to have a problem of setting both properties (the range and the user pointer). If I set both for my 2 trigger buttons (axes), then for some reason the user pointer value gets zapped and becomes 0xFFFFFFFF... However, if I just set the user pointer and not the range property, the user pointer is intact. However, than of course the range is not between my desired min/max. Hmm, might just be a crappy driver issue here.

I'll update cvs, right now, and upload a patch. Let me know if you hit the assert.
Logged
Pages: [1] 2