allow upload of SRM files, also allow upload of savestates but it seems saves are not compatible from PC

This commit is contained in:
radius 2015-05-12 00:41:40 -04:00
parent e55fe20da1
commit 0751939c52
4 changed files with 11892 additions and 12 deletions

11847
emscripten/browserfs.js Normal file

File diff suppressed because it is too large Load Diff

6
emscripten/browserfs.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -33,16 +33,17 @@
<div id="accordion" class="emscripten">
<h3>Settings</h3>
<div class="emscripten">
<button id="content" onclick="document.getElementById('rom').click()">Upload content</button>
<button id="content" onclick="document.getElementById('rom').click()">Start</button>
<input style="display: none" type="file" id="rom" name="upload" onclick="document.getElementById('content').click();" onchange="runEmulator(event.target.files);" multiple /></p>
<input type="checkbox" id="resize"><label for="resize">Resize canvas</label></p>
<button id="saves" onclick="document.getElementById('savefiles').click()">Upload Savefiles</button>
<input style="display: none" type="file" id="savefiles" name="upload" onclick="document.getElementById('saves').click();" onchange="uploadData(event.target.files,'saves');" multiple /></p>
<button id="states" onclick="document.getElementById('savestates').click()">Upload Savestates</button>
<input style="display: none" type="file" id="savestates" name="upload" onclick="document.getElementById('states').click();" onchange="uploadData(event.target.files,'states');" multiple /></p>
<input type="checkbox" id="pointerLock" checked><label for="pointerLock">Lock/hide mouse pointer</label></p>
<input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked, document.getElementById('resize').checked)"></p>
<input type="checkbox" id="vsync"><label for="vsync" id="vsync-label">Enable V-sync (can only be done before loading game)</label></p>
<input type="textbox" id="latency" size="3" maxlength="3" value="96"> <label for="latency" id="latency-label">Audio latency (ms) (increase if you hear pops at fullspeed, can only be done before loading game)</label></p>
</div>
<h3>Console</h3>
<div class="emscripten">

View File

@ -49,7 +49,7 @@ function createConfig()
function setupFileSystem()
{
console.log("setupFileSystem");
console.log("setupFileSystem");
if(localStorage.getItem("fs_inited")!="true")
{
@ -59,8 +59,11 @@ function setupFileSystem()
FS.mount(BFS, {root: '/'}, '/home');
localStorage.setItem("fs_inited","true");
console.log('Filesystem initialized: ' + localStorage.getItem("fs_inited"));
console.log('Filesystem initialized');
}
else
{
console.log('Filesystem already initialized');
}
}
@ -69,7 +72,8 @@ function runEmulator(files)
if (Modernizr.localstorage)
{
setupFileSystem();
if(firstRun)
setupFileSystem();
}
setupFolders();
@ -99,7 +103,29 @@ function runEmulator(files)
function uploadContent(data, name)
{
var dataView = new Uint8Array(data);
Module.FS_createDataFile('/', name, dataView, true, false);
FS.createDataFile('/', name, dataView, true, false);
}
function copyFile(src,dest)
{
console.log('copying: ' + src + ' to: ' + dest);
var contents = FS.readFile(src,{ encoding: 'binary' });
console.log(contents);
FS.writeFile(dest,contents,{ encoding: 'binary' });
}
function uploadData(files, path)
{
count = files.length;
for (var i = 0; i < files.length; i++)
{
filereader = new FileReader();
filereader.file_name = files[i].name;
filereader.readAsArrayBuffer(files[i]);
filereader.onload = function(){uploadContent(this.result, '/tmp/' + this.file_name)};
filereader.onloadend = function(){copyFile('/tmp/' + this.file_name,'/home/web_user/retroarch/' + path + '/' + this.file_name)};
}
}
function initFromData()