Page 3 of 3

Re: Menu API and cascading menus

Posted: Fri Dec 17, 2010 2:18 pm
by JJS
While I was writing a sample menu for the new API I was using the sceUtilityGetSystemParam*() functions and thought that doing it like that would be a better idea. So instead of having a dedicated set/get function for every variable, there is now only one set/get for each data type. This simplyfies the extension of the API and the hooking code quite a bit.

So a new header would look like this:

Code: Select all

#ifndef HBL_API
#define HBL_API

// All functions return 0 on success and a value < 0 on error
#define HBL_ERROR_OK 0
#define HBL_ERROR_GENERIC 0x80000001
#define HBL_ERROR_BUFFER_TOO_SMALL 0x80000002
#define HBL_ERROR_INVALID_PARAMETER_ID 0x80000003
#define HBL_ERROR_PARAMETER_IS_READONLY 0x80000004


// String parameter IDs (R = readable, W = writable)
typedef enum
{
	HBL_PARAM_HOMEBREW_PATH = 0,     // R+W - starting folder for the menu
	HBL_PARAM_NEXT_EXEC = 1,         // R+W - path of the EBOOT that is run next
	HBL_PARAM_CREDITS_STRING = 2,    // R - HBL credits string
	HBL_PARAM_VERSION_STRING = 3     // R - HBL version string
}
HblStringParameter;


// Integer parameter IDs (R = readable, W = writable)
typedef enum
{
	HBL_PARAM_NEXT_EXEC_IS_MENU = 0, // R+W - treat the next EBOOT as an old style menu (API in argv[1])
	HBL_PARAM_VERSION = 1,           // R - HBL revision
	HBL_PARAM_EXIT_TO_XMB = 2        // R+W - quit to the XMB after the current homebrew exits
}
HblIntParameter;



// Set the string parameter indicated by the ID
int hblSetParamString(HblStringParameter id, char* buffer);

// Get the string parameter indicated by the ID, bufferSize includes the trailing 0
int hblGetParamString(HblStringParameter id, char* buffer, unsigned int bufferSize);

// Get the size of a buffer (including the trailing 0) to hold the indicated parameter
int hblGetParamStringSize(HblStringParameter id);


// Set the int parameter indicated by the ID
int hblSetParamInt(HblIntParameter id, int value);

// Get the int parameter indicated by the ID
int hblGetParamInt(HblIntParameter id, int value);



#endif
What do you guys think?

Re: Menu API and cascading menus

Posted: Fri Dec 17, 2010 4:01 pm
by FrEdDy
JJS wrote:While I was writing a sample menu for the new API I was using the sceUtilityGetSystemParam*() functions and thought that doing it like that would be a better idea. So instead of having a dedicated set/get function for every variable, there is now only one set/get for each data type. This simplyfies the extension of the API and the hooking code quite a bit.

So a new header would look like this:

Code: Select all

#ifndef HBL_API
#define HBL_API

// All functions return 0 on success and a value < 0 on error
#define HBL_ERROR_OK 0
#define HBL_ERROR_GENERIC 0x80000001
#define HBL_ERROR_BUFFER_TOO_SMALL 0x80000002
#define HBL_ERROR_INVALID_PARAMETER_ID 0x80000003
#define HBL_ERROR_PARAMETER_IS_READONLY 0x80000004


// String parameter IDs (R = readable, W = writable)
typedef enum
{
	HBL_PARAM_HOMEBREW_PATH = 0,     // R+W - starting folder for the menu
	HBL_PARAM_NEXT_EXEC = 1,         // R+W - path of the EBOOT that is run next
	HBL_PARAM_CREDITS_STRING = 2,    // R - HBL credits string
	HBL_PARAM_VERSION_STRING = 3     // R - HBL version string
}
HblStringParameter;


// Integer parameter IDs (R = readable, W = writable)
typedef enum
{
	HBL_PARAM_NEXT_EXEC_IS_MENU = 0, // R+W - treat the next EBOOT as an old style menu (API in argv[1])
	HBL_PARAM_VERSION = 1,           // R - HBL revision
	HBL_PARAM_EXIT_TO_XMB = 2        // R+W - quit to the XMB after the current homebrew exits
}
HblIntParameter;



// Set the string parameter indicated by the ID
int hblSetParamString(HblStringParameter id, char* buffer);

// Get the string parameter indicated by the ID, bufferSize includes the trailing 0
int hblGetParamString(HblStringParameter id, char* buffer, unsigned int bufferSize);

// Get the size of a buffer (including the trailing 0) to hold the indicated parameter
int hblGetParamStringSize(HblStringParameter id);


// Set the int parameter indicated by the ID
int hblSetParamInt(HblIntParameter id, int value);

// Get the int parameter indicated by the ID
int hblGetParamInt(HblIntParameter id, int value);



#endif
What do you guys think?
Nice idea

Re: Menu API and cascading menus

Posted: Fri Dec 17, 2010 5:43 pm
by m0skit0
Nice one.

Re: Menu API and cascading menus

Posted: Mon Mar 19, 2012 7:52 am
by JJS
I was looking through old threads and this caught my attention. Sorry that I didn't finish the API implementation, guys. This whole thing got steamrolled with me helping on the sukkiri exploit and the TN HEN release I guess.

Anyway, I decided to pull a diff from the files I had on my harddrive. The problem I ran into was that I couldn't implement the API in a way that would not break backward compatibility with the old menu code. So here is a diff with HBL R112 :shock: