QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

sdk sample help [Menu]

This is a discussion on sdk sample help [Menu] within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Can someone give me a hint as to why I get this error psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c ...

Reply
 
LinkBack Thread Tools
Old 04-07-2006, 03:22 PM   #1
 
 
Join Date: Jul 2005
Location: Brampton
Posts: 631
Trader Feedback: 0
Default sdk sample help [Menu]

Can someone give me a hint as to why I get this error


psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
main.c: In function 'exit_callback':
main.c:57: error: too few arguments to function 'sceUsbDeactivate'
make: *** [main.o] Error 1

Code:
//Started with the usb shell example MrMr[iCE] made from
//http://forums.ps2dev.org/viewtopic.php?t=2395
#include "menu.h"

#include <pspkernel.h>
#include <pspiofilemgr.h>
#include <pspmodulemgr.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <pspthreadman.h>
#include <pspctrl.h>
#include <pspsdk.h>
#include <psploadexec.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include <pspgu.h>
#include <pspgum.h>

/* XXX SDK BUG: In theory everything should work when main is running in userspace.
   Unfortunately the PSP hangs if we register the exception handler in the _init constructor, so we need to
   call pspDebugInstallErrorHandler() in main().
 */
PSP_MAIN_THREAD_ATTR(/*PSP_THREAD_ATTR_USER |*/ PSP_THREAD_ATTR_VFPU);
PSP_MODULE_INFO("VFPU-test", 0x1000, 1, 1);

#define printf  pspDebugScreenPrintf
u32 state;

/**
 * Function that is called from _init in kernelmode before the
 * main thread is started in usermode.
 */
__attribute__ ((constructor))
void loaderInit()
{
    pspKernelSetKernelPC();
    pspSdkInstallNoDeviceCheckPatch();
    pspDebugInstallKprintfHandler(NULL);
}
//And this is where I get this error
//psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall   -c -o main.o mai
//n.c
//main.c: In function 'exit_callback':
//main.c:57: error: too few arguments to function 'sceUsbDeactivate'
//make: *** [main.o] Error 1
static int exit_callback(int arg1, int arg2, void *common) {
	int retVal;


//cleanup drivers
	if (state & PSP_USB_ACTIVATED) {
		retVal = sceUsbDeactivate();
		if (retVal != 0) printf("Error calling sceUsbDeactivate (0x%08X)\n", retVal);
	}

	retVal = sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0);
	if (retVal != 0) printf("Error stopping USB Mass Storage driver (0x%08X)\n", retVal);

	retVal = sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0);
	if (retVal != 0) printf("Error stopping USB BUS driver (0x%08X)\n", retVal);

	sceKernelExitGame();

   	return 0;
}


static int callback_thread (SceSize args, void *argp) {
   int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);

   sceKernelRegisterExitCallback(cbid);
   sceKernelSleepThreadCB();
   return 0;
}


/* Sets up the callback thread and returns its thread id */
static void SetupCallbacks (void) {
   int thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);

   if (thid >= 0)
      sceKernelStartThread(thid, 0, 0);
}

//helper function to make things easier
int LoadStartModule(char *path)
{
    u32 loadResult;
    u32 startResult;
    int status;

    loadResult = sceKernelLoadModule(path, 0, NULL);
    if (loadResult & 0x80000000)
	return -1;
    else
	startResult =
	    sceKernelStartModule(loadResult, 0, NULL, &status, NULL);

    if (loadResult != startResult)
	return -2;

    return 0;
}

int main (int argc, char *argv[]) {
	int retVal;
	struct SceKernelLoadExecParam exec;

	SetupCallbacks();

	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

	pspDebugScreenInit();

	//start necessary drivers
	LoadStartModule("flash0:/kd/semawm.prx");
	LoadStartModule("flash0:/kd/usbstor.prx");
	LoadStartModule("flash0:/kd/usbstormgr.prx");
	LoadStartModule("flash0:/kd/usbstorms.prx");
	LoadStartModule("flash0:/kd/usbstorboot.prx");

	//setup USB drivers
	retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
	if (retVal != 0) {
		printf("Error starting USB Bus driver (0x%08X)\n", retVal);
		sceKernelSleepThread();
	}
	retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
	if (retVal != 0) {
		printf("Error starting USB Mass Storage driver (0x%08X)\n", retVal);
		sceKernelSleepThread();
	}
	retVal = sceUsbstorBootSetCapacity(0x800000);
	if (retVal != 0) {
		printf("Error setting capacity with USB Mass Storage driver (0x%08X)\n", retVal);
		sceKernelSleepThread();
	}
    retVal = 0;
	retVal = sceUsbActivate(0x1c8);

	printf("%s\n", argv[0]);
	printf("pr4ess START to reload\n");

	while (1) {
		SceCtrlData pad;

		sceCtrlReadBufferPositive(&pad, 1);

		if (pad.Buttons & PSP_CTRL_START) {
			// must pass argv[0] (application path) to loadexec
			exec.size = sizeof(struct SceKernelLoadExecParam);
			exec.args = strlen(argv[0])+1;
			exec.argp = argv[0];
			exec.key = NULL;
			sceKernelLoadExec(argv[0], &exec);
		}
//Tried to just add the menu example from the sdk
//------------------------------------------------------------------------------
MenuContext* initMenu()
{
	MenuContext* context = (MenuContext*)malloc(sizeof(MenuContext));
	memset(context,0,sizeof(MenuContext));

	return context;
}

void destroyMenu(MenuContext* context)
{
	// delete items

	MenuItem* curr = context->root;
	while (curr)
	{
		if (curr->children)
			curr = curr->children;
		else
		{
			MenuItem* last = curr;
			curr = curr->next;

			if (!curr && last->parent)
			{
				MenuItem* lastParent = last->parent;
				curr = lastParent->next;

				free(lastParent);
			}

			free(last);
		}
	}

	free(context);
}

MenuItem* addMenuItem(MenuContext* context, MenuItem* parent, MenuItem* item, int id, int data)
{
	// setup item

	item->id = id;
	item->data = data;

	item->parent = parent;

	// attach to active parent

	if (parent)
	{
		MenuItem* sibling = parent->children;
		MenuItem* last = sibling;
		while (sibling)
		{
			last = sibling;
			sibling = sibling->next;
		}

		if (last)
			last->next = item;
		else
			parent->children = item;
	}
	else
	{
		MenuItem* sibling = context->root;
		MenuItem* last = sibling;
		while (sibling)
		{
			last = sibling;
			sibling = sibling->next;
		}

		if (last)
			last->next = item;
		else
		{
			context->root = item;
			context->active = item;
		}
	}

	switch (item->type)
	{
		case RadioButton:
		{
			if (item->state && item->parent)
				item->parent->selected = item;
			item->state = 0;
		}
		break;

		default:
		break;
	}

	return item;
}

MenuItem* createMenuContainer(const char* name)
{
	MenuItem* item = (MenuItem*)malloc(sizeof(MenuItem));
	memset(item,0,sizeof(MenuItem));

	item->name = name;
	item->type = MenuContainer;

	return item;
}

MenuItem* createRadioButton(const char* name, int state)
{
	MenuItem* item = (MenuItem*)malloc(sizeof(MenuItem));
	memset(item,0,sizeof(MenuItem));

	item->name = name;
	item->type = RadioButton;

	item->state = state;

	return item;
}

MenuItem* createTriggerButton(const char* name)
{
	MenuItem* item = (MenuItem*)malloc(sizeof(MenuItem));
	memset(item,0,sizeof(MenuItem));

	item->name = name;
	item->type = TriggerButton;

	return item;
}

MenuItem* handleMenu(MenuContext* context, SceCtrlData* input)
{
	int wasOpen = context->open;
	MenuItem* result = 0;

	if (context->lastState.Buttons != input->Buttons)
	{
		if (context->open && context->root)
		{
			MenuItem* active = context->active;

			if ((context->lastState.Buttons & PSP_CTRL_UP) && !(input->Buttons & PSP_CTRL_UP))
			{
				MenuItem* sibling = active->parent ? active->parent->children : context->root;
				MenuItem* last = sibling;
				while (sibling && (sibling != active))
				{
					last = sibling;
					sibling = sibling->next;
				}

				context->active = last;				
			}

			if ((context->lastState.Buttons & PSP_CTRL_DOWN) && !(input->Buttons & PSP_CTRL_DOWN))
			{
				if (active->next)
					context->active = active->next;
			}

			if ((context->lastState.Buttons & PSP_CTRL_CROSS) && !(input->Buttons & PSP_CTRL_CROSS))
			{
				switch (active->type)
				{
					case MenuContainer:
					{
						if (active->children)
						{
							active->state = 1;
							context->active = active->children;
						}
					}
					break;

					case RadioButton:
					{
						if (active->parent)
						{
							active->parent->selected = active;
							result = active;
						}
					}
					break;

					case ToggleButton:
					case TriggerButton:
					{
						result = active;
					}
					break;
				}
			}

			if ((context->lastState.Buttons & PSP_CTRL_CIRCLE) && !(input->Buttons & PSP_CTRL_CIRCLE))
			{
				if (active->parent)
				{
					context->active = active->parent;
					context->active->state = 0;
				}
				else
					context->open = 0;
			}
		}
		else
		{
			if ((context->lastState.Buttons & PSP_CTRL_CIRCLE) && !(input->Buttons & PSP_CTRL_CIRCLE))
				context->open = 1;
		}
	}

	// eat all input if menu is open

	context->lastState = *input;
	if (context->open || wasOpen)
		memset(input,0,sizeof(SceCtrlData));

	return result;
}

void renderMenu(MenuContext* context,int startx, int starty)
{
	if (context->open && context->root)
	{
		int depth = 0;
		int row = starty;

		MenuItem* curr = context->root;
		while (curr)
		{
			pspDebugScreenSetXY(startx + depth * 4, row);
			pspDebugScreenSetTextColor(curr == context->active ? 0x00ffff : 0xffffff);

			switch (curr->type)
			{
				case RadioButton:
				{
					int selected = curr->parent && (curr->parent->selected == curr);
					pspDebugScreenPrintf("[%s] %s",selected ? "*" : " ", curr->name);
				}
				break;

				case MenuContainer:
				{
					pspDebugScreenPrintf("%s%s",curr->state ? "-" : "+", curr->name);
					if (curr->selected && !curr->state)
						pspDebugScreenPrintf(": %s",curr->selected->name);
				}
				break;

				default:
				{
					pspDebugScreenPrintf(curr->name);
				}
				break;
			}

			// traverse

			if (curr->state && curr->children && (curr->type == MenuContainer))
			{
				curr = curr->children;
				++depth;
			}
			else
			{
				MenuItem* last = curr;
				curr = curr->next;

				if (!curr && last->parent)
				{
					curr = last->parent->next;
					--depth;
				}
			}

			++row;
		}

		pspDebugScreenSetXY(0,33);
		pspDebugScreenSetTextColor(0xffffff);
		pspDebugScreenPrintf("O = %s, Arrows = Move Up/Down, X = Select", context->active->parent ? "Back" : "Close Menu");
	}
	else
	{

		pspDebugScreenSetXY(0,33);
		pspDebugScreenPrintf("O = Open Debug Menu");
	}
}
//------------------------------------------------------------------------------
		
		sceDisplayWaitVblankStart();
	}
	return 0;
}
__________________
[CENTER]You can hyperlink quotes and the whole box will be a link:
[URL=http://forums.qj.net/showthread.php?t=35215][COLOR=DarkRed][QUOTE=ANTONIO_424][CENTER][COLOR=DarkRed]Go for it, and remember, video tape every moment...........I gotta see this :D[/COLOR][/CENTER][/QUOTE][/COLOR][/URL][SIZE=1][B][U][URL=http://forums.qj.net/showthread.php?t=65979]A Ultimate QJ FAQ[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/search.php?do=finduser&u=13500]Topics I'm in[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/f-psp-development-forum-11/t-pps-game-66613.html]My qj game topic[/URL][/U][/B]-[B][U][URL=http://www.psp-programming.com/dev-forum/viewtopic.php?t=962]My psp-prog topic[/URL][/U][/B]-[B][U][URL=http://files.pspupdates.qj.net/cgi-bin/cfiles.cgi]Old QJ Download site[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/showthread.php?t=46926]Only ISO topic[/URL][/U][/B][/SIZE]
"You stayed up all night trying to make your psp crash? LOLOL!!" - my brother
My PSN name is "icantthinkofone".[/CENTER]
lord pip is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-07-2006, 03:30 PM   #2

total-Z
 
youresam's Avatar
 
Join Date: Jul 2005
Location: texas
Posts: 2,803
Trader Feedback: 0
Default

Yeah, the SDK changed the USB functions a while back. Now you must use the same argument that the activate usb command uses.

(I had this problem while trying to compile luaplayer. Took me about half an hour to figure out the answer)
__________________
牧来栠摩琠敨映汩獥
PSN: youresam
From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
youresam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-07-2006, 03:30 PM   #3
 
Join Date: Sep 2005
Location: meh
Posts: 2,799
Trader Feedback: 0
Default

dont post the whole code..
its some problem with the usb mode code...
can you post just that part ?
cyanide is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-07-2006, 03:32 PM   #4
11th Squad Captain
 
c5cha7's Avatar
 
Join Date: Jun 2005
Location: You are here -----> 名前: アダム | 飲むコー&#1
Posts: 2,562
Trader Feedback: 0
Default

Quote:
Originally Posted by youresam
Yeah, the SDK changed the USB functions a while back. Now you must use the same argument that the activate usb command uses.

(I had this problem while trying to compile luaplayer. Took me about half an hour to figure out the answer)
Ahh...
I had this problem when i updated cygwin for
lua player lol...
I thought there was something wrong.

thanks.
__________________
FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
c5cha7 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-07-2006, 03:41 PM   #5
 
 
Join Date: Jul 2005
Location: Brampton
Posts: 631
Trader Feedback: 0
Default

if anyone doesn't get it

its - sceUsbDeactivate(0x1c8)
not - sceUsbDeactivate() <----is what you see in my code
__________________
[CENTER]You can hyperlink quotes and the whole box will be a link:
[URL=http://forums.qj.net/showthread.php?t=35215][COLOR=DarkRed][QUOTE=ANTONIO_424][CENTER][COLOR=DarkRed]Go for it, and remember, video tape every moment...........I gotta see this :D[/COLOR][/CENTER][/QUOTE][/COLOR][/URL][SIZE=1][B][U][URL=http://forums.qj.net/showthread.php?t=65979]A Ultimate QJ FAQ[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/search.php?do=finduser&u=13500]Topics I'm in[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/f-psp-development-forum-11/t-pps-game-66613.html]My qj game topic[/URL][/U][/B]-[B][U][URL=http://www.psp-programming.com/dev-forum/viewtopic.php?t=962]My psp-prog topic[/URL][/U][/B]-[B][U][URL=http://files.pspupdates.qj.net/cgi-bin/cfiles.cgi]Old QJ Download site[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/showthread.php?t=46926]Only ISO topic[/URL][/U][/B][/SIZE]
"You stayed up all night trying to make your psp crash? LOLOL!!" - my brother
My PSN name is "icantthinkofone".[/CENTER]
lord pip is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
menu , sample , sdk

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 09:07 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us