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 

USB mode for eLoader(GTA) & App on FW2.50/2.60

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



Joined: 13 Jan 2006
Posts: 116

PostPosted: Tue Aug 01, 2006 8:39 pm    Post subject: USB mode for eLoader(GTA) & App on FW2.50/2.60 Reply with quote

eLoader(GTA) w/ USB for FW2.50/2.60 v1.01 by 0okm
Thanks hitchhikr, John_K & PSPPet

after eLoader(GTA) start
run "USB for eLoader GTA"
than you can use Triangle to turn on USB mode :)

Download-Link: USB_for_eLoader_GTA.zip

with "USB for eLoader GTA"
you can also add USB mode to your app :)

main.c
Code:

/*
 * USBSample for USB4eLoaderGTA v1.01 by 0okm
 * Thanks hitchhikr, John_K & PSPPet
 */
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <string.h>

#include <pspusb.h>
#include <pspusbstor.h>

PSP_MODULE_INFO("USBSample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

/* Define printf, just to make typing easier */
#define printf  pspDebugScreenPrintf

//make this global so we can check it in the exit_callback
u32 state;

int main(void)
{
   u32 oldButtons = 0;
   u32 retVal;
   state = 0;

   pspDebugScreenInit();
   pspDebugScreenClear();

   //setup Pad
   SceCtrlData pad;
   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(0);

   //print header now in case we have any errors
   printf("USBSample for USB4eLoaderGTA v1.01 by 0okm\n");
   printf("Thanks hitchhikr, John_K & PSPPet\n\n");

   retVal = 0;

   //if everything worked we now enter our main loop
   for (;;)
   {
      sceCtrlReadBufferPositive(&pad, 1);
      state = sceUsbGetState();
      pspDebugScreenSetXY(0, 3);
      printf("%-14s: %s\n", "USB Driver", state & PSP_USB_ACTIVATED ? "activated    " : "deactivated");
      printf("%-14s: %s\n", "USB Cable", state & PSP_USB_CABLE_CONNECTED ? "connected   " : "disconnected");
      printf("%-14s: %s\n", "USB Connection", state & PSP_USB_CONNECTION_ESTABLISHED ? "established" : "not present");
      printf("\nPress X to establish or destroy the USB connection\n");
      printf("\nPress O to Exit\n\n");

      if (oldButtons != pad.Buttons)
      {
         if (pad.Buttons & PSP_CTRL_CROSS)
         {
            if (state & PSP_USB_ACTIVATED)
               retVal = sceUsbDeactivate(0x1c8);
            else
               retVal = sceUsbActivate(0x1c8);
         }
         if (pad.Buttons & PSP_CTRL_CIRCLE)
         {
            //cleanup drivers
            if (state & PSP_USB_ACTIVATED)
            {
               retVal = sceUsbDeactivate(0);
               if (retVal != 0)
                  sceDisplayWaitVblankStart();
                  printf("Error calling sceUsbDeactivate (0x%08X)\n", retVal);
            }
            sceKernelExitGame();
         }
      }
      oldButtons = pad.Buttons;
      sceDisplayWaitVblankStart();
   }

   sceKernelExitGame();
   return 0;
}


Makefile
Code:

TARGET = USBSample
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LIBS = -lpspusb -lpspusbstor
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = USBSample for USB4eLoaderGTA
PSP_EBOOT_ICON = ICON0.PNG

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

_________________
PSP hardware hack
http://0okm.blogspot.com/
Back to top
View user's profile Send private message Visit poster's website
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