| View previous topic :: View next topic |
| Author |
Message |
Energy
Joined: 26 Mar 2005 Posts: 133 Location: uk/beds/flitwick
|
Posted: Fri Feb 24, 2006 6:56 am Post subject: 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. |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Fri Feb 24, 2006 8:16 am Post subject: |
|
|
you should have a look at the pspsdk code in svn from time to time ;)
especially here
| Code: |
/** 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;
|
I think you can guess the rest :)
EDIT: if not, here's the sample from svn _________________ infj |
|
| Back to top |
|
 |
Energy
Joined: 26 Mar 2005 Posts: 133 Location: uk/beds/flitwick
|
Posted: Fri Feb 24, 2006 9:13 am Post subject: |
|
|
| Saotome wrote: | you should have a look at the pspsdk code in svn from time to time ;)
especially here
| Code: |
/** 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;
|
I think you can guess the rest :)
EDIT: if not, here's the sample from svn |
Awww I'm sooo close now Thanks! :)
I got this:
| Code: |
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;
}
}
}
}
|
Now my only issue is that the bloody thing doesn't stop moving. Yet it gives me control of it! :) Getting there slowly :D[/code] |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Fri Feb 24, 2006 5:29 pm Post subject: |
|
|
how about something like this (not tested but I'm using something similar):
| Code: |
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 |
|
| Back to top |
|
 |
Energy
Joined: 26 Mar 2005 Posts: 133 Location: uk/beds/flitwick
|
Posted: Fri Feb 24, 2006 10:42 pm Post subject: |
|
|
That's a nice way of doing it... :)
Guess the code should actually be:
| Code: |
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;
}
|
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.) |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Fri Feb 24, 2006 11:03 pm Post subject: |
|
|
| Energy wrote: | That's a nice way of doing it... :)
Guess the code should actually be... |
Ah, yes that was not correct (it was still early in the morning ;)), sorry. But actually it should have been:
| Code: |
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;
}
|
(xx*xx+yy*yy) is the square-radius then.
That should fix your issue with "xx or yy equals 0" _________________ infj |
|
| Back to top |
|
 |
orphan frequently
Joined: 11 Aug 2005 Posts: 9
|
Posted: Sat Feb 25, 2006 12:51 pm Post subject: |
|
|
When i talked to an official dev he said that the max X is 217 and the max Y is 218. True? _________________ Mike3285: wtf is a palindrome
MaroonSand: no its not dude |
|
| Back to top |
|
 |
memon
Joined: 03 Oct 2005 Posts: 63
|
Posted: Sun Feb 26, 2006 10:15 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
|