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

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
0okm0000
Posts: 116
Joined: Fri Jan 13, 2006 9:51 am
Contact:

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

Post by 0okm0000 »

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: Select all

/*
 * 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&#40;"USBSample", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;

/* 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&#40;void&#41;
&#123;
	u32 oldButtons = 0;
	u32 retVal;
	state = 0;

	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenClear&#40;&#41;;

	//setup Pad
	SceCtrlData pad;
	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;0&#41;;

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

	retVal = 0;

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

		if &#40;oldButtons != pad.Buttons&#41;
		&#123;
			if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;
			&#123;
				if &#40;state & PSP_USB_ACTIVATED&#41;
					retVal = sceUsbDeactivate&#40;0x1c8&#41;;
				else
					retVal = sceUsbActivate&#40;0x1c8&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
			&#123;
				//cleanup drivers
				if &#40;state & PSP_USB_ACTIVATED&#41;
				&#123;
					retVal = sceUsbDeactivate&#40;0&#41;;
					if &#40;retVal != 0&#41;
						sceDisplayWaitVblankStart&#40;&#41;;
						printf&#40;"Error calling sceUsbDeactivate &#40;0x%08X&#41;\n", retVal&#41;;
				&#125;
				sceKernelExitGame&#40;&#41;;
			&#125;
		&#125;
		oldButtons = pad.Buttons;
		sceDisplayWaitVblankStart&#40;&#41;;
	&#125;

	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;
Makefile

Code: Select all

TARGET = USBSample
OBJS = main.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LIBS = -lpspusb -lpspusbstor
LDFLAGS =

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

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
PSP hardware hack
http://0okm.blogspot.com/
Post Reply