Advertising (This ad goes away for registered users. You can Login or Register)

[n00bish] HBL shortcuts mod

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
TiPi
Retired Mod
Posts: 740
Joined: Tue Sep 28, 2010 5:32 am
Contact:

[n00bish] HBL shortcuts mod

Post by TiPi » Fri Nov 12, 2010 6:10 pm

The other day, I decided to *try* to learn to code in C.
I already made some simple hello worlds, but I decided to take a look in the HBL source code, just to see if I can understand how it works.
Then I tried to modify it a bit, cause I always thought it would be nice to load your homebrews quicker, and to switch between menus.

I made a very simple script to create shortcuts before loading the standard wMenu. For example:
-If you press [O] while loading HBL, it will bring you to Nymphaea's SimpleMenu.
-If you press [X] while loading HBL, it brings you to Mr.X's Xenu.
-If you do nothing, it will bring you to the standard wMenu.
Done that, I decided to just copy-paste the code to use for other homebrew. For example:
-If you press [LEFT TRIGGER] while loading HBL, gbaKAI will pop up immediately.
-If you press [RIGHT TRIGGER] while loading HBL, snes9xTYL will launch directly.
And so on..

You can choose which homebrew will be loaded by replacing in the corresponding folders (up,down,left,right,cross,circle...); but I was thinking to add an option to set the path of the shortcuts in the HBL_CONFIG text file as well. But I guess that's way too complicated for me, I'm learning the basics.
So, yea. It works, but it isn't that good or complex yet. Anyways, I thought to share it with you guys if someone thinks it's useful.


In eloader.c :
Just replace

Code: Select all

			run_eboot(g->menupath, 1);

With

Code: Select all

	// Shortcuts
	while (1)
	{
		sceCtrlReadBufferPositive(&pad, 1);
		if(pad.Buttons & PSP_CTRL_CROSS)
		{
			run_eboot("ms0:/hbl/shortcuts/cross/EBOOT.PBP", 1);
			break;
        }					
		if(pad.Buttons & PSP_CTRL_CIRCLE)
		{
			run_eboot("ms0:/hbl/shortcuts/circle/EBOOT.PBP", 1);
			break;
        }
		if(pad.Buttons & PSP_CTRL_TRIANGLE)
		{
			run_eboot("ms0:/hbl/shortcuts/triangle/EBOOT.PBP", 1);
			break;
        }		
		if(pad.Buttons & PSP_CTRL_SQUARE)
		{
			run_eboot("ms0:/hbl/shortcuts/square/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_LTRIGGER)
		{
			run_eboot("ms0:/hbl/shortcuts/left-trigger/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_RTRIGGER)
		{
			run_eboot("ms0:/hbl/shortcuts/right-trigger/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_START)
		{
			run_eboot("ms0:/hbl/shortcuts/start/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_SELECT)
		{
			run_eboot("ms0:/hbl/shortcuts/select/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_UP)
		{
			run_eboot("ms0:/hbl/shortcuts/up/EBOOT.PBP", 1);
			break;
        }		
		if(pad.Buttons & PSP_CTRL_RIGHT)
		{
			run_eboot("ms0:/hbl/shortcuts/right/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_DOWN)
		{
			run_eboot("ms0:/hbl/shortcuts/down/EBOOT.PBP", 1);
			break;
        }			
		if(pad.Buttons & PSP_CTRL_LEFT)
		{
			run_eboot("ms0:/hbl/shortcuts/left/EBOOT.PBP", 1);
			break;
        }			
				if(pad.Buttons & PSP_CTRL_HOME)
		{
			run_eboot(g->menupath, 1);
			break;
        }		
		else
		{
			run_eboot("ms0:/hbl/shortcuts/default/EBOOT.PBP", 1);
			break;
		}
	}
}
I know it's not that impressive, but I'm pretty content with it, since it's my first C code, and it works.
The original idea was that I'll probably set the HEN to autoboot when it's released. But I can't miss HBL, so I'll be able to go to HBL if I press for example the left trigger while booting the patapon exploit. Just for the nostalgia. :)

Anyways, comments, tips, links to handy tutorials are always welcome.
Advertising
Problems or questions? Feel free to contact me.
-My Blog-

jaja2u
Posts: 262
Joined: Mon Sep 27, 2010 7:52 pm

Re: [n00bish] HBL shortcuts mod

Post by jaja2u » Fri Nov 12, 2010 9:15 pm

I actually think that's a great idea. Good work :)
Advertising
Thank you Total_Noob :mrgreen:

Mr. X
Retired Mod
Posts: 528
Joined: Tue Sep 28, 2010 8:01 am
Location: England

Re: [n00bish] HBL shortcuts mod

Post by Mr. X » Fri Nov 12, 2010 10:13 pm

Nice idea, although I have no current use for it. :(

Also:

Code: Select all

PSP_CTRL_HOME
can the home button be detected in user mode?
All HBL Revisions: Binaries + Source | Topic
TN HEN Releases: Download

TiPi
Retired Mod
Posts: 740
Joined: Tue Sep 28, 2010 5:32 am
Contact:

Re: [n00bish] HBL shortcuts mod

Post by TiPi » Fri Nov 12, 2010 10:28 pm

Mr. X wrote:Nice idea, although I have no current use for it. :(

Also:

Code: Select all

PSP_CTRL_HOME
can the home button be detected in user mode?
You're right, it can't be detected. But I had to put that global variable somewhere, so I didn't have to do too much edits to the code. Otherwise I should disable the
g->menupath somewhere else in the code, but meh, too lazy. :lol:
Glad you like it, jaja2u!
Problems or questions? Feel free to contact me.
-My Blog-

iSWORD
Posts: 170
Joined: Mon Sep 27, 2010 9:50 pm

Re: [n00bish] HBL shortcuts mod

Post by iSWORD » Sat Nov 13, 2010 12:53 am

Very simple, BUT VERY helpful.. And no, it's not noobish at all..
Nice idea TiPi..

JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Re: [n00bish] HBL shortcuts mod

Post by JJS » Sat Nov 13, 2010 8:28 am

Nice idea!

I think it would be better to always set the g->menupath variable to the eboot path though because there should be a problem with running different menus now. In start_module(), the EBOOTs path is checked against g->menupath. Only if they are identical, the menu API is put into argv[1]. This means a menu run through your code should not be able to start homebrew I think. (disclaimer: I have not tried it)

Also I am wondering why you were going for a while(1) loop instead of an if-else construct. It seems like a way to recreate a switch-case statement?

Edit: The HOME button cannot directly be read in user mode to be used as a button. But if you have an exit callback registered, the PSP_CTRL_HOME flag will get set when the exit menu pops up.

TiPi
Retired Mod
Posts: 740
Joined: Tue Sep 28, 2010 5:32 am
Contact:

Re: [n00bish] HBL shortcuts mod

Post by TiPi » Sat Nov 13, 2010 8:47 am

JJS wrote: I think it would be better to always set the g->menupath variable to the eboot path though because there should be a problem with running different menus now.
I tried to mess with that global variable before, but I thought that would be a bit too difficult for my first C code.
JJS wrote: In start_module(), the EBOOTs path is checked against g->menupath. Only if they are identical, the menu API is put into argv[1]. This means a menu run through your code should not be able to start homebrew I think. (disclaimer: I have not tried it)
Oh, I didn't know that. Since I tried the shortcuts with simple programs I made on my own stored in the shortcuts folder.
JJS wrote:Edit: The HOME button cannot directly be read in user mode to be used as a button. But if you have an exit callback registered, the PSP_CTRL_HOME flag will get set when the exit menu pops up.
Aight, thanks for explaining.

I'll probably try to improve the code soon. If anyone else wants to give it a try, go ahead. :)
Problems or questions? Feel free to contact me.
-My Blog-

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: [n00bish] HBL shortcuts mod

Post by m0skit0 » Sun Nov 21, 2010 12:00 am

Very good idea TiPi, but I must say it's a bit poor programmed. You shouldn't use break, use a while condition to end the loop. Also modifying eloader.c is not a good idea because what you wanna do is menu-related, and not HBL-related. I would put that on menu.c instead. Try to figure out how ;)

And definitely, for such a things, HBL needs an API. The HBL-menu interfacing designed by wololo works, but it's not a good design.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

TiPi
Retired Mod
Posts: 740
Joined: Tue Sep 28, 2010 5:32 am
Contact:

Re: [n00bish] HBL shortcuts mod

Post by TiPi » Thu Nov 25, 2010 5:46 pm

I was thinking to port a better version of my code to an eboot, so I don't have to update and compile the source code each time a new HBL revision is released.
So, what would be better? A built in shortcuts mod? Or an automatic starting eboot that includes that mod? Not sure about that, but would it affect speed/compatibility?
And m0skit0, couldn't find a menu.c in the source code. Are you referring to /menu/main.c?
Problems or questions? Feel free to contact me.
-My Blog-

JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Re: [n00bish] HBL shortcuts mod

Post by JJS » Thu Nov 25, 2010 7:01 pm

So you mean replacing the menu by an EBOOT that contains the code above (basically a menu) to load other menus or homebrew? I don't think it is possible to load other menus that way because again the menu API is only given to the menu EBOOT if the path matches that of g->menupath. That variable would point to your wrapper of course and not to the menu you want to start.

Post Reply

Return to “Programming and Security”