- btnp() i padp() consumeixen la tecla polsada si es la que arriba com a paràmetre

- anykey() tambe mira si s'ha pulsat algun botó del pad
- anykey() consumeix qualsevol tecla o botó del pad pulsats.
This commit is contained in:
2023-01-31 19:47:52 +01:00
parent 0e1e74a000
commit f457075c49

View File

@@ -903,11 +903,19 @@ int wbtnp() {
} }
bool btnp(uint8_t i) { 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() { 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) { bool pad(int8_t i) {
@@ -916,7 +924,12 @@ bool pad(int8_t i) {
} }
bool padp(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() { int wpad() {