Intercepting home button?
Intercepting home button?
Hey there,
I just got into PSP development, and I'd like to thank for all people working on the PSPSDK and especially TyRaNiD for PSPLink, it's working like a bliss even on Mac OSX and it makes development very easy. Keep on going, guys!
Now to my question:
In my application I'd like to intercept the home button, so the user can be asked if he wants to save changes to the current document, but I'm not sure what's the best way to do it. I searched the forums for a while and couldn't find any solution so I'm asking now, sorry if I've been missing something.
Or is this trivial?
Regards,
Pailes
I just got into PSP development, and I'd like to thank for all people working on the PSPSDK and especially TyRaNiD for PSPLink, it's working like a bliss even on Mac OSX and it makes development very easy. Keep on going, guys!
Now to my question:
In my application I'd like to intercept the home button, so the user can be asked if he wants to save changes to the current document, but I'm not sure what's the best way to do it. I searched the forums for a while and couldn't find any solution so I'm asking now, sorry if I've been missing something.
Or is this trivial?
Regards,
Pailes
This is the code I use in my projects when I want a "Press HOME to exit" prompt, I don't know what could be wrong in your code:
Code: Select all
SceCtrlData pad_data;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(1);
printf("Press HOME to exit\n");
while(1) {
sceCtrlReadBufferPositive(&pad_data, 1);
if (pad_data.Buttons & PSP_CTRL_HOME)
sceKernelExitGame();
}
main.c:
makefile:
Hope this helps.[/code]
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
PSP_MODULE_INFO("test", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
#define printf pspDebugScreenPrintf
int main(void) {
// init stuff
pspDebugScreenInit();
pspDebugScreenClear();
// pad stuff
SceCtrlData pad_data;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(1);
printf("Press X to start\n\n");
while(1) {
sceCtrlReadBufferPositive(&pad_data, 1);
if (pad_data.Buttons & PSP_CTRL_CROSS) {
break;
}
}
printf("blah\n");
printf("\nPress HOME to exit\n");
while(1) {
sceCtrlReadBufferPositive(&pad_data, 1);
if (pad_data.Buttons & PSP_CTRL_HOME)
sceKernelExitGame();
}
return 0;
}
Code: Select all
TARGET = out
OBJS = main.c
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = test app
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Thanks for the code, it solved my problem, although I don't understand the reason yet why...
In my code I had the following macros:
which seemed to cause the problem, because when I changed it to
it worked ok. Maybe somebody can enlighten me?
In my code I had the following macros:
Code: Select all
PSP_MODULE_INFO("test", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
Code: Select all
PSP_MODULE_INFO("test", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);