Invalid keycodes also return 0 (but print a msg in DEBUG).

This commit is contained in:
Nicolás Ortega Froysa 2018-03-25 15:34:53 +02:00
parent d871bcec41
commit fa9a35444b
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
2 changed files with 7 additions and 3 deletions

View File

@ -135,7 +135,12 @@ void handle_event() {
int key_is_down(int code) { int key_is_down(int code) {
if(code < 0 || code >= KEY_MAX) if(code < 0 || code >= KEY_MAX)
return -1; {
#ifdef DEBUG
fprintf(stderr, "key_is_down(int): bad key code!\n");
#endif
return 0;
}
else else
return keys[code]; return keys[code];
} }

View File

@ -53,7 +53,6 @@ void handle_event();
* *
* @param code The key code. * @param code The key code.
* *
* @return If down 1 will be returned, if the keycode is * @return If down 1 will be returned, else 0.
* invalid then -1 is returned, else 0.
*/ */
int key_is_down(int code); int key_is_down(int code);