forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

analog stick acts wierd.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Thu May 24, 2007 8:08 pm    Post subject: analog stick acts wierd. Reply with quote

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:
movement = (float)(pad.Lx)-128.0f;



      if (movement < 20.0f && movement > -20.0f) { movement = 0.0f;}
      else if (movement < 100.0f && movement > -100.0f) {
         if (movement < 0) { movement = -0.01f;}
         else {    movement = 0.01f; }
      }
      else {
         if (movement < 0) {movement = -0.025f;}
         else { movement = 0.025f; }
      }
      player->setRoll(movement, player->rotation.y);
      player->setDirection(VectorRotate(player->rotation.y));



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 ?
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Thu May 24, 2007 8:20 pm    Post subject: Reply with quote

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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Fri May 25, 2007 11:57 pm    Post subject: Reply with quote

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?
Quote:
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 ?
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Cy-4AH



Joined: 31 Jan 2007
Posts: 44
Location: Belarus

PostPosted: Sat May 26, 2007 12:07 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sat May 26, 2007 1:53 am    Post subject: Reply with quote

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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
mc



Joined: 12 Jan 2005
Posts: 212
Location: Linköping

PostPosted: Sat May 26, 2007 5:25 am    Post subject: Reply with quote

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.


_________________
Flying at a high speed
Having the courage
Getting over crisis
I rescue the people
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Sat May 26, 2007 5:38 am    Post subject: Reply with quote

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
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group