Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Dark GDK issue with gamepad (twin sticks)

Author
Message
asdronin
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 13th Jun 2015 02:05
Hi all,
Thanks to s_i I was pointed to the right direction about gamepad correct recognition inside the GDK 1.0, but now I have a certain problem with this. Im currently trying a PS2 controller connected with adapter to the PC and I notice that the left stick value are not always read correctly and in fact I was specting values to be 0 if that direction is not pressed on the stick but some value remain 1 always, and even if they react its like they remain after the controller stick is not pressed in that direction. Also I noticed that the second stick corresponds to the Z twist but these values given are really huge and hard to isolaate, then how you determine what direction and possibly how hard its being pressed? because not even when centered it becomes 0 and it seems to not be measuring the angle or not that I notice, then Im sure there is a way to calculate what direction(s) are we pointing at with accuracy or at least determine up/down/left/right.

By the way the controller works fine on the actual PS2 and tested the adapter on ps3 machine too but its aimed at pc and console connection.

Well I hope you can give me some clues, thank you very much in advance.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 13th Jun 2015 08:59
The right stick on a controller is accessed with dbJoystickZ() and dbJoystickTwistZ(). The dbJoystick{X, Y, Z} functions return a value between -1000 to 1000 with 0 being center. There is an undocumented function - dbSetJoystickDeadzone() that sets a percentage of stick movement before the dbJoystick{Up, Down, Left, Right} is triggered. The function dbJoystrickTwistZ() returns a value between 0 to 65535 with 32767 being center.

This code is a little sloppy, but hopefully will help.

asdronin
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 13th Jun 2015 22:48 Edited at: 13th Jun 2015 22:52
Awesome code WickedX, kudos for you, I wish I could give you rep, thanks a lot . I noticed dbSetJoystickDeadzone is not present here, well Im using GDK 1.0 or I think its this version, in any case its previous to 2.0, I checked the definition file for the input library and that function wasnt there and found no other function similar, well not that I think. So I did my best to limit the range of the values for left stick as I understood watching your code and explanation that the deadzone should be set so that when stick is in center or almost, the program reacts as nothing is being pushed. Also I did an extra condition for right stick because it was perfect but maybe my stick has a wider deadzone so sometimes it it showed a direction when coming back to center from other, so I think it works now for mine too.

However there is something that goes around my mind... is this code more or less standard for all twin sticks we can find in any controller? or we have to create different solutions for each gamepad? I dont have other gamepad here to check but as soon as I can I will try it of course but I bet you already know the answer to this.

Forgot to mention that there are some magical numbers, I just did many trial and error until the center status was correctly detected.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jun 2015 22:52
Quote: "However there is something that goes around my mind... is this code more or less standard for all twin sticks we can find in any controller? or we have to create different solutions for each gamepad? I dont have other gamepad here to check but as soon as I can I will try it of course but I bet you already know the answer to this."


I'm using a Logitect Dual Action controller and have used a few other controllers. It would seem standard with all dual stick controllers.
asdronin
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 16th Jun 2015 06:30
Cool , thanks a lot for clarifying this, then I assume from one controller to other the only changes are fire buttons, which of course are highly customizable as I read in help file that says it can recognize up to 32 of that kind, right?

Login to post a reply

Server time is: 2024-11-18 19:43:16
Your offset time is: 2024-11-18 19:43:16