Skip to content

Commit

Permalink
Handle disk image mount requests from the JS side
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaip committed Jan 21, 2023
1 parent 68e5181 commit be99085
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/OSGLUESC.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,35 @@ LOCALFUNC blnr InitLocationDat(void)
return trueblnr;
}

/* --- disk images -- */

EM_JS(char*, consumeDiskImagePath, (void), {
const diskImagePath = workerApi.consumeDiskImagePath();
if (!diskImagePath || !diskImagePath.length) {
return 0;
}
const diskImagePathLength = lengthBytesUTF8(diskImagePath) + 1;
const diskImagePathCstr = _malloc(diskImagePathLength);
stringToUTF8(diskImagePath, diskImagePathCstr, diskImagePathLength);
return diskImagePathCstr;
});

LOCALVAR ui5b LastDiskImageCheckTime;

LOCALFUNC void HandleDiskImages(void)
{
ui5b currentTime = LastTimeSec * TicksPerSecond + LastTimeUsec;
if (currentTime - LastDiskImageCheckTime < 100000) {
return;
}
LastDiskImageCheckTime = currentTime;
char *diskImagePath = consumeDiskImagePath();
if (diskImagePath) {
Sony_Insert1(diskImagePath, trueblnr);
free(diskImagePath);
}
}

/* --- clipboard --- */

#if IncludeHostTextClipExchange
Expand Down Expand Up @@ -864,6 +893,7 @@ GLOBALOSGLUPROC WaitForNextTick(void)
#endif
}

HandleDiskImages();
ReadJSInput();

OnTrueTime = TrueEmulatedTime;
Expand Down

0 comments on commit be99085

Please sign in to comment.