From 12d6894be19471f1d52184abbf8660f20b96d8f1 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Thu, 12 Nov 2026 23:42:10 -0600 Subject: [PATCH 1/7] Launcher: console filter and quick console navigation - Left / right on the game list jump to the previous / next console (the game buttons take left / right as keys: LV_OBJ_FLAG_USER_1 in Tab5Emu::keypad_read()). - The console above the boxart opens a console picker (tap it, X on a gamepad, F on a keyboard): all consoles, or only one console's games. The console is outlined while the list is filtered, and left / right then move the filter. Launching a game the filter hides lifts it. - The selected game is highlighted in the list (the theme has no checked style for list buttons, so it was not). - USB link (protocol 3, same remote_control.hpp / emulink as the box): CONSOLE_FILTER, the filter in STATUS, launcher screenshots. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- README.md | 8 + components/gui/include/gui.hpp | 32 +++- components/gui/src/gui.cpp | 268 ++++++++++++++++++++++++++- components/tab5-emu/src/tab5-emu.cpp | 6 +- main/remote_control.hpp | 77 ++++++-- tools/emulink/emulink/cli.py | 12 +- tools/emulink/emulink/control.py | 15 +- 7 files changed, 388 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 74777fa..69baf79 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,14 @@ DualShock numbering, Backbone Pro quirks. Keyboards: arrows, Z/X/A/S, Enter, Shift/Backspace, Q/W (L/R) and E/R (L2/R2) map to the gamepad for the emulators. +In the launcher, left / right on the game list go to the previous / next +console's games. Tapping the console above the boxart (or X on a gamepad, F +on a keyboard) opens the console picker, which shows only one console's +games, or all of them again; an outline on the console means the list is +filtered, and left / right then move the filter to the next console. +`emulink filter ` (snes, gba, genesis, playstation, pc, pico8 or +all) does the same over USB. + Jedi Knight gets the full keyboard and mouse look; on a gamepad the left stick strafes, the right stick looks, R = fire, L = secondary fire, A = activate, B = jump, X = crouch, Y = use item. diff --git a/components/gui/include/gui.hpp b/components/gui/include/gui.hpp index a76251f..7fef744 100644 --- a/components/gui/include/gui.hpp +++ b/components/gui/include/gui.hpp @@ -64,14 +64,36 @@ class Gui { return rom_infos_; } - /// Select the first game whose name or rom path contains `text` + /// Select the first game whose name or rom path contains `text` (a game + /// the console filter hides lifts the filter) bool select_rom_matching(std::string_view text); + /// The consoles that have games, in list order. + std::vector consoles() const; + /// The console whose games the list shows, if it is filtered. + std::optional console_filter() const; + /// Show only `console`'s games (nullopt: every console's); false if it has none. + bool set_console_filter(std::optional console); + + /// The launcher screen (RGB565, little endian, rows packed), for the USB + /// link's screenshot when no game runs; empty if it cannot be drawn. + struct Snapshot { + size_t width{0}, height{0}; + std::vector pixels; + }; + Snapshot snapshot(); + protected: void init_ui(); void deinit_ui(); void update_shared_state(); void select_rom(int index); + void build_list(int keep_rom); + void step_console(int dir); + void update_filter_marker(); + void open_console_picker(); + void close_console_picker(); + static void picker_event(lv_event_t *e); void update(); void on_volume(const std::vector &data); @@ -108,7 +130,13 @@ class Gui { lv_obj_t *video_dropdown_{nullptr}; lv_obj_t *resume_switch_{nullptr}; lv_obj_t *battery_label_{nullptr}; - std::vector rom_buttons_; + std::vector rom_buttons_; ///< per game (rom_infos_ index); nullptr if filtered out + + // the console filter: the Console whose games the list shows, -1 all + int filter_{-1}; + lv_obj_t *picker_{nullptr}; ///< the console picker, while it is open + lv_group_t *picker_group_{nullptr}; + std::vector picker_consoles_; ///< the picker's rows: Console, -1 all std::string metadata_filename_; std::filesystem::file_time_type metadata_last_modified_{}; diff --git a/components/gui/src/gui.cpp b/components/gui/src/gui.cpp index f453e6a..54687b1 100644 --- a/components/gui/src/gui.cpp +++ b/components/gui/src/gui.cpp @@ -17,7 +17,7 @@ Gui::Gui(const Config &config) // the same after a game) if (auto *keypad = Tab5Emu::get().keypad_indev(); keypad && group_) { lv_indev_set_group(keypad, group_); - if (focused_rom_ >= 0 && focused_rom_ < (int)rom_buttons_.size()) { + if (focused_rom_ >= 0 && focused_rom_ < (int)rom_buttons_.size() && rom_buttons_[focused_rom_]) { lv_group_focus_obj(rom_buttons_[focused_rom_]); } logger_.info("keypad group attached: {} objects, focused rom {}, focused obj {}", lv_group_get_obj_count(group_), @@ -53,7 +53,7 @@ void Gui::resume() { lv_obj_invalidate(screen_); if (auto *keypad = Tab5Emu::get().keypad_indev(); keypad && group_) { lv_indev_set_group(keypad, group_); - if (focused_rom_ >= 0 && focused_rom_ < (int)rom_buttons_.size()) { + if (focused_rom_ >= 0 && focused_rom_ < (int)rom_buttons_.size() && rom_buttons_[focused_rom_]) { lv_group_focus_obj(rom_buttons_[focused_rom_]); } logger_.info("keypad group attached: {} objects, focused rom {}, focused obj {}", lv_group_get_obj_count(group_), @@ -146,6 +146,13 @@ void Gui::init_ui() { console_area_ = lv_obj_create(screen_); lv_obj_remove_style_all(console_area_); lv_obj_remove_flag(console_area_, LV_OBJ_FLAG_SCROLLABLE); + // a tap on it opens the console picker (so does X on a gamepad, F on a keyboard) + lv_obj_add_flag(console_area_, LV_OBJ_FLAG_CLICKABLE); + lv_obj_add_flag(console_area_, LV_OBJ_FLAG_OVERFLOW_VISIBLE); // (the filter outline) + lv_obj_add_event_cb(console_area_, [](lv_event_t *e) { + static_cast(lv_event_get_user_data(e))->open_console_picker(); + }, LV_EVENT_CLICKED, this); + lv_obj_set_size(console_area_, 400, 56); lv_obj_align(console_area_, LV_ALIGN_TOP_MID, 40, 76); lv_obj_set_flex_flow(console_area_, LV_FLEX_FLOW_ROW); @@ -268,24 +275,55 @@ void Gui::update_rom_list() { break; } } + build_list(focused_rom_); +} + +// The game list: the games that pass the console filter, under a header per +// console; `keep_rom` stays selected if it is shown, else the first game. +void Gui::build_list(int keep_rom) { + std::lock_guard lk(mutex_); + // a filter for a console that is no longer on the card shows them all + if (filter_ >= 0 && std::none_of(rom_infos_.begin(), rom_infos_.end(), [this](const RomInfo &r) { + return static_cast(console_of(r.platform)) == filter_; + })) { + filter_ = -1; + } + auto shown = [this](size_t i) { + return filter_ < 0 || static_cast(console_of(rom_infos_[i].platform)) == filter_; + }; + if (keep_rom < 0 || keep_rom >= (int)rom_infos_.size() || !shown(keep_rom)) { + keep_rom = -1; + for (size_t i = 0; i < rom_infos_.size() && keep_rom < 0; i++) { + if (shown(i)) keep_rom = i; + } + } // (adding the first button to the empty group focuses it, and its FOCUSED - // event selects game 0: keep the one to select) - const int keep_rom = focused_rom_; + // event selects that game: keep_rom is selected at the end) lv_obj_clean(rom_list_); - rom_buttons_.clear(); + rom_buttons_.assign(rom_infos_.size(), nullptr); if (group_) { lv_group_remove_all_objs(group_); } + int last_console = -1; for (size_t i = 0; i < rom_infos_.size(); i++) { + if (!shown(i)) continue; const Console console = console_of(rom_infos_[i].platform); - if (i == 0 || console != console_of(rom_infos_[i - 1].platform)) { + if (static_cast(console) != last_console) { + last_console = static_cast(console); add_console_header(console); } auto btn = lv_list_add_button(rom_list_, nullptr, rom_infos_[i].name.c_str()); lv_obj_set_user_data(btn, reinterpret_cast(i)); lv_obj_add_event_cb(btn, event_callback, LV_EVENT_CLICKED, this); lv_obj_add_event_cb(btn, event_callback, LV_EVENT_FOCUSED, this); - rom_buttons_.push_back(btn); + lv_obj_add_event_cb(btn, event_callback, LV_EVENT_KEY, this); + // left / right come to the game as keys (not focus moves): they change + // the console (see Tab5Emu::keypad_read()) + lv_obj_add_flag(btn, LV_OBJ_FLAG_USER_1); + // the selected game (the theme has no checked look for list buttons) + lv_obj_set_style_bg_color(btn, lv_palette_main(LV_PALETTE_BLUE), LV_STATE_CHECKED); + lv_obj_set_style_bg_opa(btn, LV_OPA_COVER, LV_STATE_CHECKED); + rom_buttons_[i] = btn; if (group_) lv_group_add_obj(group_, btn); } if (group_) { @@ -294,7 +332,8 @@ void Gui::update_rom_list() { if (o) lv_group_add_obj(group_, o); } } - if (rom_infos_.empty()) { + update_filter_marker(); + if (keep_rom < 0) { lv_list_add_text(rom_list_, "No games found.\nAdd metadata.csv to the SD card."); focused_rom_ = -1; lv_label_set_text(title_label_, ""); @@ -302,8 +341,198 @@ void Gui::update_rom_list() { lv_obj_clean(console_area_); shown_console_ = -1; } else { - select_rom(std::clamp(keep_rom, 0, rom_infos_.size() - 1)); + select_rom(keep_rom); + } +} + +std::vector Gui::consoles() const { + std::lock_guard lk(mutex_); + std::vector out; + for (const auto &r : rom_infos_) { + const Console c = console_of(r.platform); + if (out.empty() || out.back() != c) out.push_back(c); // (grouped by console) + } + return out; +} + +std::optional Gui::console_filter() const { + std::lock_guard lk(mutex_); + if (filter_ < 0) return std::nullopt; + return static_cast(filter_); +} + +bool Gui::set_console_filter(std::optional console) { + std::lock_guard lk(mutex_); + const auto present = consoles(); + if (console && std::find(present.begin(), present.end(), *console) == present.end()) { + return false; // no games for it + } + filter_ = console ? static_cast(*console) : -1; + build_list(focused_rom_); // (the selected game stays if the filter shows it) + return true; +} + +// Left / right: the previous / next console's first game; with a filter on, +// the filter moves to that console. +void Gui::step_console(int dir) { + std::lock_guard lk(mutex_); + const auto present = consoles(); + if (present.size() < 2 || focused_rom_ < 0 || focused_rom_ >= (int)rom_infos_.size()) { + return; + } + const Console current = console_of(rom_infos_[focused_rom_].platform); + const int n = present.size(); + const int at = std::find(present.begin(), present.end(), current) - present.begin(); + const Console next = present[(at + (dir < 0 ? n - 1 : 1)) % n]; + if (filter_ >= 0) { + set_console_filter(next); + return; + } + for (size_t i = 0; i < rom_infos_.size(); i++) { + if (console_of(rom_infos_[i].platform) == next) { + select_rom(i); + if (rom_buttons_[i]) lv_obj_scroll_to_view(rom_buttons_[i], LV_ANIM_ON); + return; + } + } +} + +// With a filter on, the console above the boxart is outlined (the area is also the +// button that opens the console picker). +void Gui::update_filter_marker() { + if (!console_area_) return; + // (on the badge / art itself, which is narrower than the area) + if (auto *shown = lv_obj_get_child(console_area_, 0)) { + lv_obj_set_style_outline_color(shown, lv_color_white(), 0); + lv_obj_set_style_outline_pad(shown, 3, 0); + lv_obj_set_style_outline_width(shown, filter_ >= 0 ? 3 : 0, 0); + } +} + +// The console picker: "All consoles" and each console on the card with its +// number of games, over the launcher. A tap / A picks one, B or a tap beside +// the list closes it. +void Gui::open_console_picker() { + std::lock_guard lk(mutex_); + if (picker_) { + return; + } + const auto present = consoles(); + picker_ = lv_obj_create(screen_); + lv_obj_remove_style_all(picker_); + lv_obj_set_size(picker_, lv_pct(100), lv_pct(100)); + lv_obj_set_style_bg_color(picker_, lv_color_black(), 0); + lv_obj_set_style_bg_opa(picker_, LV_OPA_60, 0); + lv_obj_add_flag(picker_, LV_OBJ_FLAG_CLICKABLE); + lv_obj_add_event_cb(picker_, picker_event, LV_EVENT_CLICKED, this); + + auto *list = lv_list_create(picker_); + lv_obj_set_size(list, 480, LV_SIZE_CONTENT); + lv_obj_set_style_max_height(list, Tab5Emu::lcd_height() - 120, 0); + lv_obj_center(list); + lv_obj_set_style_text_font(list, &lv_font_montserrat_24, 0); + lv_list_add_text(list, "Show games for"); + + picker_group_ = lv_group_create(); + lv_group_set_wrap(picker_group_, true); + picker_consoles_.clear(); + lv_obj_t *focus = nullptr; + auto add = [&](int console, const std::string &text) { + auto *btn = lv_list_add_button(list, console < 0 ? LV_SYMBOL_LIST : nullptr, text.c_str()); + lv_obj_set_height(btn, 64); + if (console >= 0) { + auto *icon = console_icon_create(btn, console_info(static_cast(console)), 32); + lv_obj_move_to_index(icon, 0); + } + if (console == filter_) lv_obj_add_state(btn, LV_STATE_CHECKED); + lv_obj_set_user_data(btn, reinterpret_cast(static_cast(picker_consoles_.size()))); + lv_obj_add_event_cb(btn, picker_event, LV_EVENT_CLICKED, this); + lv_obj_add_event_cb(btn, picker_event, LV_EVENT_KEY, this); + lv_group_add_obj(picker_group_, btn); + picker_consoles_.push_back(console); + if (console == filter_) focus = btn; + }; + add(-1, fmt::format("All consoles ({})", rom_infos_.size())); + for (const Console c : present) { + const auto n = std::count_if(rom_infos_.begin(), rom_infos_.end(), + [c](const RomInfo &r) { return console_of(r.platform) == c; }); + add(static_cast(c), fmt::format("{} ({})", console_info(c).name, n)); + } + if (focus) lv_group_focus_obj(focus); + if (auto *keypad = Tab5Emu::get().keypad_indev()) lv_indev_set_group(keypad, picker_group_); +} + +void Gui::close_console_picker() { + std::lock_guard lk(mutex_); + if (!picker_) { + return; + } + // (out of the group before the group goes; the objects go after this event) + lv_group_remove_all_objs(picker_group_); + lv_group_delete(picker_group_); + picker_group_ = nullptr; + lv_obj_delete_async(picker_); + picker_ = nullptr; + if (auto *keypad = Tab5Emu::get().keypad_indev(); keypad && group_) { + lv_indev_set_group(keypad, group_); + if (focused_rom_ >= 0 && focused_rom_ < (int)rom_buttons_.size() && rom_buttons_[focused_rom_]) { + lv_group_focus_obj(rom_buttons_[focused_rom_]); + } + } +} + +void Gui::picker_event(lv_event_t *e) { + auto *gui = static_cast(lv_event_get_user_data(e)); + if (!gui || !gui->picker_) { + return; + } + auto *target = static_cast(lv_event_get_target(e)); + const auto code = lv_event_get_code(e); + if (code == LV_EVENT_KEY) { + const auto key = lv_indev_get_key(lv_indev_active()); + if (key == LV_KEY_ESC || key == LV_KEY_HOME) gui->close_console_picker(); + return; + } + if (target == gui->picker_) { + gui->close_console_picker(); // a tap beside the list + return; + } + const auto index = reinterpret_cast(lv_obj_get_user_data(target)); + if (index >= 0 && index < (intptr_t)gui->picker_consoles_.size()) { + const int console = gui->picker_consoles_[index]; + gui->close_console_picker(); + gui->set_console_filter(console < 0 ? std::nullopt : std::optional(static_cast(console))); + } +} + +Gui::Snapshot Gui::snapshot() { + std::lock_guard lk(mutex_); + Snapshot shot; + auto *screen = lv_screen_active(); + if (!screen) { + return shot; + } + lv_obj_update_layout(screen); + const int32_t w = lv_obj_get_width(screen), h = lv_obj_get_height(screen); + const uint32_t stride = lv_draw_buf_width_to_stride(w, LV_COLOR_FORMAT_RGB565); + shot.pixels.resize(stride * h); + lv_draw_buf_t buf; + if (lv_draw_buf_init(&buf, w, h, LV_COLOR_FORMAT_RGB565, stride, shot.pixels.data(), shot.pixels.size()) != + LV_RESULT_OK || + lv_snapshot_take_to_draw_buf(screen, LV_COLOR_FORMAT_RGB565, &buf) != LV_RESULT_OK) { + shot.pixels.clear(); + return shot; + } + // (rows packed: the reader expects w * 2 bytes per row) + if (stride != static_cast(w) * 2) { + for (int32_t y = 1; y < h; y++) { + memmove(shot.pixels.data() + y * w * 2, shot.pixels.data() + y * stride, w * 2); + } + shot.pixels.resize(w * h * 2); } + shot.width = w; + shot.height = h; + return shot; } // A non-selectable row in the game list starting a console's group: the @@ -349,10 +578,12 @@ void Gui::show_console(Console console) { lv_obj_set_size(img, lv_pct(100), lv_pct(100)); lv_image_set_inner_align(img, LV_IMAGE_ALIGN_CONTAIN); lv_image_set_src(img, console_art_buf_); + update_filter_marker(); return; } } console_badge_create(console_area_, info, 48, &lv_font_montserrat_24); + update_filter_marker(); } bool Gui::select_rom_matching(std::string_view text) { @@ -364,6 +595,11 @@ bool Gui::select_rom_matching(std::string_view text) { const auto &rom = rom_infos_[i]; if (exact ? (rom.rom_path == text || rom.name == text) : (rom.name.find(text) != std::string::npos || rom.rom_path.find(text) != std::string::npos)) { + // a game the console filter hides: show them all + if (filter_ >= 0 && static_cast(console_of(rom.platform)) != filter_) { + filter_ = -1; + build_list(i); + } select_rom(i); return true; } @@ -379,13 +615,15 @@ void Gui::select_rom(int index) { } focused_rom_ = index; for (size_t i = 0; i < rom_buttons_.size(); i++) { + if (!rom_buttons_[i]) continue; // (hidden by the console filter) if ((int)i == index) lv_obj_add_state(rom_buttons_[i], LV_STATE_CHECKED); else lv_obj_remove_state(rom_buttons_[i], LV_STATE_CHECKED); } // keep the keypad focus (and its highlight) on the selected game too - if (group_ && index < (int)rom_buttons_.size() && lv_group_get_focused(group_) != rom_buttons_[index]) { + if (group_ && index < (int)rom_buttons_.size() && rom_buttons_[index] && + lv_group_get_focused(group_) != rom_buttons_[index]) { lv_group_focus_obj(rom_buttons_[index]); } const auto &rom = rom_infos_[index]; @@ -464,6 +702,16 @@ void Gui::event_callback(lv_event_t *e) { auto target = static_cast(lv_event_get_target(e)); auto code = lv_event_get_code(e); auto &emu = Tab5Emu::get(); + if (code == LV_EVENT_KEY) { + // on a game: left / right change the console, X (home) opens the picker + const auto key = lv_indev_get_key(lv_indev_active()); + if (key == LV_KEY_LEFT || key == LV_KEY_RIGHT) { + gui->step_console(key == LV_KEY_LEFT ? -1 : 1); + } else if (key == LV_KEY_HOME) { + gui->open_console_picker(); + } + return; + } if (code == LV_EVENT_FOCUSED) { // gamepad / keyboard: moving the focus through the list selects the game for (size_t i = 0; i < gui->rom_buttons_.size(); i++) { diff --git a/components/tab5-emu/src/tab5-emu.cpp b/components/tab5-emu/src/tab5-emu.cpp index d50243a..b8ad249 100644 --- a/components/tab5-emu/src/tab5-emu.cpp +++ b/components/tab5-emu/src/tab5-emu.cpp @@ -337,18 +337,22 @@ void Tab5Emu::keypad_read(lv_indev_t *indev, lv_indev_data_t *data) { st.right |= key(79); st.a |= key(40) | key(88) | key(44); // enter, keypad enter, space st.b |= key(41); // escape + st.x |= key(9); // f: the launcher's console filter } // left / right adjust a focused slider or dropdown, otherwise move focus bool horizontal_widget = false; if (auto *group = lv_indev_get_group(indev)) { if (auto *focused = lv_group_get_focused(group)) { + // (an object flagged LV_OBJ_FLAG_USER_1 takes left / right as keys too: + // the launcher's games change the console with them) horizontal_widget = lv_obj_check_type(focused, &lv_slider_class) || lv_obj_check_type(focused, &lv_dropdown_class) || - lv_obj_check_type(focused, &lv_switch_class); + lv_obj_check_type(focused, &lv_switch_class) || lv_obj_has_flag(focused, LV_OBJ_FLAG_USER_1); } } uint32_t key = 0; if (st.a) key = LV_KEY_ENTER; else if (st.b) key = LV_KEY_ESC; + else if (st.x) key = LV_KEY_HOME; // (the launcher's console picker) else if (st.up) key = LV_KEY_PREV; else if (st.down) key = LV_KEY_NEXT; else if (st.left) key = horizontal_widget ? LV_KEY_LEFT : LV_KEY_PREV; diff --git a/main/remote_control.hpp b/main/remote_control.hpp index 00c3bf6..fb80e28 100644 --- a/main/remote_control.hpp +++ b/main/remote_control.hpp @@ -111,7 +111,7 @@ class RemoteControl { public: static constexpr uint8_t kModule = 0x20; static constexpr const char *kProtocol = "emu.control"; - static constexpr uint16_t kProtocolVersion = 2; // 2: in-memory screenshots + static constexpr uint16_t kProtocolVersion = 3; // 2: in-memory screenshots, 3: console filter, launcher screenshots enum class Type : uint8_t { STATUS = 0x01, ///< () -> {state, rom, platform, console, heap, uptime, ...} @@ -123,13 +123,18 @@ class RemoteControl { LOAD = 0x07, ///< (u8 slot) /// (path: text, optional). With a path: saved there on the card as /// [u16be w][u16be h][RGB565] -> {path}. Without: -> {width, height, size, - /// format: rgb565le}, and the game holds still (its frame buffer with it) - /// while SCREENSHOT_READ reads the pixels, until the last of them is read. + /// format: rgb565le, source: game | launcher}, and the game holds still + /// (its frame buffer with it) while SCREENSHOT_READ reads the pixels, + /// until the last of them is read; with no game running, the launcher's + /// screen is drawn into a copy instead. SCREENSHOT = 0x08, USB_DRIVE = 0x09, ///< (u8 1 = the PC gets the SD card, 0 = the device takes it back) RELOAD_ROMS = 0x0A, ///< () re-read metadata.csv ENTER_UPDATER = 0x0B, ///< () reboot into the updater app (ota_1) for an update SCREENSHOT_READ = 0x0C, ///< (u32 offset, u16 length) -> raw bytes of the held SCREENSHOT (short at the end) + /// (console key: text, e.g. "snes"; empty or "all" for every console) -> + /// {filter, consoles: [keys]}: the launcher's list shows only that console's games + CONSOLE_FILTER = 0x0D, FILE_LIST = 0x10, ///< (path[\0offset]) -> {entries: [{name, dir, size}], truncated?, next?} FILE_READ = 0x11, ///< (u32 offset, u16 length, path) -> raw bytes (short at the end) FILE_WRITE = 0x12, ///< (u32 offset, path_len u16, path, data); offset 0 truncates @@ -342,6 +347,7 @@ class RemoteControl { std::unique_lock lk(shot_mutex_); if (shot_state_ != ShotState::CAPTURING) return; // the request gave up auto *cart = current_cart(); + shot_size_ = 0; if (cart) { cart->capture_hold(true); auto [w, h] = cart->frame_size(); @@ -354,7 +360,15 @@ class RemoteControl { shot_pixels_ = pixels.data(); shot_size_ = w * h * 2; } - shot_state_ = (cart && shot_size_) ? ShotState::HELD : ShotState::IDLE; + else { + // no game: the launcher's screen, drawn into a copy + launcher_shot_ = gui_.snapshot(); + shot_width_ = launcher_shot_.width; + shot_height_ = launcher_shot_.height; + shot_pixels_ = launcher_shot_.pixels.data(); + shot_size_ = launcher_shot_.pixels.size(); + } + shot_state_ = shot_size_ ? ShotState::HELD : ShotState::IDLE; has_shot_cart_ = cart != nullptr; shot_cv_.notify_all(); // hold the game while the frame is read @@ -364,6 +378,7 @@ class RemoteControl { } shot_state_ = ShotState::IDLE; shot_pixels_ = nullptr; + launcher_shot_ = {}; shot_cv_.notify_all(); lk.unlock(); if (cart) cart->capture_hold(false); @@ -374,18 +389,14 @@ class RemoteControl { fail("the device is busy (is the pause menu open?)"); break; } - if (!has_shot_cart_) { - fail("no game is running"); - break; - } if (shot_state_ != ShotState::HELD) { - fail("this game has no frame to capture"); + fail(has_shot_cart_ ? "this game has no frame to capture" : "the launcher could not be drawn"); break; } width = shot_width_; height = shot_height_; - json(fmt::format("{{\"width\":{},\"height\":{},\"size\":{},\"format\":\"{}\"}}", width, height, - shot_size_, kFrameFormat)); + json(fmt::format("{{\"width\":{},\"height\":{},\"size\":{},\"format\":\"{}\",\"source\":\"{}\"}}", width, + height, shot_size_, kFrameFormat, has_shot_cart_ ? "game" : "launcher")); break; } case Type::SCREENSHOT_READ: { @@ -452,6 +463,30 @@ class RemoteControl { return; #endif } + case Type::CONSOLE_FILTER: { + std::string key(text); + std::transform(key.begin(), key.end(), key.begin(), + [](unsigned char c) { return static_cast(std::tolower(c)); }); + const auto present = gui_.consoles(); + bool done = false; + if (key.empty() || key == "all") { + done = gui_.set_console_filter(std::nullopt); + } else { + const auto it = std::find_if(present.begin(), present.end(), + [&](Console c) { return key == console_info(c).key; }); + if (it == present.end()) { + fail(fmt::format("no games for console '{}'", key)); + break; + } + done = gui_.set_console_filter(*it); + } + if (!done) { + fail("the filter could not be set"); + break; + } + json(filter_json()); + break; + } case Type::FILE_LIST: { // path, optionally followed by '\0' and the index to start at (the "next" of a truncated // reply) @@ -679,7 +714,7 @@ class RemoteControl { "\"uptime_ms\":{},\"internal_free\":{},\"internal_largest\":{},\"internal_min_free\":{}," "\"psram_free\":{},\"psram_largest\":{},\"psram_min_free\":{},\"dma_free\":{}," "\"dma_largest\":{},\"firmware\":{},\"built\":{}," - "\"partition\":{},\"elf_sha256\":{},\"reset_reason\":{},\"last_panic\":{}}}", + "\"partition\":{},\"elf_sha256\":{},\"reset_reason\":{},\"last_panic\":{},\"filter\":{}}}", in_game ? "game" : "menu", quote(rom), platform, quote(console), frames, BoxEmu::get().frames_blitted(), BoxEmu::get().frames_dropped(), BoxEmu::get().usb_msc_host_has_card(), esp_timer_get_time() / 1000, @@ -691,7 +726,22 @@ class RemoteControl { heap_caps_get_free_size(MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL), heap_caps_get_largest_free_block(MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL), quote(app->version), quote(fmt::format("{} {}", app->date, app->time)), quote(running ? running->label : ""), - quote(elf_sha256()), (int)esp_reset_reason(), quote(DevLink::last_panic())); + quote(elf_sha256()), (int)esp_reset_reason(), quote(DevLink::last_panic()), + quote(filter_key())); + } + + /// The launcher's console filter: its console's key, empty for all. + std::string filter_key() const { + const auto f = gui_.console_filter(); + return f ? console_info(*f).key : ""; + } + + std::string filter_json() const { + std::string consoles; + for (const Console c : gui_.consoles()) { + consoles += fmt::format("{}{}", consoles.empty() ? "" : ",", quote(console_info(c).key)); + } + return fmt::format("{{\"filter\":{},\"consoles\":[{}]}}", quote(filter_key()), consoles); } /// Make the bootloader start the updater (ota_1) next. esp_ota_set_boot_partition() @@ -810,6 +860,7 @@ class RemoteControl { const uint8_t *shot_pixels_{nullptr}; size_t shot_width_{0}, shot_height_{0}, shot_size_{0}; bool has_shot_cart_{false}; + Gui::Snapshot launcher_shot_; ///< the launcher's screen, while it is read FILE *write_file_{nullptr}; std::string write_path_; uint32_t write_pos_{0}; diff --git a/tools/emulink/emulink/cli.py b/tools/emulink/emulink/cli.py index de26428..e48350a 100644 --- a/tools/emulink/emulink/cli.py +++ b/tools/emulink/emulink/cli.py @@ -140,6 +140,13 @@ def cmd_screenshot(args) -> int: return 0 +def cmd_filter(args) -> int: + with _open(args) as link: + r = Control(link).console_filter(args.console) + print(f"filter: {r['filter'] or 'all'} (consoles: {', '.join(r['consoles'])})") + return 0 + + def cmd_ls(args) -> int: with _open(args) as link: for e in Control(link).ls(args.path): @@ -457,7 +464,7 @@ def build_parser() -> argparse.ArgumentParser: s = sub.add_parser(name, help=f"{name} a save state") s.add_argument("slot", type=int) s.set_defaults(fn=fn) - s = sub.add_parser("screenshot", help="the running game's frame as a PNG") + s = sub.add_parser("screenshot", help="the running game's frame (or the launcher's screen) as a PNG") s.add_argument("-o", "--output") s.add_argument("--byteswap", action=argparse.BooleanOptionalAction, default=None, help="RGB565 big-endian (default: the byte order the device reports)") @@ -490,6 +497,9 @@ def build_parser() -> argparse.ArgumentParser: s.add_argument("--delete", action="store_true", help="also delete the file") s.set_defaults(fn=cmd_remove_rom) sub.add_parser("reload", help="re-read metadata.csv").set_defaults(fn=cmd_reload) + s = sub.add_parser("filter", help="show only one console's games in the launcher (a key such as snes, or all)") + s.add_argument("console", nargs="?", help="console key, or all (default: show the current filter)") + s.set_defaults(fn=cmd_filter) s = sub.add_parser("drive", help="hand the SD card to the PC as a USB drive (on) or take it back (off)") s.add_argument("state", choices=("on", "off")) s.set_defaults(fn=cmd_drive) diff --git a/tools/emulink/emulink/control.py b/tools/emulink/emulink/control.py index abe2c6b..dc3140f 100644 --- a/tools/emulink/emulink/control.py +++ b/tools/emulink/emulink/control.py @@ -17,6 +17,7 @@ STATUS, LIST_ROMS, LAUNCH, QUIT, BUTTONS, SAVE, LOAD, SCREENSHOT, USB_DRIVE, RELOAD_ROMS, ENTER_UPDATER = range(1, 12) SCREENSHOT_READ = 0x0C +CONSOLE_FILTER = 0x0D FILE_LIST, FILE_READ, FILE_WRITE, FILE_DELETE, MKDIR, FILE_STAT, FILE_CLOSE = range(0x10, 0x17) #: one FILE_WRITE: the frame payload is at most 4096 bytes, of which 6 + the path are the header @@ -168,9 +169,9 @@ def screenshot(self, remote_path: str = "screenshots/screenshot.bin") -> str: return self._call(SCREENSHOT, self.remote(remote_path).encode())["path"] def frame(self, progress=None) -> "Frame": - """The running game's frame, copied straight from its frame buffer - (firmware before protocol 2 saves it on the card and it is read from - there).""" + """The running game's frame, copied straight from its frame buffer, + or with no game running (protocol 3) the launcher's screen (firmware + before protocol 2 saves it on the card and it is read from there).""" info = self._call(SCREENSHOT, timeout_s=15) if "path" in info: # older firmware data = self.read_file(info["path"]) @@ -200,6 +201,14 @@ def frame(self, progress=None) -> "Frame": def usb_drive(self, host: bool) -> None: self._call(USB_DRIVE, bytes([1 if host else 0]), timeout_s=20) + def console_filter(self, console: str | None = None) -> dict: + """Set the launcher's console filter (a console key such as "snes", or + "all"); with None, only report it. -> {filter, consoles}""" + if console is None: + console = self.status().get("filter", "") + # (an empty filter would clear it: ask for the same one again) + return self._call(CONSOLE_FILTER, (console or "all").encode()) + def reload_roms(self) -> int: return self._call(RELOAD_ROMS)["total"] From 400f7c53a4c21af48dbe244fcfb40b623437b495 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 13 Nov 2026 09:00:51 -0600 Subject: [PATCH 2/7] Pin esp_tinyusb to 3.0.0 esp_tinyusb 3.0.1 (TinyUSB 0.21.0~6, the DWC2 SETUP-DMA erratum workaround) corrupts the PSRAM heap on esp-box-emu while a Genesis game runs (the link task's next allocation hits a tlsf assert or an MMU entry fault); 3.0.0 is fine. The Tab5 shares the USB device code, and a fresh build resolves '>=3.0.0' to 3.0.1, so pin it here too. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/tab5-emu/idf_component.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/tab5-emu/idf_component.yml b/components/tab5-emu/idf_component.yml index af30d2e..0e760a4 100644 --- a/components/tab5-emu/idf_component.yml +++ b/components/tab5-emu/idf_component.yml @@ -17,6 +17,11 @@ dependencies: espp/timer: '>=1.3' # USB mass storage (the SD card as a USB drive), brings esp_tinyusb; needs # UsbDevice::Config::port (the Tab5's USB-C is the P4's full-speed port) + # Pinned: esp_tinyusb 3.0.1 (TinyUSB 0.21.0~6: the DWC2 SETUP-DMA erratum + # workaround) corrupts the PSRAM heap on esp-box-emu while a Genesis game + # runs (tlsf asserts / MMU faults on the next allocation in the link task); + # 3.0.0 does not. Lift once that is understood upstream. + espressif/esp_tinyusb: '==3.0.0' espp/usb_device: # TEMP: take_msc_from_ejected_host() (esp-cpp/espp#898, merged as # 08295c0); back to the registry once it is released From 57799db3a88e2754bb63189875ff5b9a8634b85d Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 13 Nov 2026 10:11:42 -0600 Subject: [PATCH 3/7] Revert "Pin esp_tinyusb to 3.0.0" The heap corruption seen with Sonic 2 on the box turned out to be intermittent: the same builds that failed also pass repeated trials, so the runs that blamed esp_tinyusb 3.0.1 were not evidence of a cause. The corruption is tracked separately; no pin until it is understood. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/tab5-emu/idf_component.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/tab5-emu/idf_component.yml b/components/tab5-emu/idf_component.yml index 0e760a4..af30d2e 100644 --- a/components/tab5-emu/idf_component.yml +++ b/components/tab5-emu/idf_component.yml @@ -17,11 +17,6 @@ dependencies: espp/timer: '>=1.3' # USB mass storage (the SD card as a USB drive), brings esp_tinyusb; needs # UsbDevice::Config::port (the Tab5's USB-C is the P4's full-speed port) - # Pinned: esp_tinyusb 3.0.1 (TinyUSB 0.21.0~6: the DWC2 SETUP-DMA erratum - # workaround) corrupts the PSRAM heap on esp-box-emu while a Genesis game - # runs (tlsf asserts / MMU faults on the next allocation in the link task); - # 3.0.0 does not. Lift once that is understood upstream. - espressif/esp_tinyusb: '==3.0.0' espp/usb_device: # TEMP: take_msc_from_ejected_host() (esp-cpp/espp#898, merged as # 08295c0); back to the registry once it is released From 7613e0d1b4a9b5c4e9b346b71e63787e5e38f8d3 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 13 Nov 2026 21:32:32 -0600 Subject: [PATCH 4/7] Console filter: close the picker on return from a game; read-only filter query A game started from the PC (emulink launch) with the console picker open left it on screen after the game while the keypad drove the list behind it: resume() closes it. CONSOLE_FILTER takes "?" as a query that changes nothing, and emulink filter with no argument uses it instead of writing the current filter back. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/gui/src/gui.cpp | 3 +++ main/remote_control.hpp | 9 +++++++-- tools/emulink/emulink/control.py | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/gui/src/gui.cpp b/components/gui/src/gui.cpp index 54687b1..4601219 100644 --- a/components/gui/src/gui.cpp +++ b/components/gui/src/gui.cpp @@ -47,6 +47,9 @@ void Gui::pause() { void Gui::resume() { std::lock_guard lk(mutex_); + // a game started from the PC (emulink launch) leaves the console picker open + // behind it: back from the game, the list has the keypad, so close it + close_console_picker(); update_rom_list(); update_shared_state(); lv_screen_load(screen_); diff --git a/main/remote_control.hpp b/main/remote_control.hpp index fb80e28..0413ed5 100644 --- a/main/remote_control.hpp +++ b/main/remote_control.hpp @@ -132,8 +132,9 @@ class RemoteControl { RELOAD_ROMS = 0x0A, ///< () re-read metadata.csv ENTER_UPDATER = 0x0B, ///< () reboot into the updater app (ota_1) for an update SCREENSHOT_READ = 0x0C, ///< (u32 offset, u16 length) -> raw bytes of the held SCREENSHOT (short at the end) - /// (console key: text, e.g. "snes"; empty or "all" for every console) -> - /// {filter, consoles: [keys]}: the launcher's list shows only that console's games + /// (console key: text, e.g. "snes"; empty or "all" for every console; "?" + /// changes nothing, only reports) -> {filter, consoles: [keys]}: the + /// launcher's list shows only that console's games CONSOLE_FILTER = 0x0D, FILE_LIST = 0x10, ///< (path[\0offset]) -> {entries: [{name, dir, size}], truncated?, next?} FILE_READ = 0x11, ///< (u32 offset, u16 length, path) -> raw bytes (short at the end) @@ -467,6 +468,10 @@ class RemoteControl { std::string key(text); std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); + if (key == "?") { // a query: report the filter without touching the list + json(filter_json()); + break; + } const auto present = gui_.consoles(); bool done = false; if (key.empty() || key == "all") { diff --git a/tools/emulink/emulink/control.py b/tools/emulink/emulink/control.py index dc3140f..188dda0 100644 --- a/tools/emulink/emulink/control.py +++ b/tools/emulink/emulink/control.py @@ -205,8 +205,7 @@ def console_filter(self, console: str | None = None) -> dict: """Set the launcher's console filter (a console key such as "snes", or "all"); with None, only report it. -> {filter, consoles}""" if console is None: - console = self.status().get("filter", "") - # (an empty filter would clear it: ask for the same one again) + return self._call(CONSOLE_FILTER, b"?") # a query: changes nothing return self._call(CONSOLE_FILTER, (console or "all").encode()) def reload_roms(self) -> int: From 1a10e0eca13dd563ca88fd297d4698234ee32279 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 13 Nov 2026 21:58:52 -0600 Subject: [PATCH 5/7] Console filter: select a remotely chosen game once; intptr_t for button indices; tolerant emulink filter output Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/gui/src/gui.cpp | 8 +++++--- tools/emulink/emulink/cli.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/gui/src/gui.cpp b/components/gui/src/gui.cpp index 4601219..15d27ab 100644 --- a/components/gui/src/gui.cpp +++ b/components/gui/src/gui.cpp @@ -316,7 +316,7 @@ void Gui::build_list(int keep_rom) { add_console_header(console); } auto btn = lv_list_add_button(rom_list_, nullptr, rom_infos_[i].name.c_str()); - lv_obj_set_user_data(btn, reinterpret_cast(i)); + lv_obj_set_user_data(btn, reinterpret_cast(static_cast(i))); lv_obj_add_event_cb(btn, event_callback, LV_EVENT_CLICKED, this); lv_obj_add_event_cb(btn, event_callback, LV_EVENT_FOCUSED, this); lv_obj_add_event_cb(btn, event_callback, LV_EVENT_KEY, this); @@ -598,12 +598,14 @@ bool Gui::select_rom_matching(std::string_view text) { const auto &rom = rom_infos_[i]; if (exact ? (rom.rom_path == text || rom.name == text) : (rom.name.find(text) != std::string::npos || rom.rom_path.find(text) != std::string::npos)) { - // a game the console filter hides: show them all + // a game the console filter hides: show them all (build_list() + // selects it) if (filter_ >= 0 && static_cast(console_of(rom.platform)) != filter_) { filter_ = -1; build_list(i); + } else { + select_rom(i); } - select_rom(i); return true; } } diff --git a/tools/emulink/emulink/cli.py b/tools/emulink/emulink/cli.py index e48350a..ba9498a 100644 --- a/tools/emulink/emulink/cli.py +++ b/tools/emulink/emulink/cli.py @@ -143,7 +143,7 @@ def cmd_screenshot(args) -> int: def cmd_filter(args) -> int: with _open(args) as link: r = Control(link).console_filter(args.console) - print(f"filter: {r['filter'] or 'all'} (consoles: {', '.join(r['consoles'])})") + print(f"filter: {r.get('filter') or 'all'} (consoles: {', '.join(r.get('consoles', [])) or 'none'})") return 0 From 209cd4ba9cef5677a7833ab8c5b52c690b80909d Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 13 Nov 2026 22:18:23 -0600 Subject: [PATCH 6/7] Console filter: an empty request only reports it; not while a launch is pending; a list reload closes the picker As esp-box-emu (3f9a022, 2968e88), so the protocol and emulink match: - CONSOLE_FILTER with an empty payload returns {filter, consoles} without touching the launcher ("all" clears the filter); emulink filter with no console sends that query. - Setting it runs on the main loop under the GUI lock, like LAUNCH, and is refused while a launch the loop has taken has not started its cart. - Re-reading metadata.csv closes an open console picker. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/gui/src/gui.cpp | 2 ++ main/remote_control.hpp | 47 ++++++++++++++++++-------------- tools/emulink/emulink/control.py | 5 ++-- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/components/gui/src/gui.cpp b/components/gui/src/gui.cpp index 15d27ab..56ff216 100644 --- a/components/gui/src/gui.cpp +++ b/components/gui/src/gui.cpp @@ -258,6 +258,8 @@ void Gui::update_rom_list() { return; } metadata_last_modified_ = mtime; + // (an open picker's consoles and counts are the old list's) + close_console_picker(); // keep the selected game selected across a reload (its index may change); // at boot that is the last game played std::string selected_path; diff --git a/main/remote_control.hpp b/main/remote_control.hpp index 0413ed5..297abfe 100644 --- a/main/remote_control.hpp +++ b/main/remote_control.hpp @@ -132,9 +132,9 @@ class RemoteControl { RELOAD_ROMS = 0x0A, ///< () re-read metadata.csv ENTER_UPDATER = 0x0B, ///< () reboot into the updater app (ota_1) for an update SCREENSHOT_READ = 0x0C, ///< (u32 offset, u16 length) -> raw bytes of the held SCREENSHOT (short at the end) - /// (console key: text, e.g. "snes"; empty or "all" for every console; "?" - /// changes nothing, only reports) -> {filter, consoles: [keys]}: the - /// launcher's list shows only that console's games + /// (console key: text, e.g. "snes"; "all" for every console) -> {filter, + /// consoles: [keys]}: the launcher's list shows only that console's games. + /// An empty payload only reports them (nothing changes on the device). CONSOLE_FILTER = 0x0D, FILE_LIST = 0x10, ///< (path[\0offset]) -> {entries: [{name, dir, size}], truncated?, next?} FILE_READ = 0x11, ///< (u32 offset, u16 length, path) -> raw bytes (short at the end) @@ -468,28 +468,33 @@ class RemoteControl { std::string key(text); std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); - if (key == "?") { // a query: report the filter without touching the list - json(filter_json()); + if (key.empty()) { + json(filter_json()); // a query break; } - const auto present = gui_.consoles(); - bool done = false; - if (key.empty() || key == "all") { - done = gui_.set_console_filter(std::nullopt); - } else { - const auto it = std::find_if(present.begin(), present.end(), - [&](Console c) { return key == console_info(c).key; }); - if (it == present.end()) { - fail(fmt::format("no games for console '{}'", key)); - break; - } - done = gui_.set_console_filter(*it); - } - if (!done) { - fail("the filter could not be set"); + // On the main loop, as LAUNCH: a launch it has taken (ready_to_play, no + // cart yet) reads the selected game next, which a new filter can change. + // The GUI lock keeps a tap on the screen from starting one meanwhile. + bool pending = false, unknown = false, done = false; + if (!on_main([&] { + std::lock_guard lk(BoxEmu::lvgl_mutex()); + if ((pending = gui_.ready_to_play() && !current_cart())) return; + if (key == "all") { + done = gui_.set_console_filter(std::nullopt); + return; + } + const auto present = gui_.consoles(); + const auto it = std::find_if(present.begin(), present.end(), + [&](Console c) { return key == console_info(c).key; }); + if ((unknown = it == present.end())) return; + done = gui_.set_console_filter(*it); + }, std::chrono::seconds(2))) { break; } - json(filter_json()); + if (pending) fail("a game is starting"); + else if (unknown) fail(fmt::format("no games for console '{}'", key)); + else if (!done) fail("the filter could not be set"); + else json(filter_json()); break; } case Type::FILE_LIST: { diff --git a/tools/emulink/emulink/control.py b/tools/emulink/emulink/control.py index 188dda0..36e3caf 100644 --- a/tools/emulink/emulink/control.py +++ b/tools/emulink/emulink/control.py @@ -203,9 +203,10 @@ def usb_drive(self, host: bool) -> None: def console_filter(self, console: str | None = None) -> dict: """Set the launcher's console filter (a console key such as "snes", or - "all"); with None, only report it. -> {filter, consoles}""" + "all"); with None, only report it (an empty request changes nothing on + the device). -> {filter, consoles}""" if console is None: - return self._call(CONSOLE_FILTER, b"?") # a query: changes nothing + return self._call(CONSOLE_FILTER, b"") return self._call(CONSOLE_FILTER, (console or "all").encode()) def reload_roms(self) -> int: From b9948155b671bfffe65dae08a60b33a4bffda49d Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 13 Nov 2026 23:04:34 -0600 Subject: [PATCH 7/7] Console filter: split the assignment out of the condition (cppcheck clarifyCondition) Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- main/remote_control.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/remote_control.hpp b/main/remote_control.hpp index 297abfe..695b1bd 100644 --- a/main/remote_control.hpp +++ b/main/remote_control.hpp @@ -486,7 +486,8 @@ class RemoteControl { const auto present = gui_.consoles(); const auto it = std::find_if(present.begin(), present.end(), [&](Console c) { return key == console_info(c).key; }); - if ((unknown = it == present.end())) return; + unknown = (it == present.end()); + if (unknown) return; done = gui_.set_console_filter(*it); }, std::chrono::seconds(2))) { break;