Help in Button event and Thread

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

Moderators: cheriff, TyRaNiD

Post Reply
zniter81
Posts: 8
Joined: Thu Jun 15, 2006 1:25 am

Help in Button event and Thread

Post by zniter81 »

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
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Re: Help in Button event and Thread

Post by weak »

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.
zniter81
Posts: 8
Joined: Thu Jun 15, 2006 1:25 am

Re: Help in Button event and Thread

Post by zniter81 »

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
zilt
Posts: 45
Joined: Tue Feb 21, 2006 11:59 pm
Location: Ontario, Canada
Contact:

Re: Help in Button event and Thread

Post by zilt »

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
zniter81
Posts: 8
Joined: Thu Jun 15, 2006 1:25 am

Re: Help in Button event and Thread

Post by zniter81 »

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.
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

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.
Post Reply