analog stick acts wierd.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

analog stick acts wierd.

Post by Ghoti »

Hi folks,

is it standard PSP behaviour with programming only that the analog stick tends to go left without reason (i guess not so here is the code) can someone tell me what i do wrong ?

Code: Select all

movement = (float)(pad.Lx)-128.0f;



		if &#40;movement < 20.0f && movement > -20.0f&#41; &#123; movement = 0.0f;&#125;
		else if &#40;movement < 100.0f && movement > -100.0f&#41; &#123;
			if &#40;movement < 0&#41; &#123; movement = -0.01f;&#125;
			else &#123; 	movement = 0.01f; &#125;
		&#125;
		else &#123;
			if &#40;movement < 0&#41; &#123;movement = -0.025f;&#125;
			else &#123; movement = 0.025f; &#125;
		&#125;
		player->setRoll&#40;movement, player->rotation.y&#41;;
		player->setDirection&#40;VectorRotate&#40;player->rotation.y&#41;&#41;;

as yo ucan see i check whether the value is beyond +20 or -20 to cure this problem for the most part but sometimes it still turns left automatically :S i can make the marge larger but then the death spot of the analog control gets to big i guess?

anyone got some solution ?
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

The analog stick is.... analog :p that is, not very precise.
You have to take in account a minimal treshold. The stick will never be at (0, 0). The weirdest is that it doesn't have a "dead zone", its value depend from the direction you moved it last time, but it should always be in a range of +/- 32 when it's released (or more on some PSP, I don't know).
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

ah yes well i had it on ±20 but now i have set it on 32 and it is a lot better now :D thanks for the info but i do like to know why exactly this is and why it is such a big number. I mean can't they make analog precise or is it to expensive?
depend from the direction you moved it last time
so when i press it to the max left and then a little to the right it will give info that you move right instead of less left ?
Cy-4AH
Posts: 44
Joined: Wed Jan 31, 2007 9:58 pm
Location: Belarus

Post by Cy-4AH »

No, it will give max left minus little to the right.
Why you don't try sample from pspsdk witch display analog status?
It's placed at pspdev\psp\sdk\samples\controller\basic
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

My english is not good, and so my explanations are :p
You'll see what I'm talking about when trying the analog sample :)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
User avatar
mc
Posts: 211
Joined: Wed Jan 12, 2005 7:32 am
Location: Linköping

Post by mc »

Ghoti wrote:I mean can't they make analog precise or is it to expensive?
The analog stick is of a very simple construction. The stick itself is fixed
to a small plastic disc, which rests inside of a circular coil spring. The
spring is suspened around a plastic ridge, that the disc can slide under,
but not the spring. (See the diagram below.) When you push the stick in
some direction, the disc will slide out under the ridge, dislocating a part
of the spring. Since the other side of the spring is suspended by the
ridge, the spring can't follow the disc by simple translation, and will
instead stretch to fit around the disc. This tightens the spring, producing
a force to pull back the disc (and thus the stick) when you let go.
However, as the disc slides back, the spring contracts, resulting in less
and less force being applied. When the stick has reached a certain
point (+20, or whatever), there spring will have contracted so much that
there is not enough stored force left to overcome the friction between the
disc and the ridge. So the lack of good centering is the result of cheap
design. Not _bad_ design, just cheap.

Image
Flying at a high speed
Having the courage
Getting over crisis
I rescue the people
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

wow! that was the info i needed :D now i understand why it is :) thank you very much for the explaination. it is really clear now ! :D:D
Post Reply