View Full Version : Problem with joystick axes on delphiX

22-11-2005, 12:51 PM
Please help,

I use delphi X directinput for joystick control. When I read the values from my joystick I see that axes are switched. So the Y value is read at the dijoystate2.IZ and the X value is nowhere. As soon as I set the property UseDirectInput to false, the axes are OK. But then I can't use for example the torsion of the joystick handle. Who can help me out?

This is how I read the values (via a timer):

procedure TForm6.DXTimer1Timer(Sender: TObject; LagCount: Integer);
js : Tdijoystate2;
js := dxinput1.Joystick.Joystate;
lb.AddItem('IX' + inttostr(js.lX), nil);
lb.AddItem('IY' + inttostr(js.lY), nil);
lb.AddItem('IZ' + inttostr(js.lZ), nil);
lb.AddItem('IRx' + inttostr(js.lRx), nil);
lb.AddItem('IRy' + inttostr(js.lRy), nil);
lb.AddItem('IRZ' + inttostr(js.lRZ), nil);
lb.AddItem('IVx' + inttostr(js.lVX), nil);
lb.AddItem('IVy' + inttostr(js.lVy), nil);
lb.AddItem('IVZ' + inttostr(js.lVz), nil);
lb.AddItem('IVRx' + inttostr(js.lVRx), nil);
lb.AddItem('IVRy' + inttostr(js.lVRy), nil);
lb.AddItem('IVRz' + inttostr(js.lVRz), nil);
lb.AddItem('IAx' + inttostr(js.lAX), nil);
lb.AddItem('IAy' + inttostr(js.lAy), nil);
lb.AddItem('IAz' + inttostr(js.lAz), nil);
lb.AddItem('IARx' + inttostr(js.lARx), nil);
lb.AddItem('IARy' + inttostr(js.lARy), nil);
lb.AddItem('IARz' + inttostr(js.lARz), nil);
lb.AddItem('IFx' + inttostr(js.lFX), nil);
lb.AddItem('IFy' + inttostr(js.lFy), nil);
lb.AddItem('IFz' + inttostr(js.lFz), nil);
lb.AddItem('IFRx' + inttostr(js.lFRx), nil);
lb.AddItem('IFRy' + inttostr(js.lFRy), nil);
lb.AddItem('IFRz' + inttostr(js.lFRz), nil);
lb.AddItem('rglslider0' + inttostr(js.rglSlider[0]), nil);
lb.AddItem('rglslider1' + inttostr(js.rglSlider[1]), nil);
lb.AddItem('rglVslider0' + inttostr(js.rglVSlider[0]), nil);
lb.AddItem('rglVslider1' + inttostr(js.rglVSlider[1]), nil);
lb.AddItem('rglAslider0' + inttostr(js.rglASlider[0]), nil);
lb.AddItem('rglAslider1' + inttostr(js.rglASlider[1]), nil);
lb.AddItem('rglFslider0' + inttostr(js.rglFSlider[0]), nil);
lb.AddItem('rglFslider1' + inttostr(js.rglFSlider[1]), nil);


lb is a listbox on a form that I fill with the actual values of the joystick.


22-11-2005, 10:12 PM
Joystate? Have you tried dxinput1.Joystick.X , dxinput1.Joystick.Y and so on? Like dx keyboard i hardly ever use keyboard.states. Commonly those states are defined clicking the TXDInput component on form.

25-11-2005, 07:18 PM
This gives me the same problem. The axes are stil wrong.