mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
coreinit_FS: Invoke attach callback after FSAddClientEx to inform title that SD card was inserted.
This commit is contained in:
parent
0ed2638da3
commit
345ba088d1
@ -275,7 +275,23 @@ namespace coreinit
|
||||
cemuLog_log(LogType::Force, "FSShutdown called");
|
||||
}
|
||||
|
||||
FS_RESULT FSAddClientEx(FSClient_t* fsClient, uint32 uknR4, uint32 errHandling)
|
||||
struct AttachCallbackData
|
||||
{
|
||||
/* +0x00 */ uint8 unk[0x1c];
|
||||
/* +0x1c */ char mountName[8];
|
||||
};
|
||||
|
||||
SysAllocator<AttachCallbackData> s_fsAttachCallbackData;
|
||||
|
||||
void invokeAttachCallback(FSAttachParams& attachParams)
|
||||
{
|
||||
*s_fsAttachCallbackData = { .mountName = "sdcard" /* expected by Mii Maker */ };
|
||||
PPCCoreCallback(attachParams.userCallback,
|
||||
0 /* r3 = unknown */, 1 /* r4 = non-zero means device is attached */,
|
||||
s_fsAttachCallbackData.GetMPTR(), attachParams.userContext);
|
||||
}
|
||||
|
||||
FS_RESULT FSAddClientEx(FSClient_t* fsClient, FSAttachParams* attachParams, uint32 errHandling)
|
||||
{
|
||||
if (!sFSInitialized || sFSShutdown || !fsClient)
|
||||
{
|
||||
@ -283,15 +299,13 @@ namespace coreinit
|
||||
return FS_RESULT::FATAL_ERROR;
|
||||
}
|
||||
FSLockMutex();
|
||||
if (uknR4 != 0)
|
||||
if (attachParams != nullptr &&
|
||||
attachParams->userCallback == nullptr)
|
||||
{
|
||||
uint32 uknValue = memory_readU32(uknR4 + 0x00);
|
||||
if (uknValue == 0)
|
||||
{
|
||||
FSUnlockMutex();
|
||||
__FSErrorAndBlock("FSAddClientEx - unknown error");
|
||||
return FS_RESULT::FATAL_ERROR;
|
||||
}
|
||||
FSUnlockMutex();
|
||||
// "FS: FSAddClient: attachParams->userCallback must be set.\n"
|
||||
__FSErrorAndBlock("FSAddClientEx - unknown error");
|
||||
return FS_RESULT::FATAL_ERROR;
|
||||
}
|
||||
if (__FSIsClientRegistered(__FSGetClientBody(fsClient)))
|
||||
{
|
||||
@ -324,12 +338,16 @@ namespace coreinit
|
||||
fsClientBody->fsClientBodyNext = nullptr;
|
||||
}
|
||||
FSUnlockMutex();
|
||||
|
||||
if (attachParams != nullptr) // invoke right before returning
|
||||
invokeAttachCallback(*attachParams);
|
||||
|
||||
return FS_RESULT::SUCCESS;
|
||||
}
|
||||
|
||||
FS_RESULT FSAddClient(FSClient_t* fsClient, uint32 errHandling)
|
||||
{
|
||||
return FSAddClientEx(fsClient, 0, errHandling);
|
||||
return FSAddClientEx(fsClient, nullptr, errHandling);
|
||||
}
|
||||
|
||||
FS_RESULT FSDelClient(FSClient_t* fsClient, uint32 errHandling)
|
||||
|
||||
@ -18,6 +18,13 @@ struct FSAsyncParams
|
||||
};
|
||||
static_assert(sizeof(FSAsyncParams) == 0xC);
|
||||
|
||||
struct FSAttachParams
|
||||
{
|
||||
MEMPTR<void> userCallback;
|
||||
MEMPTR<void> userContext;
|
||||
};
|
||||
static_assert(sizeof(FSAttachParams) == 0x8);
|
||||
|
||||
namespace coreinit
|
||||
{
|
||||
struct FSCmdBlockBody;
|
||||
@ -242,7 +249,7 @@ namespace coreinit
|
||||
sint32 __FSQueryInfoAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* queryString, uint32 queryType, void* queryResult, uint32 errHandling, FSAsyncParams* fsAsyncParams);
|
||||
|
||||
// coreinit exports
|
||||
FS_RESULT FSAddClientEx(FSClient_t* fsClient, uint32 uknR4, uint32 errHandling);
|
||||
FS_RESULT FSAddClientEx(FSClient_t* fsClient, FSAttachParams* attachParams, uint32 errHandling);
|
||||
FS_RESULT FSAddClient(FSClient_t* fsClient, uint32 errHandling);
|
||||
FS_RESULT FSDelClient(FSClient_t* fsClient, uint32 errHandling);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user