Can't use HOME button to quit when using sceDisplayDisable

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

Moderators: cheriff, TyRaNiD

Post Reply
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Can't use HOME button to quit when using sceDisplayDisable

Post by picobsd »

hi,all


I have a strange question,
if I want call sceDisplay**able function, i must set my app run on kernel mode , 0x1000, PSP_MAIN_THREAD_ATTR(0), these are must, if I don't do these, then app will crush when it begin to run. (I don't know why, I copy from Mr.sakya's sample code)

but if I did this,when I push HOME key, and then push X key, psp didn't not response me, but if I push O key, it can response me and resume the excution of current apps. why?
Last edited by picobsd on Thu Jul 26, 2007 1:53 pm, edited 1 time in total.
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Post by picobsd »

by the way, my firmware version is 3.03oeb
and I have noticed that Mr. sakya 's sample code ("sceDisplaySetBrightness and sceDisplayDisable sample") also have this problem, in his sample, he use Triangle button to quit.
Last edited by picobsd on Thu Jul 26, 2007 1:06 pm, edited 1 time in total.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

I think I have encountered this also, but didn't really know the cause,
you might have narrowed it down because I also use those functions.

Have you tried taking control of the HOME button and exiting the app
in the program if the HOME button is pressed?
Exit callback isn't the only way to quit a program.

You might want to try crashing the PSP unit by causing an exception, or two.

Code: Select all

			_sw(0, 0);		// cause exception to crash PSP unit (1)
			asm("break\n");		// cause exception to crash PSP unit (2)

// by moonlight
The only problem is these will cause the PSP to standby rather than quit to XMB.
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Post by picobsd »

Art wrote:I think I have encountered this also, but didn't really know the cause,
you might have narrowed it down because I also use those functions.

Have you tried taking control of the HOME button and exiting the app
in the program if the HOME button is pressed?
Exit callback isn't the only way to quit a program.

You might want to try crashing the PSP unit by causing an exception, or two.

Code: Select all

			_sw(0, 0);		// cause exception to crash PSP unit (1)
			asm("break\n");		// cause exception to crash PSP unit (2)

// by moonlight
The only problem is these will cause the PSP to standby rather than quit to XMB.


oh, thank you for your time and consideration. I think I can hanle HOME key myself in program, but I am very curious with this problem, Why X button doesn't work in that circumstance. I wondered.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Well I can't be specific sorry, but you're no the only one.

MapThis! GPS application has the same issue, not sure if for the same reason,
one of my own released programs Time Baby.

I don't think it's to do with the X button being ignored, but more that the exit callback doesn't work, or scekernalexitgame doesn't work.
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Post by picobsd »

Art wrote:Well I can't be specific sorry, but you're no the only one.

MapThis! GPS application has the same issue, not sure if for the same reason,
one of my own released programs Time Baby.

I don't think it's to do with the X button being ignored, but more that the exit callback doesn't work, or scekernalexitgame doesn't work.
do you mean that sceKernealExitGame doesn't work in Callback routine when mode is 0x1000, may be you are right, that is not key processing's problem.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Not for every kernal mode program, that's why I said I think you might have narrowed it down to the brightness/LCD routines.

I will test that, as I'd trade off use of those functions for the Home button to
work if that's the problem.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Re: Can't use HOME button to quit when using sceDisplayDisab

Post by sakya »

Hi! :)

To solve your problem declare a static variable

Code: Select all

static int runningFlag = 1;
Then change the exit_callback and SetupCallbacks like this:

Code: Select all

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
		  runningFlag = 0;
          sceKernelExitGame();
          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}
Change the while(1) loops to:

Code: Select all

while(runningFlag)
P.S: I also updated the post with the sample code. ;)

Ciaooo
Sakya
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Re: Can't use HOME button to quit when using sceDisplayDisab

Post by picobsd »

sakya wrote:Hi! :)

To solve your problem declare a static variable

Code: Select all

static int runningFlag = 1;
Then change the exit_callback and SetupCallbacks like this:

Code: Select all

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
		  runningFlag = 0;
          sceKernelExitGame();
          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}
Change the while(1) loops to:

Code: Select all

while(runningFlag)
P.S: I also updated the post with the sample code. ;)

Ciaooo
Sakya
hi, long time no see, thank you for your code, I'll try it tonignt, hope it works, I merely gave up on this, thank you.
Post Reply