Need help on my menu

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
AntiBNI
Posts: 15
Joined: Mon Sep 24, 2007 1:15 pm
Location: Planet Earth

Need help on my menu

Post by AntiBNI »

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: Select all

	

//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 &#40;num1 <= 1&#41;
				 &#123;
				 num1 = 1;
			 &#125;
				 else if &#40;num1 >= 9&#41;
				 &#123;
					 num1 = 9;
				 &#125;
				 else if &#40;num1 == 1&#41;
				 &#123;
					 num1 = 1;
					 pspDebugScreenSetXY&#40;28,16&#41;;
	                 printf&#40;"%d",num1&#41;;
				 &#125;
				 else if &#40;num1 == 2&#41;
				 &#123;
					 num1 = 2;
					 pspDebugScreenSetXY&#40;28,16&#41;;
	                 printf&#40;"%d",num1&#41;;
				 &#125;
				 else if &#40;num1 == 3&#41;
				 &#123;
					 num1 = 3;
					 pspDebugScreenSetXY&#40;28,16&#41;;
	                 printf&#40;"%d",num1&#41;;
				 &#125;
			&#125;
			else if &#40;pad.Buttons & PSP_CTRL_DOWN&#41;
			&#123;
				num1-- ;
		     if &#40;num1 <= 1&#41;
				 &#123;
				 num1 = 1;
			 &#125;
				 else if &#40;num1 >= 9&#41;
				 &#123;
					 num1 = 9;
				 &#125;
			&#125;
			 if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;
			 &#123;
              fclose &#40;file&#41;;
			  sceKernelExitGame&#40;&#41;;
			 &#125;
		&#125;
		&#125;
I need to know some way of just adding 1 to the string and pausing it.


Help will be Appriciated.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

You can check which buttons changed by doing

lastpad = pad.Buttons from last time round
thispad = pad.Buttons
newbuttons = thispad & ~lastpad

Jim
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

What Jim said - you need to debounce the keys. Look for a CHANGE in the key state, not the current state.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Or use OSlib - it allows you to see if key was pressed,released,or is it holded.
Post Reply