forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help on my menu

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
AntiBNI



Joined: 24 Sep 2007
Posts: 15
Location: Planet Earth

PostPosted: Sun Sep 30, 2007 7:38 am    Post subject: Need help on my menu Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Sep 30, 2007 11:02 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Sep 30, 2007 11:17 am    Post subject: Reply with quote

What Jim said - you need to debounce the keys. Look for a CHANGE in the key state, not the current state.
Back to top
View user's profile Send private message AIM Address
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Sun Sep 30, 2007 7:30 pm    Post subject: Reply with quote

Or use OSlib - it allows you to see if key was pressed,released,or is it holded.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group