PDA

View Full Version : Joystick buttons don't work?



nzo2
07-05-2007, 08:04 PM
I just tried to implement joystick support and found (not suprised) that it doesn't work very well.
OK.. so the axis are screwed on the movement and forcefeedback doesn't work.. I can fix the axis and lose the FF, but... erm. NO BUTTONS WORK!

Anyone successfully using a joystick with DelphiX ?

thanks

seiferalmasy
08-05-2007, 12:59 AM
FFB doesn't work with delphix at the moment anyway.

But buttons should definately work, and, for axis I use:

if (mainfm.DXInput1.Joystick.Joystate.rgdwPOV[0]=0)then
begin


This will be UP direction with digital ON.

Other values (for the =0 part) are then 18000, 27000, 9000 for other directions, and yes values for diagonals are there too. I forget but I think 4500 is one, then half way between 9000 and 18000 so on so on so on

But should you not want digital anyway, it won't matter because as I say, FFB is not even working at the moment for delphix

Show me some of your code

nzo2
08-05-2007, 05:36 PM
I tried the joystick sample from Cerebral Bicycle, as well as the joystick samples that come with DelphiX.

Joystick.ButtonCount returns 16, but all buttons return false at all times!?

This is using a PS2 controller with the USB interface (it does work ok on other stuff).

I also have a Saitek X52 and a Logitec steering wheel I can try to eliminate the PS2 controller from the problem - but I REALLY want the PS2 controller because it is ideally suited to the game I`m making (Robotron).

Cheers

seiferalmasy
08-05-2007, 05:44 PM
i use a ps2 controller also:) using joybox 5

now, show me the code you are using. to check if normal axis are input you do:

if (isup in dxinput1.states)then
begin
...movement here for up....

also, make sure at the start of your code in the timer (ontimer) you have dxinput1.update;

for buttons 1 to 12 on a ps2 joypad it is the same:

isbutton1 in dxinput1.states for triangle for example

this UPDATES the states, without it, the code is as good as useless

nzo2
08-05-2007, 10:37 PM
This is in the timer:



for i := 0 to DXInput1.Joystick.ButtonCount do
begin
if DXInput1.Joystick.Buttons[i] = True then
begin
str(i,StrVal);
MessageDlg(StrVal,mtInformation,[mbOK] ,0);
end;
end;

DXInput1.Joystick.Buttons[i] doesn't work, and just use DXInput1.States?
OK.. I`ll try now...

OK, dxinput1.update is there of course.
Even Hori example doesn't work (button1). Movement works (wrong directions, but can be fixed)
Maybe I have a bad DXInput.pas file?

nzo2
09-05-2007, 12:08 AM
Duh!!

The property "UseDirectInput" should be false.. then everything works! (except FFB.. but what the hell)

seiferalmasy
10-05-2007, 08:38 PM
yeah the code you are using also works, but isbutton1 etc does the same thing. I guess your way is better in other circumstances too:)

And yeah, i was about to make sure you had that set right;)

nzo2
10-05-2007, 10:34 PM
Yes, All is good now.

It was kind of an afterthought to set that property, as when I looked thru the DXInout code, I see that DX isn't used for the joystick!!!