Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lrusso committed May 14, 2023
1 parent cd16c10 commit e386002
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Emulatrix_DOSBox.htm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

// mobile compatibility
var joystick=null;
var JoyStick=function(t,e){var i=void 0===(e=e||{}).title?"joystick":e.title,n=void 0===e.width?0:e.width,o=void 0===e.height?0:e.height,h=void 0===e.internalFillColor?"rgba(0,0,0,0.25)":e.internalFillColor,r=void 0===e.internalLineWidth?2:e.internalLineWidth,d=(void 0===e.internalStrokeColor||e.internalStrokeColor,void 0===e.externalLineWidth?2:e.externalLineWidth),a=void 0===e.externalStrokeColor?"rgba(255,255,255,0.175)":e.externalStrokeColor,c=document.getElementById(t),l=document.createElement("canvas");l.id=i,0==n&&(n=c.clientWidth),0==o&&(o=c.clientHeight),l.width=n,l.height=o,c.appendChild(l);var u=l.getContext("2d"),g=0,s=2*Math.PI,f=(l.width-110)/2,v=f+5,w=f+30,p=l.width/2,C=l.height/2,L=l.width/10,W=-1*L,k=l.height/10,E=-1*k,m=p,S=C;function x(){u.beginPath(),u.arc(p,C,w,0,s,!1),u.lineWidth=d,u.strokeStyle=a,u.stroke()}function y(){u.beginPath(),m<f&&(m=v),m+f>l.width&&(m=l.width-v),S<f&&(S=v),S+f>l.height&&(S=l.height-v),u.arc(m,S,f,0,s,!1),u.fillStyle=h,u.fill(),u.lineWidth=r,u.strokeStyle="rgba(255,255,255,0.175)",u.stroke()}l.addEventListener("touchstart",function(t){g=1},!1),l.addEventListener("touchmove",function(t){if(t.preventDefault(),1==g)try{for(var e=l.getBoundingClientRect(),i=e.left+l.offsetWidth,n=e.top,o=-1,h=0;h<t.touches.length;h++)t.touches[h].pageX<=i&&t.touches[h].pageY>=n&&(o=h);o>-1&&(m=t.touches[o].pageX,S=l.height-(window.innerHeight-t.touches[o].pageY),m-=l.offsetLeft,u.clearRect(0,0,l.width,l.height),x(),y())}catch(t){}},!1),l.addEventListener("touchend",function(t){g=0,m=p,S=C,u.clearRect(0,0,l.width,l.height),x(),y()},!1),l.addEventListener("mousedown",function(t){g=1},!1),l.addEventListener("mousemove",function(t){1==g&&(m=t.pageX,S=l.height-(window.innerHeight-t.pageY),m-=l.offsetLeft,S-=l.offsetTop,u.clearRect(0,0,l.width,l.height),x(),y())},!1),l.addEventListener("mouseup",function(t){g=0,m=p,S=C,u.clearRect(0,0,l.width,l.height),x(),y()},!1),x(),y(),this.GetWidth=function(){return l.width},this.GetHeight=function(){return l.height},this.GetPosX=function(){return m},this.GetPosY=function(){return S},this.GetX=function(){return((m-p)/v*100).toFixed()},this.GetY=function(){return((S-C)/v*100*-1).toFixed()},this.GetDir=function(){var t="",e=m-p,i=S-C;return i>=E&&i<=k&&(t="C"),i<E&&(t="N"),i>k&&(t="S"),e<W&&("C"==t?t="W":t+="W"),e>L&&("C"==t?t="E":t+="E"),t}};
var JoyStick=function(t,e){var i=void 0===(e=e||{}).title?"joystick":e.title,n=void 0===e.width?0:e.width,o=void 0===e.height?0:e.height,h=void 0===e.internalFillColor?"rgba(0,0,0,0.25)":e.internalFillColor,r=void 0===e.internalLineWidth?2:e.internalLineWidth,d=void 0===e.internalStrokeColor?"rgba(255,255,255,0.175)":e.internalStrokeColor,a=void 0===e.externalLineWidth?2:e.externalLineWidth,l=void 0===e.externalStrokeColor?"rgba(255,255,255,0.175)":e.externalStrokeColor,c=document.getElementById(t),u=document.createElement("canvas");u.id=i,0==n&&(n=c.clientWidth),0==o&&(o=c.clientHeight),u.width=n,u.height=o,c.appendChild(u);var g=u.getContext("2d"),s=0,f=2*Math.PI,v=(u.width-110)/2,w=v+5,p=v+30,C=u.width/2,L=u.height/2,S=u.width/10,W=-1*S,k=u.height/10,E=-1*k,m=C,G=L,x=-1;function y(){g.beginPath(),g.arc(C,L,p,0,f,!1),g.lineWidth=a,g.strokeStyle=l,g.stroke()}function R(){g.beginPath(),m<v&&(m=w),m+v>u.width&&(m=u.width-w),G<v&&(G=w),G+v>u.height&&(G=u.height-w),g.arc(m,G,v,0,f,!1);var t=g.createRadialGradient(C,L,5,C,L,200);t.addColorStop(0,h),t.addColorStop(1,d),g.fillStyle=t,g.fill(),g.lineWidth=r,g.strokeStyle=d,g.stroke()}u.addEventListener("touchstart",function(t){s=1;for(var e=u.getBoundingClientRect(),i=e.left+u.offsetWidth,n=e.top,o=0;o<t.touches.length;o++)t.touches[o].pageX<=i&&t.touches[o].pageY>=n&&(x=o)},!1),u.addEventListener("touchmove",function(t){if(t.preventDefault(),1==s)try{x>-1&&(m=t.touches[x].pageX,G=u.height-(window.innerHeight-t.touches[x].pageY),m-=u.offsetLeft,g.clearRect(0,0,u.width,u.height),y(),R())}catch(t){}},!1),u.addEventListener("touchend",function(t){s=0,x=-1,m=C,G=L,g.clearRect(0,0,u.width,u.height),y(),R()},!1),u.addEventListener("mousedown",function(t){s=1},!1),u.addEventListener("mousemove",function(t){1==s&&(m=t.pageX,G=u.height-(window.innerHeight-t.pageY),m-=u.offsetLeft,G-=u.offsetTop,g.clearRect(0,0,u.width,u.height),y(),R())},!1),u.addEventListener("mouseup",function(t){s=0,m=C,G=L,g.clearRect(0,0,u.width,u.height),y(),R()},!1),y(),R(),this.GetWidth=function(){return u.width},this.GetHeight=function(){return u.height},this.GetPosX=function(){return m},this.GetPosY=function(){return G},this.GetX=function(){return((m-C)/w*100).toFixed()},this.GetY=function(){return((G-L)/w*100*-1).toFixed()},this.GetDir=function(){var t="",e=m-C,i=G-L;return i>=E&&i<=k&&(t="C"),i<E&&(t="N"),i>k&&(t="S"),e<W&&("C"==t?t="W":t+="W"),e>S&&("C"==t?t="E":t+="E"),t}};
function isMobileDevice(){return!!(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i))}
function sendVirtualKey(eventType,keyCode,charCode){try{var e=document.createEventObject?document.createEventObject():document.createEvent("Events");if(e.initEvent&&e.initEvent(eventType,!0,!0),e.keyCode=keyCode,e.which=keyCode,e.charCode=charCode,"undefined"!=typeof JSEvents&&JSEvents.eventHandlers&&JSEvents.eventHandlers.length>0)for(var i=0;i<JSEvents.eventHandlers.length;++i)JSEvents.eventHandlers[i].target!=Module.canvas&&JSEvents.eventHandlers[i].target!=window||JSEvents.eventHandlers[i].eventTypeString!=eventType||JSEvents.eventHandlers[i].handlerFunc(e);else Module.canvas.dispatchEvent?Module.canvas.dispatchEvent(e):Module.canvas.fireEvent("on"+eventType,e)}catch(e){}}
function showVirtualJoystick(){joystick = new JoyStick("joyDiv");setInterval(function(){var joystickDirection = joystick.GetDir();switch(joystickDirection){case "N":try{sendVirtualKey("keydown",38,38);sendVirtualKey("keyup",40,40);sendVirtualKey("keyup",37,37);sendVirtualKey("keyup",39,39)}catch(err){}break;case "S":try{sendVirtualKey("keydown",40,40);sendVirtualKey("keyup",38,38);sendVirtualKey("keyup",37,37);sendVirtualKey("keyup",39,39)}catch(err){}break;case "W":try{sendVirtualKey("keydown",37,37);sendVirtualKey("keyup",38,38);sendVirtualKey("keyup",40,40);sendVirtualKey("keyup",39,39)}catch(err){}break;case "E":try{sendVirtualKey("keydown",39,39);sendVirtualKey("keyup",38,38);sendVirtualKey("keyup",40,40);sendVirtualKey("keyup",37,37)}catch(err){}break;case "NW":try{sendVirtualKey("keydown",38,38);sendVirtualKey("keydown",37,37);sendVirtualKey("keyup",39,39);sendVirtualKey("keyup",40,40)}catch(err){}break;case "NE":try{sendVirtualKey("keydown",38,38);sendVirtualKey("keydown",39,39);sendVirtualKey("keyup",40,40);sendVirtualKey("keyup",37,37)}catch(err){}break;case "SE":try{sendVirtualKey("keydown",40,40);sendVirtualKey("keydown",39,39);sendVirtualKey("keyup",38,38);sendVirtualKey("keyup",37,47)}catch(err){}break;case "SW":try{sendVirtualKey("keydown",40,40);sendVirtualKey("keydown",37,37);sendVirtualKey("keyup",38,38);sendVirtualKey("keyup",39,49)}catch(err){}break;default:try{sendVirtualKey("keyup",39,39);sendVirtualKey("keyup",38,38);sendVirtualKey("keyup",40,40);sendVirtualKey("keyup",37,37)}catch(err){}break}},25)}
Expand Down
2 changes: 1 addition & 1 deletion Emulatrix_GameBoy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e386002

Please sign in to comment.