diff --git a/gdlibretro/src/Input.cpp b/gdlibretro/src/Input.cpp index caf1e6d..37ee94c 100644 --- a/gdlibretro/src/Input.cpp +++ b/gdlibretro/src/Input.cpp @@ -53,9 +53,12 @@ void RetroHost::forwarded_input( const godot::Ref &event ) if(retro_key > RETROK_LAST) return; - this->core.retro_keyboard_event_callback( key_event->is_pressed(), retro_key, - 0, modifiers ); - + if (this->core.retro_keyboard_event_callback) { + this->core.retro_keyboard_event_callback(key_event->is_pressed(), retro_key, 0, modifiers); + } else { + godot::UtilityFunctions::printerr("[RetroHost] retro_keyboard_event_callback is not set."); + } + keyboard_state[retro_key] = key_event->is_pressed(); } } \ No newline at end of file diff --git a/gdlibretro/src/RetroHost.cpp b/gdlibretro/src/RetroHost.cpp index 6a77847..5dd7444 100644 --- a/gdlibretro/src/RetroHost.cpp +++ b/gdlibretro/src/RetroHost.cpp @@ -141,6 +141,7 @@ bool RetroHost::load_core(godot::String name) load_symbol_return_false_on_err(this->core.handle, this->core.retro_run, retro_run); load_symbol_return_false_on_err(this->core.handle, this->core.retro_load_game, retro_load_game); load_symbol_return_false_on_err(this->core.handle, this->core.retro_unload_game, retro_unload_game); + load_symbol_return_false_on_err(this->core.handle, this->core.retro_keyboard_event_callback, retro_keyboard_event_callback); godot::UtilityFunctions::print("[RetroHost] All symbols loaded successfully."); diff --git a/gdlibretro/src/RetroHost.hpp b/gdlibretro/src/RetroHost.hpp index 414ad9b..3834f8c 100644 --- a/gdlibretro/src/RetroHost.hpp +++ b/gdlibretro/src/RetroHost.hpp @@ -116,7 +116,7 @@ private: bool (*retro_load_game)(const struct retro_game_info *game); void (*retro_unload_game)(void); - retro_keyboard_event_t retro_keyboard_event_callback; + retro_keyboard_event_t retro_keyboard_event_callback = nullptr; } core; protected: