QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Analog Support

This is a discussion on Analog Support within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Can anyone give me a quick snippet of how to access the analog control. I checked the included controller file ...

Reply
 
LinkBack Thread Tools
Old 02-16-2006, 11:49 AM   #1
 
framerate's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 389
Trader Feedback: 0
Default Analog Support

Can anyone give me a quick snippet of how to access the analog control. I checked the included controller file in the SDK and it seems that the analog is 0,0 by default.. and then has positive negative value equal to the distance you move it...

Is this correct? so just something like:

Code:
if (analogx < 0 ) { move(left);}
etc?

Thanks guys, I just thought I might as well use that stick since it's there
__________________
[URL=http://www.framerate.info/psp][IMG]http://www.framerate.info/_hosted/imageupload/signature.gif[/IMG][/URL]
framerate is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 01:54 PM   #2

Respected Developer
 
Join Date: Jul 2005
Posts: 379
Trader Feedback: 0
Default

Actualy I think the analog stick goes from 0-255 (unsigned). So 128 is the mid point.

Also as long as you init the psp controlls to analog on, you can read the values stored when you call the psp to update input.

// Setup Input
sceCtrlSetSamplingCycle(0 );
sceCtrlSetSamplingMode(PS P_CTRL_MODE_ANALOG);

// Read Input
SceCtrlData PadInput;
sceCtrlReadBufferPositive ( &PadInput, 1 );

if( PadInput.Lx < 32 ) MoveLeft();
if( PadInput.Lx > 255 - 32 ) MoveRight();
nexis2600 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 01:56 PM   #3
 
Join Date: Jan 2006
Posts: 4,288
Trader Feedback: 0
Default

Oh thank you so much. I've been wondering this myself for quite some time.
soccerPMN is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 03:09 PM   #4
 
framerate's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 389
Trader Feedback: 0
Default

Quote:
Originally Posted by nexis2600
Actualy I think the analog stick goes from 0-255 (unsigned). So 128 is the mid point.

Also as long as you init the psp controlls to analog on, you can read the values stored when you call the psp to update input.

// Setup Input
sceCtrlSetSamplingCycle(0 );
sceCtrlSetSamplingMode(PS P_CTRL_MODE_ANALOG);

// Read Input
SceCtrlData PadInput;
sceCtrlReadBufferPositive ( &PadInput, 1 );

if( PadInput.Lx < 32 ) MoveLeft();
if( PadInput.Lx > 255 - 32 ) MoveRight();
Ahh that's the ticket..

But why is it < 32 and > 233?

Wouldn't it be < 178 and > 178? What am I missing here?
__________________
[URL=http://www.framerate.info/psp][IMG]http://www.framerate.info/_hosted/imageupload/signature.gif[/IMG][/URL]
framerate is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 04:06 PM   #5

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Quote:
Originally Posted by framerate
Ahh that's the ticket..

But why is it < 32 and > 233?

Wouldn't it be < 178 and > 178? What am I missing here?
Ok, start up some game with analog support, move tha analog stick up a little bit, does the thing move? No, because the PSP only recognizes the Analog movements for 32. Any where below that, it's basically pointless cause nothing will happen.
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 04:20 PM   #6
 
fchaos's Avatar
 
Join Date: Sep 2005
Location: Texas
Posts: 146
Trader Feedback: 0
Default

Quote:
Originally Posted by framerate
Ahh that's the ticket..

But why is it < 32 and > 233?

Wouldn't it be < 178 and > 178? What am I missing here?
The analog stick is very sensitive, so sometimes when the stick isn't being moved, a value of 150-200 is produced. It's best to stay clear of that range. I don't know why nexis made the values so small though...
__________________
[IMG]http://img.photobucket.com/albums/v693/fchaos/koolaidsig.jpg[/IMG]
fchaos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 05:21 PM   #7

Developer
 
Smerity's Avatar
 
Join Date: Jun 2005
Location: Sydney, Australia
Posts: 128
Trader Feedback: 0
Default

Something I was interested in trying out was kind of a fine analog variation algorithm. Haven't had time to try it yet though.

Basically it's weighted so that if it's below about 25 to 35 it has no effect (ie, think a very very squished parabola, and then you can input our x (analog number) into that and as you push harder the amount it goes becomes further, whilst small values have little effect)

Babble out of the way, here's a snippet of my very simple analog code...

Code:
int cursorx = 240, cursory = 136;
float ms = 1;

while (1) {
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
SceCtrlData pad;

sceCtrlReadBufferPositive(&pad, 1);

clearScreen(BLACK);

float cx = ((pad.Lx - 125)/16)*ms;
float cy = ((pad.Ly - 125)/16)*ms;
cursorx = cursorx + (int)cx;
cursory = cursory + (int)cy;
if ( cursorx > 480 ) cursorx = 480;
if ( cursory > 272 ) cursory = 272;
if ( cursorx < 0 ) cursorx = 0;
if ( cursory < 0 ) cursory = 0;

blitAlphaImageToScreen( 0, 0, 24, 24, cursor, (int)cursorx-12, (int)cursory-12);
flipScreen();
sceKernelDelayThread(50000);
}
To note -
ms == mouse speed, which is a variable I change if I need it to move faster
__________________
Developer of Airstrike
Smerity is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 07:49 PM   #8

Respected Developer
 
Join Date: Jul 2005
Posts: 379
Trader Feedback: 0
Default

Quote:
Originally Posted by framerate
Ahh that's the ticket..

But why is it < 32 and > 233?

Wouldn't it be < 178 and > 178? What am I missing here?
As someone already noted. The analog is rather sensative and when at rest is not a perfect 128/128. I just gave 32 as an example (in other words only accepting the input that has the analog almost all the way near the edge).
nexis2600 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 08:33 PM   #9
OMGZ0R this guy is 1337
 
elevationsnow's Avatar
 
Join Date: Aug 2005
Location: Minnesota, MN (originally england)
Posts: 218
Trader Feedback: 0
Default

heres my absolutly insane analogue function it does a parabola changing the value 2 you can change how much it accelerates aka the parabola thing you were talking about
Code:
         xx = pad.Lx - 130;
         yy = pad.Ly - 130;  
         speed = sqrt((xx*xx)+(yy*yy))/(2*sqrt(sqrt((xx*xx)+(yy*yy))));//harder you press analogue faster it goes
         rotation =  atan2(xx,yy) / (PI/180); //figure out the rotation of the analouge this **** is pointless i was just messing arround im gonna clean this up thats why i called it insane
         x2 = sin(rotation*(PI/180))*speed;
         y2 = cos(rotation*(PI/180))*speed;
         pbrushx = brushx;  //for my brush so it doesnt have gaps from speed its a painting program 
         pbrushy = brushy; 
         if(xx>25 && brushx<480){
         brushx += x2;
         }
         if(xx<-25 && brushx>0){
         brushx += x2;
         }
         if(yy>25 && brushy<272){
         brushy += y2;
         }
         if(yy<-25 && brushy>0){ 
         brushy += y2;
         }
__________________
[IMG]http://img26.imageshack.us/img26/4208/sigcopy0lu.jpg[/IMG]

Last edited by elevationsnow; 02-16-2006 at 08:37 PM..
elevationsnow is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 08:59 PM   #10

Developer
 
Smerity's Avatar
 
Join Date: Jun 2005
Location: Sydney, Australia
Posts: 128
Trader Feedback: 0
Default

elevationsnow - lol, wow, that looks a lot more complicated than it did in my head, but same basic concept, good stuff =)
__________________
Developer of Airstrike
Smerity is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
analog , support

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 07:16 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us