Bonjour à tous je débute en programmation pour PSP, j'ai déja quelques connaissance an C mais j'avou que la je suis un peu déconcerté par ce problème.
En fait je voudrai faire une boucle infini qui permettrai d'afficher "Hello world" lorsque l'ont appuy sur le bouton [X] ou alors quitte le programme si l'on appui sur le bouton [O] Mais mon problème est que le " Hello world" s'affiche 8 fois !!! et je ne trouve pas pourquoi. Merci d'avance pour vos réponses !
#include #include #include #include PSP_MODULE_INFO(" test", 0, 1, 1);#define printf pspDebugScreenPrintf/* Exit callback */int exit_callback(int arg1, int arg2, void *common) {sceKernelExitGame();return 0;}/* Callback thread */int CallbackThread(SceSize args, void *argp) {int cbid;cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);sceKernelRegisterExitCallback(cbid);sceKernelSleepThreadCB();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, 0, 0);if(thid >= 0) {sceKernelStartThread(thid, 0, 0);}return thid;} // Le main qui se lance au démarrage du programme.// Le main qui se lance au démarrage du programme.int main(void){SetupCallbacks();pspDebugScreenInit();// On initialise l'écranpspDebugScreenSetTextColor(0xFF0000); // La couleur du texte: il faut un logiciel nommé Fast color codes pour obtenir ce code couleur c++pspDebugScreenClear(); // On efface l'écran// On écrit du texte :Pprintf("\n Appuyez sur[X] pour afficher Hello World ou sur [O] pour finnir le programme");
while(1>0) // Une boucle infinie
{
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS)
{
printf("\n\n hello world");
}
//Sinon c'est bon, on le signale.
else if(pad.Buttons & PSP_CTRL_CIRCLE)
{
sceKernelExitGame();
}
}
}