Analogue Pad
Analogue Pad
Hey,
I've been searching away at this, and got little or no sucsess. I'm jsut trying to work out how to use the bloody thing! Search on the forums will only let you view the 1st page of results :/
From what I know:
CtrlSetAnalogMode(1);
needs to be put at the beginning of your code if you plan to use the analogue stick.
if(pad.Buttons & PSP_CTRL_CIRCLE) <- returns a value, so I'm wodering do I just do this...
if(pad.Buttons & PSP_ANALOG_X == ???)
{
//....
}
Is that on the rightlines...
I'm so close to something that I consider releasable (in an early form). Just really polishing and sorting bugs and stuff :/
Thanks for any help.
I've been searching away at this, and got little or no sucsess. I'm jsut trying to work out how to use the bloody thing! Search on the forums will only let you view the 1st page of results :/
From what I know:
CtrlSetAnalogMode(1);
needs to be put at the beginning of your code if you plan to use the analogue stick.
if(pad.Buttons & PSP_CTRL_CIRCLE) <- returns a value, so I'm wodering do I just do this...
if(pad.Buttons & PSP_ANALOG_X == ???)
{
//....
}
Is that on the rightlines...
I'm so close to something that I consider releasable (in an early form). Just really polishing and sorting bugs and stuff :/
Thanks for any help.
you should have a look at the pspsdk code in svn from time to time ;)
especially here
I think you can guess the rest :)
EDIT: if not, here's the sample from svn
especially here
Code: Select all
/** Returned controller data */
typedef struct SceCtrlData {
/** The current read frame. */
unsigned int TimeStamp;
/** Bit mask containing zero or more of ::PspCtrlButtons. */
unsigned int Buttons;
/** Analogue stick, X axis. */
unsigned char Lx;
/** Analogue stick, Y axis. */
unsigned char Ly;
/** Reserved. */
unsigned char Rsrv[6];
} SceCtrlData;
EDIT: if not, here's the sample from svn
infj
Saotome wrote:you should have a look at the pspsdk code in svn from time to time ;)
especially here
I think you can guess the rest :)Code: Select all
/** Returned controller data */ typedef struct SceCtrlData { /** The current read frame. */ unsigned int TimeStamp; /** Bit mask containing zero or more of ::PspCtrlButtons. */ unsigned int Buttons; /** Analogue stick, X axis. */ unsigned char Lx; /** Analogue stick, Y axis. */ unsigned char Ly; /** Reserved. */ unsigned char Rsrv[6]; } SceCtrlData;
EDIT: if not, here's the sample from svn
Awww I'm sooo close now Thanks! :)
I got this:
Code: Select all
while(1)
{
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(1);
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Lx > 132)
{
if(pad.Lx < 192)
{
if(player_x < 422)
{
player_x += 4;
}
}
else
{
if(player_x < 417)
{
player_x += 9;
}
}
}
}
how about something like this (not tested but I'm using something similar):
Code: Select all
int xx,yy;
xx = (int)pad.Lx - 128;
yy = (int)pad.Ly - 128;
if ((xx * yy) > 500) //maybe some higher value
{
player_x += xx >> 4;
player_y += yy >> 4;
}
infj
That's a nice way of doing it... :)
Guess the code should actually be:
That works quite well. Big thanks for your help.
Hoping to get something out by mid next week.
(only issue I see is if xx or yy equals 0 then you don't get anywhere. Should be easy to fix though.)
Guess the code should actually be:
Code: Select all
int xx,yy;
xx = (int)pad.Lx - 128;
yy = (int)pad.Ly - 128;
if ((xx * yy) > 500 || (xx * yy) < -500) //maybe some higher value
{
player_x += xx >> 4;
player_y += yy >> 4;
}
Hoping to get something out by mid next week.
(only issue I see is if xx or yy equals 0 then you don't get anywhere. Should be easy to fix though.)
Ah, yes that was not correct (it was still early in the morning ;)), sorry. But actually it should have been:Energy wrote:That's a nice way of doing it... :)
Guess the code should actually be...
Code: Select all
int xx,yy;
xx = (int)pad.Lx - 128;
yy = (int)pad.Ly - 128;
if ((xx*xx + yy*yy) > 500) //maybe some higher value
{
player_x += xx >> 4;
player_y += yy >> 4;
}
That should fix your issue with "xx or yy equals 0"
infj
-
- Posts: 9
- Joined: Thu Aug 11, 2005 1:52 pm
I remember getting the whole range in my psp controller tests. The only thing is that you really want to have small dead zone in the middle, something like +-18 (so yeah the effective range is something like 220). The reason is that when you release the analog stick it never really gets back to the center.