From 8b2434a408494f54304e459c0387b69ad82698e1 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 8 Sep 2016 23:37:05 -0500 Subject: [PATCH] (ems) override F1 and other keys, use paths relative to the base url --- pkg/emscripten/proto.html | 4 ++- pkg/emscripten/proto.js | 74 ++++++++++++++++++++++++++++----------- 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/pkg/emscripten/proto.html b/pkg/emscripten/proto.html index af26694fc7..7ae1e38ecb 100644 --- a/pkg/emscripten/proto.html +++ b/pkg/emscripten/proto.html @@ -9,7 +9,7 @@ - + @@ -150,10 +150,12 @@ + + diff --git a/pkg/emscripten/proto.js b/pkg/emscripten/proto.js index f5826c1fc0..2268705ef9 100644 --- a/pkg/emscripten/proto.js +++ b/pkg/emscripten/proto.js @@ -103,9 +103,9 @@ function setupFileSystem(backend) var lsfs = new BrowserFS.FileSystem.LocalStorage(); /* create an XmlHttpRequest filesystem for assets */ var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest - (".index-xhr", "https://bot.libretro.com/web/assets/"); + (".index-xhr", "/web/assets/"); var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest - (".index-xhr", "https://bot.libretro.com/assets/cores/"); + (".index-xhr", "/assets/cores/"); /* mount the local filesystem at the root of mfs*/ mfs.mount('/home/web_user/userdata', lsfs); @@ -124,9 +124,9 @@ function setupFileSystem(backend) var mfs = new BrowserFS.FileSystem.MountableFileSystem(); /* create an XmlHttpRequest filesystem for assets */ var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest - (".index-xhr", "https://bot.libretro.com/web/assets/"); + (".index-xhr", "/web/assets/"); var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest - (".index-xhr", "https://bot.libretro.com/assets/cores/"); + (".index-xhr", "/assets/cores/"); /* mount the local filesystem at the root of mfs*/ mfs.mount('/home/web_user/userdata', afs); @@ -265,16 +265,17 @@ function switchStorage(backend) { // When the browser has loaded everything. $(function() { - // Find which core to load. - var core = localStorage.getItem("core", core); - if (!core) { - core = 'gambatte'; - } - // Show the current core as the active core. - $('.nav-item.' + core).addClass('active'); + // Find which core to load. + var core = localStorage.getItem("core", core); + if (!core) { + core = 'gambatte'; + } + // Show the current core as the active core. + $('.nav-item.' + core).addClass('active'); - // Load the Core's related JavaScript. - $.getScript(core + '_libretro.js', function () { + // Load the Core's related JavaScript. + $.getScript(core + '_libretro.js', function () + { // Activate the Start RetroArch button. $('#btnRun').removeClass('disabled'); $('#icnRun').removeClass('fa-spinner spinning'); @@ -297,11 +298,44 @@ $(function() { * Attempt to disable some default browser keys. */ - window.addEventListener('keydown', function(e) { - // Space key, arrows, and F1. - if([32, 37, 38, 39, 40, 112].indexOf(e.keyCode) > -1) { - e.preventDefault(); + var util = { }; + + document.addEventListener('keydown', function(e) + { + var key = util.key[e.which]; + if( key ) + { + e.preventDefault(); } - }, false); - }); -}); + }) + + util.key = { + 9: "tab", + 13: "enter", + 16: "shift", + 18: "alt", + 27: "esc", + 33: "rePag", + 34: "avPag", + 35: "end", + 36: "home", + 37: "left", + 38: "up", + 39: "right", + 40: "down", + 112: "F1", + 113: "F2", + 114: "F3", + 115: "F4", + 116: "F5", + 117: "F6", + 118: "F7", + 119: "F8", + 120: "F9", + 121: "F10", + 122: "F11", + 123: "F12" + } + + }); + }); \ No newline at end of file