Fixing #1364: Microbit 'button pressed?' block should return true/false.

This commit is contained in:
Evelyn Eastmond 2018-09-10 13:32:58 -04:00
parent cfe7e45d8b
commit 4b2b82a224

View file

@ -751,11 +751,11 @@ class Scratch3MicroBitBlocks {
*/ */
isButtonPressed (args) { isButtonPressed (args) {
if (args.BTN === 'any') { if (args.BTN === 'any') {
return this._peripheral.buttonA | this._peripheral.buttonB; return (this._peripheral.buttonA | this._peripheral.buttonB) === 1;
} else if (args.BTN === 'A') { } else if (args.BTN === 'A') {
return this._peripheral.buttonA; return this._peripheral.buttonA === 1;
} else if (args.BTN === 'B') { } else if (args.BTN === 'B') {
return this._peripheral.buttonB; return this._peripheral.buttonB === 1;
} }
return false; return false;
} }