more button info

This commit is contained in:
Lokathor 2018-12-24 11:57:57 -07:00
parent 7d8c82ddbc
commit ce3b871728
2 changed files with 18 additions and 1 deletions

View file

@ -63,6 +63,23 @@ the whole frame. If you've worked with polling input before that should sound
totally normal, but if not just always remember to gather the input once per
frame and then use that value across the whole frame.
### Detecting New Presses
The keypad only tells you what's _currently_ pressed, but if you want to check
what's _newly_ pressed it's not too much harder.
All that you do is store the last frame's keys and compare them to the current
keys with an `XOR`. In the `gba` crate it's called `KeyInput::difference`. Once
you've got the difference between last frame and this frame, you know what
changes happened.
* If something is in the difference and _not pressed_ in the last frame, that
means it was newly pressed.
* If something is in the difference and _pressed_ in the last frame that means
it was newly released.
* If something is not in the difference then there's no change between last
frame and this frame.
## Key Interrupt Control
* KEYCNT, `0x400_0132`, `u16`, read/write

View file

@ -85,7 +85,7 @@ pub fn display_control() -> DisplayControlSetting {
/// If the `VCOUNT` register reads equal to or above this then you're in vblank.
pub const VBLANK_SCANLINE: u16 = 160;
/// Vertical Counter (LY).
/// Vertical Counter (LY). Read only.
///
/// Gives the current scanline that the display controller is working on. If
/// this is at or above the `VBLANK_SCANLINE` value then the display controller