summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-11-26 20:19:36 -0800
committerMichael Pavone <pavone@retrodev.com>2017-11-26 20:19:36 -0800
commitd064c9a6c6ea4aff356b5cde90f5afc92cb705f4 (patch)
treeefe7f33de90745c696a707ee02157f8d9fd5425b /io.c
parent4a9e985267f3c88b480f9f3b3d07e4a0c70716ae (diff)
Don't crash when keys are pressed before ROM is loaded
--HG-- branch : nuklear_ui
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/io.c b/io.c
index 9207093..24568d9 100644
--- a/io.c
+++ b/io.c
@@ -360,6 +360,9 @@ void store_key_event(uint16_t code)
void handle_keydown(int keycode, uint8_t scancode)
{
+ if (!current_io) {
+ return;
+ }
int bucket = keycode >> 15 & 0xFFFF;
int idx = keycode & 0x7FFF;
keybinding * binding = bindings[bucket] ? bindings[bucket] + idx : NULL;
@@ -564,6 +567,9 @@ void handle_binding_up(keybinding * binding)
void handle_keyup(int keycode, uint8_t scancode)
{
+ if (!current_io) {
+ return;
+ }
int bucket = keycode >> 15 & 0xFFFF;
int idx = keycode & 0x7FFF;
keybinding * binding = bindings[bucket] ? bindings[bucket] + idx : NULL;