Ah oui, j'avais pas compris le problème. C'est parce qu'il faut mettre un timer sinon les touches se répètent trop vite. Pourquoi s'emmerder en rajoutant une valeur statut ?
Voilà le code:
// Code corrigé par roomain// Puis Maniac m'a donné une idée// Alors j'ai re-corrigé le code :d#include <pspsdk.h>#include <pspkernel.h>#include <pspctrl.h>#include <string.h>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.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 texteprintf("\n Appuyez sur[X] pour afficher Hello World ou sur [O] pour finnir le programme");while(1) // Une boucle infinie{SceCtrlData pad;sceCtrlReadBufferPositive(&pad, 1);if (pad.Buttons & PSP_CTRL_CROSS){printf("\n\n hello world");sceKernelDelayThread(500000); // le timer pour éviter la répétition}if(pad.Buttons & PSP_CTRL_CIRCLE){sceKernelExitGame();}}}
Théoriquement, ca devrait fonctionner mais il faut lacher le bouton X 0.5 sec max après avoir appuyé sinon le texte s'affichera plusieurs fois !