| View previous topic :: View next topic |
| Author |
Message |
AntiBNI
Joined: 24 Sep 2007 Posts: 15 Location: Planet Earth
|
Posted: Sun Sep 30, 2007 7:38 am Post subject: Need help on my menu |
|
|
Im having a bit of a problem with my menu.
when the user trys to select a number it doesn't stop one by one,instead it rokets all the way to the top of the menu.
this is the code for better understanding of my problem:
| Code: |
//I want to put something that pauses the counter until the user presses up again.
while(1)//while 1
{
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_UP)
{
num1++ ;
Here <------------
if (num1 <= 1)
{
num1 = 1;
}
else if (num1 >= 9)
{
num1 = 9;
}
else if (num1 == 1)
{
num1 = 1;
pspDebugScreenSetXY(28,16);
printf("%d",num1);
}
else if (num1 == 2)
{
num1 = 2;
pspDebugScreenSetXY(28,16);
printf("%d",num1);
}
else if (num1 == 3)
{
num1 = 3;
pspDebugScreenSetXY(28,16);
printf("%d",num1);
}
}
else if (pad.Buttons & PSP_CTRL_DOWN)
{
num1-- ;
if (num1 <= 1)
{
num1 = 1;
}
else if (num1 >= 9)
{
num1 = 9;
}
}
if (pad.Buttons & PSP_CTRL_CROSS)
{
fclose (file);
sceKernelExitGame();
}
}
} |
I need to know some way of just adding 1 to the string and pausing it.
Help will be Appriciated. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun Sep 30, 2007 11:02 am Post subject: |
|
|
You can check which buttons changed by doing
lastpad = pad.Buttons from last time round
thispad = pad.Buttons
newbuttons = thispad & ~lastpad
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Sep 30, 2007 11:17 am Post subject: |
|
|
| What Jim said - you need to debounce the keys. Look for a CHANGE in the key state, not the current state. |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Sun Sep 30, 2007 7:30 pm Post subject: |
|
|
| Or use OSlib - it allows you to see if key was pressed,released,or is it holded. |
|
| Back to top |
|
 |
|