i recently started developing for the psp and was fooling around with code trying to get the buttons to work. but this code does not seem to work and im not sure what the problem with it is.
int main(void)
{
SceCtrlData pad;
int status = 0;
pspDebugScreenInit()
SetupCallbacks();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
sceCtrlReadBufferPositive(&pad, 1);
pspDebugScreenSetXY(18, 2);
printf("control test program");
pspDebugScreenSetXY(2, 5);
printf("Try Hitting X");
if (pad.Buttons & PSP_CTRL_CROSS){
printf("X");
status ++;
if (status == 1){
printf("You have successfully completed the program. Press Home to exit"); }
status ++;
if (status == 2)
sceKernelSleepThread(); }
return 0; }
it gets to "Try Hitting X" and then it freezes. i'm not sure if it's something with the sleepthread, help a noob psp dev out here =).
Think about what you're trying to do, read your code and ask yourself, "Is this doing at all what I'm meaning to?"
What you have written here:
Reads the keypad once
Prints out "Try Hitting X"
Hits an if statement that will probably never be true because the user didn't realize he was supposed to press the button BEFORE the text shows up
And hits the end of main
You almost certainly want that if statement to be a while loop and you need to read the keypad within the loop.
thanks, i knew i forgot something.. lemme get on that now. also, how would i get the "X" to print more than once, but on a different line? right now i have this:
int main()
{
SceCtrlData pad;
int scrnset = 5;
int count = 1;
pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
while(count >= 1){
sceCtrlReadBufferPositive(&pad, 1);
scrn(18, 2);
printf("control test program");
scrn(2, 5);
printf("Try Hitting X");
if (pad.Buttons & PSP_CTRL_CROSS){
scrn(2,scrnset +2);
printf("X"); } }
return 0; }
note that i have defined scrn as pspdebugscreensetXY. the psp doesnt seem to want to read the (count >= 1) part, and doesnt print out anything. while(1) works, but that is not the condition i want, and only prints X out once. sorry im a little rusty on my C.