diff --git a/sim/state/misc.ts b/sim/state/misc.ts index f1e93664..a5d39e40 100644 --- a/sim/state/misc.ts +++ b/sim/state/misc.ts @@ -62,6 +62,13 @@ namespace pxsim.control { } export function onEvent(id: number, evid: number, handler: RefAction) { + if (id == DAL.MICROBIT_ID_BUTTON_AB) { + const b = board().buttonPairState; + if (!b.usesButtonAB) { + b.usesButtonAB = true; + runtime.queueDisplayUpdate(); + } + } pxtcore.registerWithDal(id, evid, handler) } diff --git a/sim/visuals/microbit.ts b/sim/visuals/microbit.ts index 8eb6f70b..eb090eaa 100644 --- a/sim/visuals/microbit.ts +++ b/sim/visuals/microbit.ts @@ -966,6 +966,7 @@ path.sim-board { let state = this.board; state.edgeConnectorState.pins[index].touched = true; this.updatePin(state.edgeConnectorState.pins[index], index); + this.board.bus.queue(state.edgeConnectorState.pins[index].id, DAL.MICROBIT_BUTTON_EVT_DOWN); })); btn.addEventListener(pointerEvents.leave, ev => { let state = this.board; @@ -981,6 +982,7 @@ path.sim-board { }) accessibility.enableKeyboardInteraction(btn, undefined, () => { let state = this.board; + this.board.bus.queue(state.edgeConnectorState.pins[index].id, DAL.MICROBIT_BUTTON_EVT_DOWN); this.board.bus.queue(state.edgeConnectorState.pins[index].id, DAL.MICROBIT_BUTTON_EVT_UP); this.board.bus.queue(state.edgeConnectorState.pins[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK); }); @@ -993,6 +995,7 @@ path.sim-board { let state = this.board; stateButtons[index].pressed = true; svg.fill(this.buttons[index], this.props.theme.buttonDown); + this.board.bus.queue(stateButtons[index].id, DAL.MICROBIT_BUTTON_EVT_DOWN); })); btn.addEventListener(pointerEvents.leave, ev => { let state = this.board; @@ -1007,6 +1010,7 @@ path.sim-board { this.board.bus.queue(stateButtons[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK); }) accessibility.enableKeyboardInteraction(btn, undefined, () => { + this.board.bus.queue(stateButtons[index].id, DAL.MICROBIT_BUTTON_EVT_DOWN); this.board.bus.queue(stateButtons[index].id, DAL.MICROBIT_BUTTON_EVT_UP); this.board.bus.queue(stateButtons[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK); }); @@ -1019,6 +1023,7 @@ path.sim-board { svg.fill(this.buttons[0], this.props.theme.buttonDown); svg.fill(this.buttons[1], this.props.theme.buttonDown); svg.fill(this.buttons[2], this.props.theme.buttonDown); + this.board.bus.queue(stateButtons[2].id, DAL.MICROBIT_BUTTON_EVT_DOWN); })); this.buttonsOuter[2].addEventListener(pointerEvents.leave, ev => { let state = this.board; @@ -1042,6 +1047,7 @@ path.sim-board { this.board.bus.queue(stateButtons[2].id, DAL.MICROBIT_BUTTON_EVT_CLICK); }) accessibility.enableKeyboardInteraction(this.buttonsOuter[2], undefined, () => { + this.board.bus.queue(stateButtons[2].id, DAL.MICROBIT_BUTTON_EVT_DOWN); this.board.bus.queue(stateButtons[2].id, DAL.MICROBIT_BUTTON_EVT_UP); this.board.bus.queue(stateButtons[2].id, DAL.MICROBIT_BUTTON_EVT_CLICK); });