gba icon indicating copy to clipboard operation
gba copied to clipboard

Friendly interface for key inputs

Open davidhollis opened this issue 3 years ago • 1 comments

👋 Hello! I'm relatively new to Rust and gradually refreshing my memory of GBA programming (it's been about a decade!). I've been messing around with this library and thought I might contribute back some of the key input abstractions I wrote if this is the sort of thing you're looking for.

This branch adds:

  • A typed Keys::read() function to eliminate the need for .into()s (closes #130)
  • An .update() method to update a Keys in place
  • A Key enum with BitOr impls so you can do things like if keys.any_pressed(Key::A | Key::B) { ... }
  • A type for keeping track of key inputs across 2 frames. I called this KeyMonitor, but I'm definitely open to other thoughts on naming—I don't like calling something a "monitor" when it has to be manually updated, but I also didn't have a better idea.

davidhollis avatar Jan 18 '22 04:01 davidhollis

Having the keys value update itself in place seems strange to me, but I guess it's not strictly wrong.

Otherwise, things seem basically okay so far, but probably there should be a doc comment on anything that isn't just a getter

Lokathor avatar Jan 18 '22 14:01 Lokathor

The KeyInput type is now naturally storing the low-active data, so key data should naturally be much easier to work with. I'll close this.

Lokathor avatar Nov 16 '23 19:11 Lokathor