From d064c9a6c6ea4aff356b5cde90f5afc92cb705f4 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 26 Nov 2017 20:19:36 -0800 Subject: Don't crash when keys are pressed before ROM is loaded --HG-- branch : nuklear_ui --- io.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- cgit v1.2.3