mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-27 23:32:39 +02:00
Added libappletPushInData. Moved common storage creation+writing code into 1 func, in libapplet.c.
This commit is contained in:
parent
2405872b16
commit
2d5000ba57
@ -41,6 +41,14 @@ void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag);
|
||||
*/
|
||||
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h);
|
||||
|
||||
/**
|
||||
* @brief Creates a storage using the input buffer which is pushed to the AppletHolder via \ref appletHolderPushInData.
|
||||
* @param h AppletHolder object.
|
||||
* @param buffer Input data buffer.
|
||||
* @param size Input data size.
|
||||
*/
|
||||
Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size);
|
||||
|
||||
/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
|
||||
/// Returns to the main Home Menu, equivalent to pressing the HOME button.
|
||||
Result libappletRequestHomeMenu(void);
|
||||
|
@ -19,41 +19,52 @@ void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag) {
|
||||
a->PlayStartupSound = flag!=0;
|
||||
}
|
||||
|
||||
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h) {
|
||||
static Result _libappletCreateWriteStorage(AppletStorage* s, const void* buffer, size_t size) {
|
||||
Result rc=0;
|
||||
|
||||
rc = appletCreateStorage(s, size);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
rc = appletStorageWrite(s, 0, buffer, size);
|
||||
if (R_FAILED(rc)) {
|
||||
appletStorageClose(s);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _libappletPushInData(AppletHolder *h, const void* buffer, size_t size) {
|
||||
Result rc=0;
|
||||
AppletStorage storage;
|
||||
|
||||
rc = _libappletCreateWriteStorage(&storage, buffer, size);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
return appletHolderPushInData(h, &storage);
|
||||
}
|
||||
|
||||
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h) {
|
||||
//Official sw stores the header in LibAppletArgs seperately (first 8-bytes), but here we're including it with the LibAppletCommonArguments struct.
|
||||
//Official sw uses appletStorageWrite twice, for writing the header then the rest of the struct.
|
||||
|
||||
a->tick = armGetSystemTick();
|
||||
|
||||
rc = appletCreateStorage(&storage, sizeof(LibAppletArgs));
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
rc = appletStorageWrite(&storage, 0, a, sizeof(LibAppletArgs));
|
||||
if (R_FAILED(rc)) {
|
||||
appletStorageClose(&storage);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return appletHolderPushInData(h, &storage);
|
||||
return _libappletPushInData(h, a, sizeof(LibAppletArgs));
|
||||
}
|
||||
|
||||
static Result _libappletQlaunchRequest(u8* buf, size_t size) {
|
||||
Result rc=0;
|
||||
AppletStorage storage;
|
||||
|
||||
rc = appletCreateStorage(&storage, size);
|
||||
rc = _libappletCreateWriteStorage(&storage, buf, size);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
rc = appletStorageWrite(&storage, 0, buf, size);
|
||||
if (R_FAILED(rc)) {
|
||||
appletStorageClose(&storage);
|
||||
return rc;
|
||||
return appletPushToGeneralChannel(&storage);
|
||||
}
|
||||
|
||||
return appletPushToGeneralChannel(&storage);
|
||||
Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size) {
|
||||
return _libappletPushInData(h, buffer, size);
|
||||
}
|
||||
|
||||
Result libappletRequestHomeMenu(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user