New Project

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

Moderators: cheriff, TyRaNiD

Locked
superman6143
Posts: 4
Joined: Fri Aug 29, 2008 2:55 pm

New Project

Post by superman6143 »

i need help with this code i made it wont read the button press

Code: Select all

// Sibling Snooper

/*
	Created by Justin Kee on 08/28/08
	Scares your sibling when they are snooping through you psp
*/


#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psppower.h>
PSP_MODULE_INFO&#40;"Sibling Snooper", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;
          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;
          sceKernelSleepThreadCB&#40;&#41;;
          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;
          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;
          return thid;
&#125;

int main&#40;&#41; &#123;
	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;
	SceCtrlData pad;
	printf&#40;"Congrats you just pushed the wrong button. This PSP has crashed and bricked. Bright one!! To save the PSP press X"&#41;; 
	while&#40;1&#41; &#123;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
			int scePowerRequestSuspen &#40;void&#41;;
		&#125;
	&#125;
&#125;

J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

No, you just don't know how to program... your main loop does a declaration of a function, not a function. :P
superman6143
Posts: 4
Joined: Fri Aug 29, 2008 2:55 pm

Post by superman6143 »

oh yeah i forgot to mention i just started programing if i knew exactly how everything goes i dont think i would need help over something as small as this
whistler
Posts: 39
Joined: Tue Mar 04, 2008 7:08 am

Post by whistler »

change

int scePowerRequestSuspend (void); to scePowerRequestSuspend ();
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

There's nothing PSP related in your inability to write code.
Learn C, then learn PSP architecture, then learn how to program PSP.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

and be careful not to get closer to our local noobs' eater :) (someone should recognize himself ;P).


EDIT: too late !!!!
superman6143
Posts: 4
Joined: Fri Aug 29, 2008 2:55 pm

Post by superman6143 »

i did what you said it ran but when i press x is still dont shut off
you think it should be when instead of while
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

Carefully check any compiler errors or warnings.
Got any?
superman6143
Posts: 4
Joined: Fri Aug 29, 2008 2:55 pm

Post by superman6143 »

none
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Does scePowerRequestSuspen() even do anything? I've never seen it used. For a button test, don't use undocumented functions - try something known to work, like sceKernelExitGame(). :)
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

J.F. wrote:Does scePowerRequestSuspen() even do anything? I've never seen it used. For a button test, don't use undocumented functions - try something known to work, like sceKernelExitGame(). :)
It causes a sleep mode. But maybe it is scePowerRequestStandby what he really wanted to do.
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post by jbit »

Learn C, then learn PSP architecture, then learn how to program PSP.
Locked