From cb2f9b6177905db71e75cd9fd51016852aff248b Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Wed, 23 Dec 2020 17:43:54 +0000 Subject: [PATCH] Re-enable keyboard. Print a short message informing the user about game focus mode. Signed-off-by: Andrea Odetti --- linux.md | 6 ++++-- source/frontends/retro/environment.cpp | 8 ++++++++ source/frontends/retro/environment.h | 2 ++ source/frontends/retro/libretro.cpp | 9 +++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/linux.md b/linux.md index 07df0105..dca464da 100644 --- a/linux.md +++ b/linux.md @@ -68,7 +68,7 @@ Keyboard shortcuts * ``ALT-DOWN``: vertical hires (bigger) In order to properly appreciate the wider hi res graphics, open a big terminal window and choose a small font size. -Try ``CTRL-`` as well if ``ALT--` does not work: terminals do not report a consistent keycode for these combinations. +Try ``CTRL-`` as well if ``ALT-`` does not work: terminals do not report a consistent keycode for these combinations. The joystick uses evdev (currently the device name is hardcoded). @@ -95,7 +95,9 @@ See [sa2](source/frontends/sa2/README.md). There is an initial [libretro](https://docs.libretro.com/development/cores/developing-cores/) core. -Keyboard works, but a lot of keys overlap with RetroArch shortcuts. In the latest version the keyboard has been disabled and only the retro joypad works. +A retropad can be plugged in port 1 (with or without analog stick). + +In order to have a better experience with the keyboard, one should probably enable *Game Focus Mode* (normally Scroll-Lock) to disable hotkeys. Video works, but the vertical flip is done in software. diff --git a/source/frontends/retro/environment.cpp b/source/frontends/retro/environment.cpp index 16466c5a..eed3c702 100644 --- a/source/frontends/retro/environment.cpp +++ b/source/frontends/retro/environment.cpp @@ -24,3 +24,11 @@ retro_audio_sample_t audio_cb; retro_audio_sample_batch_t audio_batch_cb; std::string retro_base_directory; + +void display_message(const std::string & message) +{ + retro_message rmsg; + rmsg.frames = 180; + rmsg.msg = message.c_str(); + environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &rmsg); +} diff --git a/source/frontends/retro/environment.h b/source/frontends/retro/environment.h index 4810a98b..9232ecb0 100644 --- a/source/frontends/retro/environment.h +++ b/source/frontends/retro/environment.h @@ -13,3 +13,5 @@ extern retro_audio_sample_t audio_cb; extern retro_audio_sample_batch_t audio_batch_cb; extern std::string retro_base_directory; + +void display_message(const std::string & message); diff --git a/source/frontends/retro/libretro.cpp b/source/frontends/retro/libretro.cpp index 6f0770f3..e73e4aa4 100644 --- a/source/frontends/retro/libretro.cpp +++ b/source/frontends/retro/libretro.cpp @@ -115,8 +115,8 @@ void retro_set_environment(retro_environment_t cb) cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports); - // retro_keyboard_callback callback = {&Game::keyboardCallback}; - // cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &callback); + retro_keyboard_callback callback = {&Game::keyboardCallback}; + cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &callback); } void retro_set_audio_sample(retro_audio_sample_t cb) @@ -174,6 +174,11 @@ bool retro_load_game(const retro_game_info *info) log_cb(RETRO_LOG_INFO, "Game path: %s:%d\n", info->path, ok); + if (ok) + { + display_message("Enable Game Focus Mode for better keyboard handling"); + } + return ok; } catch (const std::exception & e)