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 

Help in Button event and Thread

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



Joined: 15 Jun 2006
Posts: 8

PostPosted: Thu Jun 15, 2006 1:29 am    Post subject: Help in Button event and Thread Reply with quote

hi all,

can any1 show me how to create and handle button action? coz all the tutorial are in a forever loop to check if user press any key.
maybe in a form of interrupt or whatsoever...

also can any1 show me how to create a lightweight thread to run some job, perhaps a helloworld thread....


thanks
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Thu Jun 15, 2006 2:26 am    Post subject: Re: Help in Button event and Thread Reply with quote

zniter81 wrote:

can any1 show me how to create and handle button action? coz all the tutorial are in a forever loop to check if user press any key.
maybe in a form of interrupt or whatsoever...


pspsdk/src/samples/controller/basic

that sample has a while loop ;)


pspsdk/src/samples/kernel/threadstatus

so basically: take a look at sample sources and the documentation.
Back to top
View user's profile Send private message
zniter81



Joined: 15 Jun 2006
Posts: 8

PostPosted: Thu Jun 15, 2006 11:46 am    Post subject: Re: Help in Button event and Thread Reply with quote

weak wrote:
zniter81 wrote:

can any1 show me how to create and handle button action? coz all the tutorial are in a forever loop to check if user press any key.
maybe in a form of interrupt or whatsoever...


pspsdk/src/samples/controller/basic

that sample has a while loop ;)


pspsdk/src/samples/kernel/threadstatus

so basically: take a look at sample sources and the documentation.


the pspsdk/src/sample/controller/basic are using while loop. but it wasting processing power looping and doing nothing. is there a way to implement it as a interrupt or other, so that when press it activate a function?
etc j2SE when button is press it has a actionListener...

thx
Back to top
View user's profile Send private message
zilt



Joined: 21 Feb 2006
Posts: 45
Location: Ontario, Canada

PostPosted: Thu Jun 15, 2006 12:59 pm    Post subject: Re: Help in Button event and Thread Reply with quote

zniter81 wrote:

the pspsdk/src/sample/controller/basic are using while loop. but it wasting processing power looping and doing nothing.


sceCtrlReadBufferPositive() is a blocking call - so no wasted processing. Use sceCtrlPeek* if you want to see if there's any button press/release events to check for without blocking.

Adam
Back to top
View user's profile Send private message Visit poster's website
zniter81



Joined: 15 Jun 2006
Posts: 8

PostPosted: Thu Jun 15, 2006 2:55 pm    Post subject: Re: Help in Button event and Thread Reply with quote

zilt wrote:

sceCtrlReadBufferPositive() is a blocking call - so no wasted processing. Use sceCtrlPeek* if you want to see if there's any button press/release events to check for without blocking.

Adam


so what u mean is that if user didn't press anything it will stop at sceCtrlReadBufferPositive(). proceed untill a key is pressed.
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Thu Jun 15, 2006 6:43 pm    Post subject: Reply with quote

Quote:
sceCtrlReadBufferPositive() is a blocking call - so no wasted processing. Use sceCtrlPeek* if you want to see if there's any button press/release events to check for without blocking.


thats not quite accurate.... sceCtrlReadBufferPositive reads the buttons, and then waits for vblank before it returns (thus it isnt "blocking"). the vblank routine internally allows other threads to run while its waiting (so there is no cpu time wasted while doing so). the sceCtrlPeek* functions only read the buttons and then immediatly return, so you have to take care of the above yourself.

as for an interrupt, i think you could register one, but i think it can only be done in kernel mode - and i dont think its generally a good idea either.
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
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