Detection Problems

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

Moderators: cheriff, TyRaNiD

Post Reply
Sleepy566
Posts: 23
Joined: Thu Dec 28, 2006 2:30 am

Detection Problems

Post by Sleepy566 »

Once again with my n00b questions, can somebody please help me with my source code? I am trying to make a program that (so far) will detect certain things. Here's what I have so far (and I can tell a bunch of it is wrong):

Code: Select all

// Project 9 - Another of Sleepy's n00b projects...

/*


              This program was begun by Sleepy on 12-22-06
                  
          
*/

#include <pspkernel.h>
#include <pspdebug.h> 
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pspmscm.h>
#include "common/callbacks/standard.h"

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO&#40;"Project 9", 0x1000, 1, 1&#41;; //Learned from Booster

PSP_MAIN_THREAD_ATTR&#40;0&#41;; //Learned from dot_blank


int main&#40;&#41; &#123;
pspDebugScreenInit&#40;&#41;;
SetupCallbacks&#40;&#41;;
SceCtrlData pad;

int sceWlanDevIsPowerOn&#40;void&#41; &#123;
    if &#40;1&#41; &#123;                                      //I'm trying to say 'if it returns 1'
    printf&#40;"WLAN switch is on\n"&#41;;
&#125;
    else if &#40;0&#41; &#123;                              //I'm trying to say 'if it returns 0'
    printf&#40;"WLAN switch is off\n"&#41;;
&#125;
    return 0;
&#125;


int sceUmdCheckMedium&#40;void&#41; &#123;
    if &#40;0&#41; &#123;                                     //Trying to say 'if it returns 0'
    printf&#40;"No UMD inserted\n"&#41;;
&#125;
    else if &#40;1&#41; &#123;                             //Trying to say 'if it returns 1'
    printf&#40;"UMD inserted\n"&#41;;
&#125;
    return 0;
&#125;	


printf&#40;"Project 9 by Sleepy. Press &#91;X&#93; to exit.\n"&#41;;

while&#40;1&#41; &#123;
          sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
          if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
                    sceKernelExitGame&#40;&#41;;
          &#125;
&#125;
return 0;
&#125;
Yeah... so I know it looks bad but I need to start somewhere, right?

And I also want to check for (possibly write to) the memory stick, but when I checked out mscm.h it only told me how to respond to somebody inserting or ejecting it.

Thanks a ton to all who help!

-Sleepy
n00b programmer
Jai_Guru
Posts: 12
Joined: Sun Aug 13, 2006 8:01 am

Post by Jai_Guru »

The structure of your program is not right.

You shouldn't define functions inside the main function.

Also there's another thing.

Code: Select all

int sceUmdCheckMedium&#40;void&#41; &#123;
    if &#40;0&#41; &#123;                                     //Trying to say 'if it returns 0'
       printf&#40;"No UMD inserted\n"&#41;;
    &#125;
    else if &#40;1&#41; &#123;                             //Trying to say 'if it returns 1'
       printf&#40;"UMD inserted\n"&#41;;
    &#125;
    return 0;
&#125; 
¿If what returns 0 or 1?

Probably the forum at http://www.psp-programming.com is a better place for this question although they aren't working now.
jas0nuk
Posts: 137
Joined: Thu Apr 27, 2006 8:00 am

Re: Detection Problems

Post by jas0nuk »

Since I'm real bored, here...

Code: Select all

// Project 9 - Another of Sleepy's n00b projects...

/*


              This program was begun by Sleepy on 12-22-06
                  
          
*/

#include <pspkernel.h>
#include <pspdebug.h> 
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pspmscm.h>
#include "common/callbacks/standard.h"

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO&#40;"Project 9", 0x1000, 1, 1&#41;; // 0x1000 for kernel mode

PSP_MAIN_THREAD_ATTR&#40;0&#41;; // Kernel attribs for thread &#40;not needed in most situations&#41;


int main&#40;&#41; &#123;
pspDebugScreenInit&#40;&#41;;
SetupCallbacks&#40;&#41;;
SceCtrlData pad;

if &#40;sceWlanDevIsPowerOn&#40;&#41;&#41; printf&#40;"WLAN switch is on\n"&#41;;
else printf&#40;"WLAN switch is off\n"&#41;;

if &#40;sceUmdCheckMedium&#40;&#41;&#41; printf&#40;"UMD inserted\n"&#41;;
else printf&#40;"No UMD inserted\n"&#41;;

printf&#40;"Project 9 by Sleepy. Press &#91;X&#93; to exit.\n"&#41;;

while&#40;1&#41; &#123;
          sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
          if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
                    sceKernelExitGame&#40;&#41;;
          &#125;
&#125;
return 0;
&#125;
Sleepy566
Posts: 23
Joined: Thu Dec 28, 2006 2:30 am

Post by Sleepy566 »

ooohhhhh... that's my bad.

I thought it would need to be in a loop or something, not just by itself.

then I thought it might need to be it's own int function.

well, thanks a million jas0nuk!

I'll be sure to remember this later. I can't believe I made such a stupid mistake.....
ah well... it happens to all of us. thanks again!

-Sleepy
Post Reply