From f457075c49ed22a95dae102f371a342c40fb8a10 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Tue, 31 Jan 2023 19:47:52 +0100 Subject: [PATCH] =?UTF-8?q?-=20btnp()=20i=20padp()=20consumeixen=20la=20te?= =?UTF-8?q?cla=20polsada=20si=20es=20la=20que=20arriba=20com=20a=20par?= =?UTF-8?q?=C3=A0metre=20-=20anykey()=20tambe=20mira=20si=20s'ha=20pulsat?= =?UTF-8?q?=20algun=20bot=C3=B3=20del=20pad=20-=20anykey()=20consumeix=20q?= =?UTF-8?q?ualsevol=20tecla=20o=20bot=C3=B3=20del=20pad=20pulsats.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mini.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mini.cpp b/mini.cpp index 768179c..896c501 100644 --- a/mini.cpp +++ b/mini.cpp @@ -903,11 +903,19 @@ int wbtnp() { } bool btnp(uint8_t i) { - return key_just_pressed == i; + if (key_just_pressed == i) { + key_just_pressed=0; + return true; + } else { + return false; + } } bool anykey() { - return key_just_pressed != 0; + const bool something_pressed = (key_just_pressed != 0) || (pad_just_pressed != -1); + key_just_pressed=0; + pad_just_pressed=-1; + return something_pressed; } bool pad(int8_t i) { @@ -916,7 +924,12 @@ bool pad(int8_t i) { } bool padp(int8_t i) { - return pad_just_pressed == i; + if (pad_just_pressed == i) { + pad_just_pressed=-1; + return true; + } else { + return false; + } } int wpad() {