forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detection Problems

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Sleepy566



Joined: 28 Dec 2006
Posts: 23

PostPosted: Thu Jan 04, 2007 6:38 am    Post subject: Detection Problems Reply with quote

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:
// 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("Project 9", 0x1000, 1, 1); //Learned from Booster

PSP_MAIN_THREAD_ATTR(0); //Learned from dot_blank


int main() {
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;

int sceWlanDevIsPowerOn(void) {
    if (1) {                                      //I'm trying to say 'if it returns 1'
    printf("WLAN switch is on\n");
}
    else if (0) {                              //I'm trying to say 'if it returns 0'
    printf("WLAN switch is off\n");
}
    return 0;
}


int sceUmdCheckMedium(void) {
    if (0) {                                     //Trying to say 'if it returns 0'
    printf("No UMD inserted\n");
}
    else if (1) {                             //Trying to say 'if it returns 1'
    printf("UMD inserted\n");
}
    return 0;
}   


printf("Project 9 by Sleepy. Press [X] to exit.\n");

while(1) {
          sceCtrlReadBufferPositive(&pad, 1);
          if(pad.Buttons & PSP_CTRL_CROSS) {
                    sceKernelExitGame();
          }
}
return 0;
}


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
Back to top
View user's profile Send private message
Jai_Guru



Joined: 13 Aug 2006
Posts: 12

PostPosted: Thu Jan 04, 2007 7:21 am    Post subject: Reply with quote

The structure of your program is not right.

You shouldn't define functions inside the main function.

Also there's another thing.

Quote:
Code:

int sceUmdCheckMedium(void) {
    if (0) {                                     //Trying to say 'if it returns 0'
       printf("No UMD inserted\n");
    }
    else if (1) {                             //Trying to say 'if it returns 1'
       printf("UMD inserted\n");
    }
    return 0;
}


ż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.
Back to top
View user's profile Send private message
jas0nuk



Joined: 27 Apr 2006
Posts: 137

PostPosted: Thu Jan 04, 2007 7:58 am    Post subject: Re: Detection Problems Reply with quote

Since I'm real bored, here...

Code:
// 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("Project 9", 0x1000, 1, 1); // 0x1000 for kernel mode

PSP_MAIN_THREAD_ATTR(0); // Kernel attribs for thread (not needed in most situations)


int main() {
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;

if (sceWlanDevIsPowerOn()) printf("WLAN switch is on\n");
else printf("WLAN switch is off\n");

if (sceUmdCheckMedium()) printf("UMD inserted\n");
else printf("No UMD inserted\n");

printf("Project 9 by Sleepy. Press [X] to exit.\n");

while(1) {
          sceCtrlReadBufferPositive(&pad, 1);
          if(pad.Buttons & PSP_CTRL_CROSS) {
                    sceKernelExitGame();
          }
}
return 0;
}
Back to top
View user's profile Send private message
Sleepy566



Joined: 28 Dec 2006
Posts: 23

PostPosted: Thu Jan 04, 2007 8:15 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group