| View previous topic :: View next topic |
| Author |
Message |
zniter81
Joined: 15 Jun 2006 Posts: 8
|
Posted: Thu Jun 15, 2006 1:29 am Post subject: Help in Button event and Thread |
|
|
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 |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Thu Jun 15, 2006 2:26 am Post subject: Re: Help in Button event and Thread |
|
|
| 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 |
|
 |
zniter81
Joined: 15 Jun 2006 Posts: 8
|
Posted: Thu Jun 15, 2006 11:46 am Post subject: Re: Help in Button event and Thread |
|
|
| 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 |
|
 |
zilt
Joined: 21 Feb 2006 Posts: 45 Location: Ontario, Canada
|
Posted: Thu Jun 15, 2006 12:59 pm Post subject: Re: Help in Button event and Thread |
|
|
| 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 |
|
 |
zniter81
Joined: 15 Jun 2006 Posts: 8
|
Posted: Thu Jun 15, 2006 2:55 pm Post subject: Re: Help in Button event and Thread |
|
|
| 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 |
|
 |
groepaz

Joined: 01 Sep 2005 Posts: 305
|
Posted: Thu Jun 15, 2006 6:43 pm Post subject: |
|
|
| 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 |
|
 |
|