Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

micro:bit sim - not firing all button events #2445

Closed
HelenFoster opened this issue Jul 13, 2017 · 3 comments
Closed

micro:bit sim - not firing all button events #2445

HelenFoster opened this issue Jul 13, 2017 · 3 comments

Comments

@HelenFoster
Copy link

HelenFoster commented Jul 13, 2017

I was looking for a "button down" event (to make games more responsive). It seemed like it should be possible with the Control blocks, but it's not on the list.

On further searching, MICROBIT_BUTTON_EVT_DOWN=1 gets fired. If I switch into JavaScript and write the number 1, it does actually work on the real micro:bit (though not on the simulator). This code moves the sprite to the left on A "pressed", and moves it to the right on B "button down".

let item: game.LedSprite = null
input.onButtonPressed(Button.A, () => {
    item.change(LedSpriteProperty.X, -1)
})
control.onEvent(EventBusSource.MICROBIT_ID_BUTTON_B, 1, () => {
    item.change(LedSpriteProperty.X, 1)
})
item = game.createSprite(2, 2)

There might be other really useful things that also haven't made it onto the list of values.

On the other hand, it's pretty long already, so if the menu could somehow tell which were relevant from the "from" field, that would be even better.

@riknoll
Copy link
Member

riknoll commented Jul 14, 2017

The simulator thing is definitely a bug. We probably skip a lot of runtime events that we should fire.

@HelenFoster
Copy link
Author

HelenFoster commented Jul 16, 2017

I put too many things in this ticket. If we say it's about simulator handling of button events:

MICROBIT_BUTTON_EVT_DOWN - not simulated
MICROBIT_BUTTON_EVT_UP - simulated
MICROBIT_BUTTON_EVT_CLICK - simulated, but takes LONG_CLICK as well (so in the simulator always fires at the same time as UP)
MICROBIT_BUTTON_EVT_LONG_CLICK - not simulated - becomes CLICK in simulator
MICROBIT_BUTTON_EVT_HOLD - not simulated
MICROBIT_BUTTON_EVT_DOUBLE_CLICK - doesn't seem to get fired on real micro:bit either

@lock
Copy link

lock bot commented Sep 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants