Merge pull request #1832 from ericrosenbaum/bugfix/makey-fixes

Makey Makey extension fixes
This commit is contained in:
Eric Rosenbaum 2018-12-10 10:17:10 -05:00 committed by GitHub
commit d2a6a0faa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,6 +86,9 @@ class Scratch3MakeyMakeyBlocks {
this.keyPressed = this.keyPressed.bind(this); this.keyPressed = this.keyPressed.bind(this);
this.runtime.on('KEY_PRESSED', this.keyPressed); this.runtime.on('KEY_PRESSED', this.keyPressed);
this._clearkeyPressBuffer = this._clearkeyPressBuffer.bind(this);
this.runtime.on('PROJECT_STOP_ALL', this._clearkeyPressBuffer);
/* /*
* An object containing a set of sequence objects. * An object containing a set of sequence objects.
* These are the key sequences currently being detected by the "when * These are the key sequences currently being detected by the "when
@ -155,7 +158,7 @@ class Scratch3MakeyMakeyBlocks {
`${KEY_ID_UP} ${KEY_ID_DOWN}`, `${KEY_ID_UP} ${KEY_ID_DOWN}`,
`${KEY_ID_DOWN} ${KEY_ID_UP}`, `${KEY_ID_DOWN} ${KEY_ID_UP}`,
`${KEY_ID_UP} ${KEY_ID_RIGHT} ${KEY_ID_DOWN} ${KEY_ID_LEFT}`, `${KEY_ID_UP} ${KEY_ID_RIGHT} ${KEY_ID_DOWN} ${KEY_ID_LEFT}`,
`${KEY_ID_SPACE} ${KEY_ID_SPACE} ${KEY_ID_SPACE}`, `${KEY_ID_UP} ${KEY_ID_LEFT} ${KEY_ID_DOWN} ${KEY_ID_RIGHT}`,
`${KEY_ID_UP} ${KEY_ID_UP} ${KEY_ID_DOWN} ${KEY_ID_DOWN} ` + `${KEY_ID_UP} ${KEY_ID_UP} ${KEY_ID_DOWN} ${KEY_ID_DOWN} ` +
`${KEY_ID_LEFT} ${KEY_ID_RIGHT} ${KEY_ID_LEFT} ${KEY_ID_RIGHT}` `${KEY_ID_LEFT} ${KEY_ID_RIGHT} ${KEY_ID_LEFT} ${KEY_ID_RIGHT}`
]; ];
@ -337,6 +340,13 @@ class Scratch3MakeyMakeyBlocks {
} }
} }
/**
* Clear the key press buffer.
*/
_clearkeyPressBuffer () {
this.keyPressBuffer = [];
}
/* /*
* Add a key sequence to the set currently being checked on each key press. * Add a key sequence to the set currently being checked on each key press.
* @param {string} sequenceString a string of space-separated KEY_IDs. * @param {string} sequenceString a string of space-separated KEY_IDs.