diff --git a/libs/core/buttons.cpp b/libs/core/buttons.cpp index 127b9f66..7b9ec0b1 100644 --- a/libs/core/buttons.cpp +++ b/libs/core/buttons.cpp @@ -96,15 +96,10 @@ class WButtons { */ //% block="button enter" weight=95 Button buttonEnter; - /** - * Exit button. - */ - //% block="button exit" weight=95 - Button buttonExit; WButtons() : buttonLeft(BUTTON_ID_LEFT), buttonRight(BUTTON_ID_RIGHT), buttonUp(BUTTON_ID_UP), - buttonDown(BUTTON_ID_DOWN), buttonEnter(BUTTON_ID_ENTER), buttonExit(BUTTON_ID_ESCAPE) { + buttonDown(BUTTON_ID_DOWN), buttonEnter(BUTTON_ID_ENTER) { pthread_t pid; pthread_create(&pid, NULL, buttonPoll, this); pthread_detach(pid); @@ -112,7 +107,7 @@ class WButtons { }; SINGLETON(WButtons); -const int LastButtonID = (Button *)&((WButtons *)0)->buttonExit - ((WButtons *)0)->buttons; +const int LastButtonID = (Button *)&((WButtons *)0)->buttonEnter - ((WButtons *)0)->buttons; extern "C" uint16_t readButtons(); @@ -124,6 +119,8 @@ void *buttonPoll(void *arg) { auto state = readButtons(); if (state == prevState) continue; + if (state & BUTTON_ID_ESCAPE) + exit(0); for (int i = 0; i < LastButtonID; ++i) { auto btn = &wb->buttons[i]; btn->setPressed(!!(state & btn->id)); diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 162ab44f..d27bc840 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -31,12 +31,6 @@ declare namespace input { */ //% block="button enter" weight=95 fixedInstance shim=pxt::getButton(4) const buttonEnter: Button; - - /** - * Exit button. - */ - //% block="button exit" weight=95 fixedInstance shim=pxt::getButton(5) - const buttonExit: Button; } declare namespace control {