![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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 ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() |
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);}
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] |
|
|
|
|
|
#2 |
![]() ![]() Respected Developer
|
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(); |
|
|
|
|
|
#4 | |
![]() |
Quote:
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] |
|
|
|
|
|
|
#5 | |
![]() ![]() ...in a dream...
|
Quote:
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
|
#6 | |
![]() |
Quote:
__________________
[IMG]http://img.photobucket.com/albums/v693/fchaos/koolaidsig.jpg[/IMG] |
|
|
|
|
|
|
#7 |
![]() ![]() Developer
|
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);
}
ms == mouse speed, which is a variable I change if I need it to move faster
__________________
Developer of Airstrike |
|
|
|
|
|
#8 | |
![]() ![]() Respected Developer
|
Quote:
|
|
|
|
|
|
|
#9 |
![]() OMGZ0R this guy is 1337
|
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.. |
|
|
|
![]() |
| Tags |
| analog , support |
| Thread Tools | |
|
|