[App] Minor Fixes
Added F9 [Controller Hotkeys] Call RunTitle from the UI thread
This commit is contained in:
parent
036f19c66e
commit
3d3810fa98
|
@ -12,6 +12,7 @@
|
||||||
#include "third_party/discord-rpc/include/discord_rpc.h"
|
#include "third_party/discord-rpc/include/discord_rpc.h"
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
|
|
||||||
|
// TODO: This library has been deprecated in favor of Discord's GameSDK.
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace discord {
|
namespace discord {
|
||||||
|
|
||||||
|
|
|
@ -1195,11 +1195,11 @@ const std::map<int, EmulatorWindow::ControllerHotKey> controller_hotkey_map = {
|
||||||
{X_INPUT_GAMEPAD_DPAD_DOWN,
|
{X_INPUT_GAMEPAD_DPAD_DOWN,
|
||||||
EmulatorWindow::ControllerHotKey(
|
EmulatorWindow::ControllerHotKey(
|
||||||
EmulatorWindow::ButtonFunctions::IncTitleSelect,
|
EmulatorWindow::ButtonFunctions::IncTitleSelect,
|
||||||
"D-PAD Down + Guide = Title Selection +1", true, false)},
|
"D-PAD Down = Title Selection +1", true, false)},
|
||||||
{X_INPUT_GAMEPAD_DPAD_UP,
|
{X_INPUT_GAMEPAD_DPAD_UP,
|
||||||
EmulatorWindow::ControllerHotKey(
|
EmulatorWindow::ControllerHotKey(
|
||||||
EmulatorWindow::ButtonFunctions::DecTitleSelect,
|
EmulatorWindow::ButtonFunctions::DecTitleSelect,
|
||||||
"D-PAD Up + Guide = Title Selection -1", true, false)}};
|
"D-PAD Up = Title Selection -1", true, false)}};
|
||||||
|
|
||||||
EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
|
EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
|
||||||
int buttons) {
|
int buttons) {
|
||||||
|
@ -1247,12 +1247,10 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
|
||||||
case ButtonFunctions::RunTitle: {
|
case ButtonFunctions::RunTitle: {
|
||||||
if (selected_title_index == -1) selected_title_index++;
|
if (selected_title_index == -1) selected_title_index++;
|
||||||
|
|
||||||
xe::X_STATUS title_success = RunTitle(
|
app_context().CallInUIThread([this]() {
|
||||||
recently_launched_titles_[selected_title_index].path_to_file);
|
RunTitle(recently_launched_titles_[selected_title_index].path_to_file);
|
||||||
|
});
|
||||||
|
|
||||||
if (title_success == X_ERROR_SUCCESS) {
|
|
||||||
imgui_drawer_.get()->ClearDialogs();
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
case ButtonFunctions::ClearMemoryPageState:
|
case ButtonFunctions::ClearMemoryPageState:
|
||||||
ToggleGPUSetting(gpu_cvar::ClearMemoryPageState);
|
ToggleGPUSetting(gpu_cvar::ClearMemoryPageState);
|
||||||
|
@ -1311,6 +1309,7 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey(
|
||||||
selected_title_index = std::clamp(
|
selected_title_index = std::clamp(
|
||||||
selected_title_index, 0, (int)recently_launched_titles_.size() - 1);
|
selected_title_index, 0, (int)recently_launched_titles_.size() - 1);
|
||||||
|
|
||||||
|
// Must clear dialogs to prevent stacking
|
||||||
imgui_drawer_.get()->ClearDialogs();
|
imgui_drawer_.get()->ClearDialogs();
|
||||||
|
|
||||||
// Titles may contain Unicode characters such as At World’s End
|
// Titles may contain Unicode characters such as At World’s End
|
||||||
|
@ -1338,7 +1337,7 @@ void EmulatorWindow::VibrateController(xe::hid::InputSystem* input_sys,
|
||||||
// otherwise the rumble may fail.
|
// otherwise the rumble may fail.
|
||||||
auto input_lock = input_sys->lock();
|
auto input_lock = input_sys->lock();
|
||||||
|
|
||||||
X_INPUT_VIBRATION vibration{};
|
X_INPUT_VIBRATION vibration = {};
|
||||||
|
|
||||||
vibration.left_motor_speed = toggle_rumble ? UINT16_MAX : 0;
|
vibration.left_motor_speed = toggle_rumble ? UINT16_MAX : 0;
|
||||||
vibration.right_motor_speed = toggle_rumble ? UINT16_MAX : 0;
|
vibration.right_motor_speed = toggle_rumble ? UINT16_MAX : 0;
|
||||||
|
@ -1473,11 +1472,12 @@ void EmulatorWindow::DisplayHotKeysConfig() {
|
||||||
msg);
|
msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
xe::X_STATUS EmulatorWindow::RunTitle(std::filesystem::path path) {
|
xe::X_STATUS EmulatorWindow::RunTitle(std::filesystem::path path_to_file) {
|
||||||
bool titleExists = !std::filesystem::exists(path);
|
bool titleExists = !std::filesystem::exists(path_to_file);
|
||||||
|
|
||||||
if (path.empty() || titleExists) {
|
if (path_to_file.empty() || titleExists) {
|
||||||
char* log_msg = path.empty() ? "Failed to launch title path is empty."
|
char* log_msg = path_to_file.empty()
|
||||||
|
? "Failed to launch title path is empty."
|
||||||
: "Failed to launch title path is invalid.";
|
: "Failed to launch title path is invalid.";
|
||||||
|
|
||||||
XELOGE(log_msg);
|
XELOGE(log_msg);
|
||||||
|
@ -1501,19 +1501,19 @@ xe::X_STATUS EmulatorWindow::RunTitle(std::filesystem::path path) {
|
||||||
|
|
||||||
// Prevent crashing the emulator by not loading a game if a game is already
|
// Prevent crashing the emulator by not loading a game if a game is already
|
||||||
// loaded.
|
// loaded.
|
||||||
auto abs_path = std::filesystem::absolute(path);
|
auto abs_path = std::filesystem::absolute(path_to_file);
|
||||||
auto result = emulator_->LaunchPath(abs_path);
|
auto result = emulator_->LaunchPath(abs_path);
|
||||||
|
|
||||||
|
imgui_drawer_.get()->ClearDialogs();
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
XELOGE("Failed to launch target: {:08X}", result);
|
XELOGE("Failed to launch target: {:08X}", result);
|
||||||
|
|
||||||
imgui_drawer_.get()->ClearDialogs();
|
|
||||||
|
|
||||||
xe::ui::ImGuiDialog::ShowMessageBox(
|
xe::ui::ImGuiDialog::ShowMessageBox(
|
||||||
imgui_drawer_.get(), "Title Launch Failed!",
|
imgui_drawer_.get(), "Title Launch Failed!",
|
||||||
"Failed to launch title.\n\nCheck xenia.log for technical details.");
|
"Failed to launch title.\n\nCheck xenia.log for technical details.");
|
||||||
} else {
|
} else {
|
||||||
AddRecentlyLaunchedTitle(path, emulator_->title_name());
|
AddRecentlyLaunchedTitle(path_to_file, emulator_->title_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1525,32 +1525,19 @@ void EmulatorWindow::RunPreviouslyPlayedTitle() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatorWindow::RunRecentlyPlayedTitle(
|
|
||||||
std::filesystem::path path_to_file) {
|
|
||||||
if (path_to_file.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto abs_path = std::filesystem::absolute(path_to_file);
|
|
||||||
auto result = emulator_->LaunchPath(abs_path);
|
|
||||||
if (XFAILED(result)) {
|
|
||||||
// TODO: Display a message box.
|
|
||||||
XELOGE("Failed to launch target: {:08X}", result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AddRecentlyLaunchedTitle(path_to_file, emulator_->title_name());
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmulatorWindow::FillRecentlyLaunchedTitlesMenu(
|
void EmulatorWindow::FillRecentlyLaunchedTitlesMenu(
|
||||||
xe::ui::MenuItem* recent_menu) {
|
xe::ui::MenuItem* recent_menu) {
|
||||||
for (const RecentTitleEntry& entry : recently_launched_titles_) {
|
for (int i = 0; i < recently_launched_titles_.size(); ++i) {
|
||||||
std::string item_text = !entry.title_name.empty()
|
std::string hotkey = (i == 0) ? "F9" : "";
|
||||||
? entry.title_name
|
|
||||||
: entry.path_to_file.string();
|
const RecentTitleEntry& entry = recently_launched_titles_[i];
|
||||||
recent_menu->AddChild(
|
const std::string item_text = entry.title_name.empty()
|
||||||
MenuItem::Create(MenuItem::Type::kString, item_text,
|
? entry.path_to_file.string()
|
||||||
std::bind(&EmulatorWindow::RunRecentlyPlayedTitle,
|
: entry.title_name;
|
||||||
this, entry.path_to_file)));
|
|
||||||
|
recent_menu->AddChild(MenuItem::Create(
|
||||||
|
MenuItem::Type::kString, item_text, hotkey,
|
||||||
|
std::bind(&EmulatorWindow::RunTitle, this, entry.path_to_file)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class EmulatorWindow {
|
||||||
|
|
||||||
std::unique_ptr<xe::threading::Thread> Gamepad_HotKeys_Listener;
|
std::unique_ptr<xe::threading::Thread> Gamepad_HotKeys_Listener;
|
||||||
|
|
||||||
int selected_title_index = -1;
|
int32_t selected_title_index = -1;
|
||||||
|
|
||||||
Emulator* emulator() const { return emulator_; }
|
Emulator* emulator() const { return emulator_; }
|
||||||
ui::WindowedAppContext& app_context() const { return app_context_; }
|
ui::WindowedAppContext& app_context() const { return app_context_; }
|
||||||
|
@ -210,9 +210,8 @@ class EmulatorWindow {
|
||||||
std::string BoolToString(bool value);
|
std::string BoolToString(bool value);
|
||||||
void DisplayHotKeysConfig();
|
void DisplayHotKeysConfig();
|
||||||
|
|
||||||
xe::X_STATUS RunTitle(std::filesystem::path path);
|
xe::X_STATUS RunTitle(std::filesystem::path path_to_file);
|
||||||
void RunPreviouslyPlayedTitle();
|
void RunPreviouslyPlayedTitle();
|
||||||
void RunRecentlyPlayedTitle(std::filesystem::path path_to_file);
|
|
||||||
void FillRecentlyLaunchedTitlesMenu(xe::ui::MenuItem* recent_menu);
|
void FillRecentlyLaunchedTitlesMenu(xe::ui::MenuItem* recent_menu);
|
||||||
void LoadRecentlyLaunchedTitles();
|
void LoadRecentlyLaunchedTitles();
|
||||||
void AddRecentlyLaunchedTitle(std::filesystem::path path_to_file,
|
void AddRecentlyLaunchedTitle(std::filesystem::path path_to_file,
|
||||||
|
|
Loading…
Reference in New Issue