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

Improve button handling in the API #63

Closed
lenardg opened this issue Jan 13, 2020 · 2 comments
Closed

Improve button handling in the API #63

lenardg opened this issue Jan 13, 2020 · 2 comments
Assignees

Comments

@lenardg
Copy link
Contributor

lenardg commented Jan 13, 2020

Currently the API provides us with button statuses only (is it pressed or is it released). The demo game scrolly-tile does some bitfield magic to keep track of what is actually done with the buttons - and not just if it is held or not.

Relevant code:

	uint16_t changed = blit::buttons ^ last_buttons;
	uint16_t pressed = changed & blit::buttons;
	uint16_t released = changed & ~blit::buttons;

It would be great if this same functionality would be part of the engine.

Instead of just blit::buttons it could be a struct of some kind, where you would have three members:

  • status - to check the status of a single button, like what blit::buttons is now.
  • pressed - that would tell which button was pressed since last time
  • released - that would tell which button was released since last time

ALthough it might be a little bit long to write, it would increase clarity.

For example: if ( blit::buttons::pressed & blit::button::A )

@ali1234
Copy link
Contributor

ali1234 commented Jan 15, 2020

You can avoid the complement operation:

uint16_t released = changed & last_buttons;

@Daft-Freak
Copy link
Collaborator

I think I did (quite close to) this in #310?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants