Fixed checkSoftKeysToRelease(), although the iOS soft keyboard still sucks

This commit is contained in:
Jeff Parsons 2016-08-02 15:42:41 -07:00 committed by Jeff Parsons
commit c59678f37d
3 changed files with 9 additions and 9 deletions

View file

@ -558,9 +558,6 @@ Keyboard.prototype.onKeyDown = function(event, fDown)
if (sSoftCode) {
fPass = this.onSoftKeyDown(sSoftCode, fDown);
}
if (!fPass) {
event.preventDefault();
}
@ -582,14 +579,16 @@ Keyboard.prototype.onKeyDown = function(event, fDown)
Keyboard.prototype.onSoftKeyDown = function(sSoftCode, fDown)
{
if (fDown) {
// this.println(sSoftCode + " down");
this.keysPressed[sSoftCode] = Date.now();
delete this.keysToRelease[sSoftCode];
} else {
// this.println(sSoftCode + " up");
var msDown = this.keysPressed[sSoftCode];
this.assert(msDown);
if (msDown) {
var msElapsed = Date.now() - msDown;
if (msElapsed < Keyboard.MINPRESSTIME) {
// this.println(sSoftCode + " released after only " + msElapsed + "ms");
this.keysToRelease[sSoftCode] = msDown;
this.checkSoftKeysToRelease();
return true;
@ -637,7 +636,8 @@ Keyboard.prototype.checkSoftKeysToRelease = function()
{
var msDelayMin = -1;
var asSoftCodes = Object.keys(this.keysToRelease);
for (var sSoftCode in asSoftCodes) {
for (var i = 0; i < asSoftCodes.length; i++) {
var sSoftCode = asSoftCodes[i];
var msDown = this.keysToRelease[sSoftCode];
var msElapsed = Date.now() - msDown;
var msDelay = Keyboard.MINPRESSTIME - msElapsed;

View file

@ -100,9 +100,9 @@ var Jd={Oa:{Ia:130,tc:1,sc:2,rc:4,qc:8,uc:16,Vb:32,Dd:64,bd:128}},Kd={"1p":49,"2
Id.prototype.ma=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.K[e]){if("led"==a&&Md[b])return this.K[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return Nd(d,a,!0)},c.onkeyup=function(a){return Nd(d,a,!1)},!0;default:if(void 0!==Kd[b])return this.K[e]=c,a=function(a,b){return function(){Od(a,b,!0)}}(this,b),b=function(a,b){return function(){Od(a,b,!1)}}(this,b),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};
Id.prototype.Ma=function(a,b,c,d){this.G=d;this.C=nb(a,"ChipSet");this.Ga=this.C.Ga;switch(this.Ga){case zd.Da:this.w=Jd}this.w&&(yb(b,this,this.w.Jb),Cb(b,this,this.w.Kb))};Id.prototype.Ba=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};Id.prototype.Ha=function(a){return a?this.save():!0};Jd.Ua=[[0]];Id.prototype.reset=function(){this.u={};this.b={};this.w&&!this.restore(this.w.Ua)&&this.ca("reset error")};
Id.prototype.save=function(){var a=new I(this);switch(this.Ga){case zd.Da:J(a,0,[this.A])}return a.data()};Id.prototype.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.Ga){case V.Da:return!0;case zd.Da:return this.A=b[0],Pd(this),!0}return!1};function Pd(a){for(var b in Md){var c=a.K["led-"+b];if(c){var d=Md[b],e=!!(a.A&d);d&d-1&&(e=!(a.A&~d));c.style.backgroundColor=e?"#ff0000":"#000000"}}}
function Nd(a,b,c){var d=!0,e;a:{e=b.keyCode;e=Ld[e]||e;for(var f in Kd)if(Kd[f]===e){e=f;break a}e=null}e&&(d=Od(a,e,c));d||b.preventDefault();return d}
function Nd(a,b,c){var d=!0,e;a:{e=b.keyCode;e=Ld[e]||e;for(var f in Kd)if(Kd[f]===e){e=f;break a}e=null}e&&(d=Od(a,e,c),b.preventDefault());return d}
function Od(a,b,c){if(c)a.u[b]=Date.now(),delete a.b[b];else{var d=a.u[b];if(d&&100>Date.now()-d)return a.b[b]=d,Qd(a),!0;delete a.u[b]}if(a.C)switch(b){case "1p":Ad(a.C,V.Pa.vc,c);break;case "2p":Ad(a.C,V.Pa.zc,c);break;case "coin":Ad(a.C,V.Pa.pc,c);break;case "left":Ad(a.C,V.Pa.xc,c);break;case "right":Ad(a.C,V.Pa.yc,c);break;case "fire":Ad(a.C,V.Pa.wc,c)}return!0}
function Qd(a){var b=-1,c=Object.keys(a.b),d;for(d in c)if(c=100-(Date.now()-a.b[d]),0<c){if(0>b||b>c)b=c}else delete a.b[d],Od(a,d,!1);0<=b&&setTimeout(function(){Qd(a)},b)}Id.prototype.F=function(a,b,c){D(this,a,b,c,"KBDUART.STATUS",null);this.A=b;Pd(this)};Jd.Jb={};Jd.Kb={130:Id.prototype.F};Ha(function(){for(var a=C(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Id(d);ab(d,c)}});
function Qd(a){for(var b=-1,c=Object.keys(a.b),d=0;d<c.length;d++){var e=c[d],f=100-(Date.now()-a.b[e]);if(0<f){if(0>b||b>f)b=f}else delete a.b[e],Od(a,e,!1)}0<=b&&setTimeout(function(){Qd(a)},b)}Id.prototype.F=function(a,b,c){D(this,a,b,c,"KBDUART.STATUS",null);this.A=b;Pd(this)};Jd.Jb={};Jd.Kb={130:Id.prototype.F};Ha(function(){for(var a=C(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=A(c),d=new Id(d);ab(d,c)}});
function Rd(a,b,c,d,e){var f=this;this.dc=wa("Gecko/");var h=["","moz","ms","webkit"];z.call(this,"Video",a,Rd,262144);this.Y=a.screenWidth;this.W=a.screenHeight;this.wa=a.bufferAddr;this.Vc=a.bufferRAM;var g=a.bufferFormat;this.ha=g&&Sd[g.toLowerCase()]||Td;this.Ra=a.bufferCols;this.Fa=a.bufferRows;this.Sc=this.la=a.cellWidth||1;this.ea=a.cellHeight||1;this.ab=null;this.Qa=a.bufferBits||1;this.Wc=a.bufferLeft||0;if(this.F=a.bufferRotate)this.F=this.F%360,0<this.F&&(this.F-=360),-90!=this.F&&(this.ca("unsupported buffer rotation: "+
this.F),this.F=0);this.kc=a.interruptRate;this.Yc=a.refreshRate||60;this.T=b;this.H=c;this.ya=(this.Zc=d)||b||null;this.Tc=this.Y;this.Uc=this.W;this.Gb=this.Y/this.Ra|0;this.cc=this.W/this.Fa|0;1<this.ea&&this.Fa++;b=a.smoothing;(c=Pa.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.H[d]){this.H[d]=b;break}if(this.I=a.screenRotate)this.I=this.I%360,0<this.I&&(this.I-=360),-90!=this.I?(this.ca("unsupported screen rotation: "+
this.I),this.I=0):(this.H.translate(0,this.W),this.H.rotate(this.I*Math.PI/180),this.H.scale(this.W/this.Y,this.Y/this.W));if(this.w=e)if(this.w.cb=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.w.cb){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){Ud(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},!1);

View file

@ -90,9 +90,9 @@ var Z={ia:{ba:130,Hb:1,Gb:2,Fb:4,Eb:8,Ib:16,ib:32,Pc:64,oc:128}},lc={"1p":49,"2p
Y.prototype.R=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.w[e]){if("led"==a&&nc[b])return this.w[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return oc(d,a,!0)},c.onkeyup=function(a){return oc(d,a,!1)},!0;default:if(void 0!==lc[b])return this.w[e]=c,a=function(a,b){return function(){pc(a,b,!0)}}(this,b),b=function(a,b){return function(){pc(a,b,!1)}}(this,b),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};
Y.prototype.ha=function(a,b,c,d){this.K=d;this.D=Oa(a,"ChipSet");this.T=this.D.T;switch(this.T){case cc.X:this.b=Z}this.b&&(Za(b,this,this.b.Sa),$a(b,this,this.b.Ta))};Y.prototype.Y=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};Y.prototype.ea=function(a){return a?this.save():!0};Z.za=[[0]];Y.prototype.reset=function(){this.l={};this.a={};this.b&&!this.restore(this.b.za)&&this.I("reset error")};
Y.prototype.save=function(){var a=new I(this);switch(this.T){case cc.X:K(a,0,[this.c])}return a.data()};Y.prototype.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.T){case X.X:return!0;case cc.X:return this.c=b[0],qc(this),!0}return!1};function qc(a){for(var b in nc){var c=a.w["led-"+b];if(c){var d=nc[b],e=!!(a.c&d);d&d-1&&(e=!(a.c&~d));c.style.backgroundColor=e?"#ff0000":"#000000"}}}
function oc(a,b,c){var d=!0,e;a:{e=b.keyCode;e=mc[e]||e;for(var f in lc)if(lc[f]===e){e=f;break a}e=null}e&&(d=pc(a,e,c));d||b.preventDefault();return d}
function oc(a,b,c){var d=!0,e;a:{e=b.keyCode;e=mc[e]||e;for(var f in lc)if(lc[f]===e){e=f;break a}e=null}e&&(d=pc(a,e,c),b.preventDefault());return d}
function pc(a,b,c){if(c)a.l[b]=Date.now(),delete a.a[b];else{var d=a.l[b];if(d&&100>Date.now()-d)return a.a[b]=d,rc(a),!0;delete a.l[b]}if(a.D)switch(b){case "1p":dc(a.D,X.ja.Jb,c);break;case "2p":dc(a.D,X.ja.Nb,c);break;case "coin":dc(a.D,X.ja.Db,c);break;case "left":dc(a.D,X.ja.Lb,c);break;case "right":dc(a.D,X.ja.Mb,c);break;case "fire":dc(a.D,X.ja.Kb,c)}return!0}
function rc(a){var b=-1,c=Object.keys(a.a),d;for(d in c)if(c=100-(Date.now()-a.a[d]),0<c){if(0>b||b>c)b=c}else delete a.a[d],pc(a,d,!1);0<=b&&setTimeout(function(){rc(a)},b)}Y.prototype.f=function(a,b){this.c=b;qc(this)};Z.Sa={};Z.Ta={130:Y.prototype.f};ta(function(){for(var a=D(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=C(c),d=new Y(d);Ia(d,c)}});
function rc(a){for(var b=-1,c=Object.keys(a.a),d=0;d<c.length;d++){var e=c[d],f=100-(Date.now()-a.a[e]);if(0<f){if(0>b||b>f)b=f}else delete a.a[e],pc(a,e,!1)}0<=b&&setTimeout(function(){rc(a)},b)}Y.prototype.f=function(a,b){this.c=b;qc(this)};Z.Sa={};Z.Ta={130:Y.prototype.f};ta(function(){for(var a=D(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=C(c),d=new Y(d);Ia(d,c)}});
function sc(a,b,c,d,e){var f=this;this.lb=oa("Gecko/");var h=["","moz","ms","webkit"];u.call(this,"Video",a,sc);this.s=a.screenWidth;this.o=a.screenHeight;this.V=a.bufferAddr;this.Yb=a.bufferRAM;var g=a.bufferFormat;this.F=g&&tc[g.toLowerCase()]||vc;this.Ja=a.bufferCols;this.fa=a.bufferRows;this.Rb=this.M=a.cellWidth||1;this.J=a.cellHeight||1;this.Wa=null;this.oa=a.bufferBits||1;this.Zb=a.bufferLeft||0;if(this.c=a.bufferRotate)this.c=this.c%360,0<this.c&&(this.c-=360),-90!=this.c&&(this.I("unsupported buffer rotation: "+
this.c),this.c=0);this.ub=a.interruptRate;this.ac=a.refreshRate||60;this.m=b;this.f=c;this.$=(this.cc=d)||b||null;this.Sb=this.s;this.Tb=this.o;this.hb=this.s/this.Ja|0;this.kb=this.o/this.fa|0;1<this.J&&this.fa++;b=a.smoothing;(c=ya.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.f[d]){this.f[d]=b;break}if(this.g=a.screenRotate)this.g=this.g%360,0<this.g&&(this.g-=360),-90!=this.g?(this.I("unsupported screen rotation: "+
this.g),this.g=0):(this.f.translate(0,this.o),this.f.rotate(this.g*Math.PI/180),this.f.scale(this.o/this.s,this.s/this.o));if(this.b=e)if(this.b.qa=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.b.qa){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){wc(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},!1);