Cave StoryRandom Homebrew: Cave Story
Probably the most famous platform freeware game, cave story is the result of 5 years of work by an i [...]
Friends: Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita

sleep fnction or some advice ???

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

sleep fnction or some advice ???

Postby kmanev07 » Sat May 26, 2012 3:25 pm

hi guys I am detecting key press in my menu... but it is super fast and i need something like "Sleep()" function which take parameter Miliseconds... Plese teel me or give me advice how to slow down the checking so it will be normal...

Aslo what is the function for closing the app ? And can i get the result if PS button is pressed?
kmanev07
 
Posts: 47
Joined: Fri Jun 03, 2011 9:39 am

Re: sleep fnction or some advice ???

Postby FrEdDy » Sat May 26, 2012 3:57 pm

sceKernelDelayThread(int milliseconds)
sceKernelExitGame to exit your application. I don't understand your other question though.
https://github.com/freddy-156
<@n00b81> FREDDY CUTTIES
User avatar
FrEdDy
HBL Collaborator
 
Posts: 349
Joined: Mon Sep 27, 2010 7:08 pm

Re: sleep fnction or some advice ???

Postby wth » Sat May 26, 2012 4:15 pm

Me neither, but apparently pressing the PS button triggers a HOME button press
wth
HBL Developer
 
Posts: 587
Joined: Wed Aug 31, 2011 4:44 pm

Re: sleep fnction or some advice ???

Postby kmanev07 » Sat May 26, 2012 7:24 pm

yes how to get the result of the Home button (whit playstation logo on it) Exit ? yes or no
kmanev07
 
Posts: 47
Joined: Fri Jun 03, 2011 9:39 am

Re: sleep fnction or some advice ???

Postby kmanev07 » Sat May 26, 2012 7:41 pm

FrEdDy wrote:sceKernelDelayThread(int milliseconds)
sceKernelExitGame to exit your application. I don't understand your other question though.

thanks works perfect :D
kmanev07
 
Posts: 47
Joined: Fri Jun 03, 2011 9:39 am

Re: sleep fnction or some advice ???

Postby snailface » Sun May 27, 2012 4:09 am

kmanev07 wrote:
FrEdDy wrote:sceKernelDelayThread(int milliseconds)
sceKernelExitGame to exit your application. I don't understand your other question though.

thanks works perfect :D

Only problem with that delay function is that if you do it in a rendering loop, you will stop the program every time you press the button.

It would be a good idea to get in the habit of doing something like this:
Code: Select all
int held=0; //declared outside of rendering loop


if( (pad.Buttons & PSP_CTRL_CROSS) && !held){
           
            //do whatever just once

            held=1; 
}
       else if
       ( !(pad.Buttons & PSP_CTRL_CROSS) )held=0; 

That will only allow just one button press to get through each time it is held down for whatever amount of time. :)
Image
snailface
 
Posts: 100
Joined: Tue May 24, 2011 8:02 pm

Re: sleep fnction or some advice ???

Postby FrEdDy » Sun May 27, 2012 8:09 am

snailface wrote:
kmanev07 wrote:
FrEdDy wrote:sceKernelDelayThread(int milliseconds)
sceKernelExitGame to exit your application. I don't understand your other question though.

thanks works perfect :D

Only problem with that delay function is that if you do it in a rendering loop, you will stop the program every time you press the button.

It would be a good idea to get in the habit of doing something like this:
Code: Select all
int held=0; //declared outside of rendering loop


if( (pad.Buttons & PSP_CTRL_CROSS) && !held){
           
            //do whatever just once

            held=1; 
}
       else if
       ( !(pad.Buttons & PSP_CTRL_CROSS) )held=0; 

That will only allow just one button press to get through each time it is held down for whatever amount of time. :)

Or you could render in a different thread.
https://github.com/freddy-156
<@n00b81> FREDDY CUTTIES
User avatar
FrEdDy
HBL Collaborator
 
Posts: 349
Joined: Mon Sep 27, 2010 7:08 pm

Re: sleep fnction or some advice ???

Postby kmanev07 » Sun May 27, 2012 12:28 pm

you mean to pause only the tread with hotkeys :) ?
kmanev07
 
Posts: 47
Joined: Fri Jun 03, 2011 9:39 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests