Skip to content

Commit

Permalink
fix: Update to better support case that the hardware isnt found (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
finger563 authored Jul 15, 2024
1 parent 51fe194 commit f1f753c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/box-emu/src/box-emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void BoxEmu::detect() {
// Version 0
version_ = BoxEmu::Version::V0;
} else {
logger_.warn("No box detected");
logger_.warn("No box-emu hardware detected");
// No box detected
version_ = BoxEmu::Version::UNKNOWN;
return;
Expand Down
27 changes: 18 additions & 9 deletions components/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ void Gui::init_ui() {
settings_screen_group_ = lv_group_create();

// get the KEYPAD indev
auto keypad = BoxEmu::get().keypad()->get_input_device();
if (keypad)
lv_indev_set_group(keypad, rom_screen_group_);
auto keypad = BoxEmu::get().keypad();
if (keypad) {
auto input = keypad->get_input_device();
if (input)
lv_indev_set_group(input, rom_screen_group_);
}

ui_init();

Expand Down Expand Up @@ -446,9 +449,12 @@ void Gui::focus_rommenu() {
// focus the rom screen group
logger_.debug("Focusing rom screen group");
lv_group_focus_freeze(rom_screen_group_, false);
auto keypad = BoxEmu::get().keypad()->get_input_device();
if (keypad)
lv_indev_set_group(keypad, rom_screen_group_);
auto keypad = BoxEmu::get().keypad();
if (keypad) {
auto input = keypad->get_input_device();
if (input)
lv_indev_set_group(input, rom_screen_group_);
}
}

void Gui::focus_settings() {
Expand All @@ -457,9 +463,12 @@ void Gui::focus_settings() {
logger_.debug("Focusing settings screen group");
lv_group_focus_freeze(settings_screen_group_, false);
// NOTE: we don't set editing here since we use it to manage the dropdown
auto keypad = BoxEmu::get().keypad()->get_input_device();
if (keypad)
lv_indev_set_group(keypad, settings_screen_group_);
auto keypad = BoxEmu::get().keypad();
if (keypad) {
auto input = keypad->get_input_device();
if (input)
lv_indev_set_group(input, settings_screen_group_);
}
}

void Gui::on_key(lv_event_t *e) {
Expand Down
9 changes: 6 additions & 3 deletions components/menu/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ void Menu::init_ui() {
lv_group_set_default(group_);

// get the KEYPAD indev
auto keypad = BoxEmu::get().keypad()->get_input_device();
if (keypad)
lv_indev_set_group(keypad, group_);
auto keypad = BoxEmu::get().keypad();
if (keypad) {
auto input = keypad->get_input_device();
if (input)
lv_indev_set_group(input, group_);
}

// now initialize our UI
menu_ui_init();
Expand Down

0 comments on commit f1f753c

Please sign in to comment.