mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-24 03:36:24 +00:00
initial emscripten dosbox integration
This commit is contained in:
parent
bff9a885f8
commit
664d37f943
@ -1,4 +1,8 @@
|
||||
<!doctype html>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -24,6 +28,8 @@
|
||||
<button id="btnLoad" onclick="document.getElementById('rom').click()">Upload Content</button>
|
||||
<input style="display: none" type="file" id="rom" name="upload" onclick="document.getElementById('btnLoad').click();" onchange="selectFiles(event.target.files)" multiple />
|
||||
<button id="btnStart" onclick="startRetroArch()">Start RetroArch</button>
|
||||
<button id="btnAuth" onclick="dropboxInit()">Link to Dropbox</button>
|
||||
<button id="btnBack" onclick="dropboxCopy()">Backup Config to Dropbox</button>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="webplayer">
|
||||
@ -40,19 +46,72 @@
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
||||
<script type='text/javascript'>
|
||||
var count = 0;
|
||||
|
||||
<script type='text/javascript'>
|
||||
var dropbox = false;
|
||||
var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" });
|
||||
|
||||
var showError = function(error) {
|
||||
switch (error.status) {
|
||||
case Dropbox.ApiError.INVALID_TOKEN:
|
||||
// If you're using dropbox.js, the only cause behind this error is that
|
||||
// the user token expired.
|
||||
// Get the user through the authentication flow again.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NOT_FOUND:
|
||||
// The file or folder you tried to access is not in the user's Dropbox.
|
||||
// Handling this error is specific to your application.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.OVER_QUOTA:
|
||||
// The user is over their Dropbox quota.
|
||||
// Tell them their Dropbox is full. Refreshing the page won't help.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.RATE_LIMITED:
|
||||
// Too many API requests. Tell the user to try again later.
|
||||
// Long-term, optimize your code to use fewer API calls.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NETWORK_ERROR:
|
||||
// An error occurred at the XMLHttpRequest layer.
|
||||
// Most likely, the user's network connection is down.
|
||||
// API calls will not succeed until the user gets back online.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.INVALID_PARAM:
|
||||
case Dropbox.ApiError.OAUTH_ERROR:
|
||||
case Dropbox.ApiError.INVALID_METHOD:
|
||||
default:
|
||||
// Caused by a bug in dropbox.js, in your application, or in Dropbox.
|
||||
// Tell the user an error occurred, ask them to refresh the page.
|
||||
}
|
||||
};
|
||||
|
||||
function dropboxInit()
|
||||
{
|
||||
client.authDriver(new Dropbox.AuthDriver.Redirect());
|
||||
client.authenticate({ rememberUser: true }, function(error, client)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
return showError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
function setupFileSystem()
|
||||
{
|
||||
console.log(client.isAuthenticated());
|
||||
if(localStorage.getItem("fs_inited")!="true")
|
||||
{
|
||||
var lsfs = new BrowserFS.FileSystem.LocalStorage();
|
||||
|
||||
BrowserFS.initialize(lsfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
|
||||
FS.mount(BFS, {root: '/'}, '/home');
|
||||
|
||||
console.log('WEBPLAYER: Filesystem initialized');
|
||||
}
|
||||
else
|
||||
@ -71,6 +130,8 @@
|
||||
FS.createPath('/', '/home/web_user/saves', true, true);
|
||||
FS.createPath('/', '/home/web_user/states', true, true);
|
||||
FS.createPath('/', '/home/web_user/system', true, true);
|
||||
|
||||
FS.createPath('/', '/data/test', true, true);
|
||||
}
|
||||
|
||||
function stat(path)
|
||||
@ -111,7 +172,7 @@
|
||||
config += 'video_vsync = false\n';
|
||||
config += 'system_directory = /home/web_user/system/\n';
|
||||
config += 'savefile_directory = /home/web_user/saves/\n';
|
||||
config += 'savestate_directory = /home/web_user/saves/\n';
|
||||
config += 'savestate_directory = /home/web_user/states/\n';
|
||||
config += 'rgui_browser_directory = /home/web_user/content/\n';
|
||||
|
||||
FS.writeFile(cfgFile, config);
|
||||
@ -146,6 +207,18 @@
|
||||
FS.unlink(name);
|
||||
|
||||
}
|
||||
|
||||
function dropboxCopy()
|
||||
{
|
||||
var data = FS.readFile('/home/web_user/.config/retroarch/retroarch.cfg',{ encoding: 'utf8' });
|
||||
console.log(data);
|
||||
var dbfs = new BrowserFS.FileSystem.Dropbox(client);
|
||||
BrowserFS.initialize(dbfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
|
||||
var fs = BrowserFS.BFSRequire('fs');
|
||||
fs.writeFile('retroarch.cfg', data ,{ encoding: 'utf8' });
|
||||
}
|
||||
|
||||
var Module =
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user