mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-25 13:00:22 +00:00
Fixes
This commit is contained in:
parent
7dd141c4f8
commit
431726fd8d
8 changed files with 39 additions and 7 deletions
|
@ -87,6 +87,7 @@ void InputController::handle_keyboard_event(int key, int scancode, int action, i
|
|||
GLFW_KEYBOARD_TO_GAMEPAD(GLFW_KEY_B, GLFW_GAMEPAD_BUTTON_B);
|
||||
GLFW_KEYBOARD_TO_GAMEPAD(GLFW_KEY_X, GLFW_GAMEPAD_BUTTON_X);
|
||||
GLFW_KEYBOARD_TO_GAMEPAD(GLFW_KEY_Y, GLFW_GAMEPAD_BUTTON_Y);
|
||||
GLFW_KEYBOARD_TO_GAMEPAD(GLFW_KEY_ESCAPE, GLFW_GAMEPAD_BUTTON_START);
|
||||
|
||||
glfw_gamepad_state.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER] = glfw_keyboard_state[GLFW_KEY_Z] ? 1 : -1;
|
||||
glfw_gamepad_state.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER] = glfw_keyboard_state[GLFW_KEY_C] ? 1 : -1;
|
||||
|
|
|
@ -54,6 +54,13 @@ void Settings::add_host(const std::string address) {
|
|||
}
|
||||
}
|
||||
|
||||
void Settings::remove_host(const std::string address) {
|
||||
if (std::find(m_hosts.begin(), m_hosts.end(), address) != m_hosts.end()) {
|
||||
m_hosts.erase(std::remove(m_hosts.begin(), m_hosts.end(), address), m_hosts.end());
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::load() {
|
||||
json_t* root = json_load_file((m_working_dir + "/settings.json").c_str(), 0, NULL);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
}
|
||||
|
||||
void add_host(const std::string address);
|
||||
void remove_host(const std::string address);
|
||||
|
||||
int resolution() const {
|
||||
return m_resolution;
|
||||
|
|
|
@ -81,7 +81,7 @@ int http_init(const char* key_directory) {
|
|||
}
|
||||
|
||||
int http_request(char* url, Data* data, HTTPRequestTimeout timeout) {
|
||||
Logger::info("Curl", "Request %s", url);
|
||||
Logger::info("Curl", "Request:\n%s", url);
|
||||
|
||||
HTTP_DATA* http_data = (HTTP_DATA*)malloc(sizeof(HTTP_DATA));
|
||||
http_data->memory = (char*)malloc(1);
|
||||
|
|
|
@ -143,7 +143,6 @@ ssize_t AudrenAudioRenderer::free_wavebuf_index() {
|
|||
return i;
|
||||
}
|
||||
}
|
||||
Logger::error("Audren", "No free wavebuf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -189,14 +188,14 @@ size_t AudrenAudioRenderer::append_audio(const void *buf, size_t size) {
|
|||
}
|
||||
|
||||
void AudrenAudioRenderer::write_audio(const void *buf, size_t size) {
|
||||
if (m_inited_driver) {
|
||||
if (!m_inited_driver) {
|
||||
Logger::fatal("Audren", "Call write_audio without init driver!");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t written = 0;
|
||||
|
||||
while(written < size) {
|
||||
while (written < size) {
|
||||
written += append_audio(buf + written, size - written);
|
||||
|
||||
if (written != size) {
|
||||
|
|
|
@ -86,7 +86,7 @@ void Application::gamepad_button_callback_event(int jid, int button, int action)
|
|||
m_windows.back()->gamepad_button_event(jid, button, action);
|
||||
}
|
||||
|
||||
if (action && button == NANOGUI_GAMEPAD_BUTTON_START) {
|
||||
if (action && button == NANOGUI_GAMEPAD_BUTTON_START && m_windows.size() == 1) {
|
||||
moonlight_exit = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,13 +27,28 @@ void LogsWindow::reload() {
|
|||
|
||||
if (data.is_empty()) {
|
||||
auto label = container()->add<Label>("No logs...");
|
||||
label->set_fixed_width(container()->width());
|
||||
m_labels.push_back(label);
|
||||
} else {
|
||||
std::stringstream stream((char *)data.bytes());
|
||||
std::string string;
|
||||
std::vector<std::string> logs;
|
||||
|
||||
while (std::getline(stream, string, '\n')) {
|
||||
auto label = container()->add<Label>(string);
|
||||
if (string.size() > 100) {
|
||||
string = string.substr(0, 100) + "...";
|
||||
}
|
||||
|
||||
logs.push_back(string);
|
||||
}
|
||||
|
||||
if (logs.size() > 100) {
|
||||
logs = std::vector<std::string>(logs.end() - 100, logs.end());
|
||||
logs.insert(logs.begin(), "* Show last 100 lines");
|
||||
}
|
||||
|
||||
for (auto log: logs) {
|
||||
auto label = container()->add<Label>(log);
|
||||
label->set_selectable(true);
|
||||
m_labels.push_back(label);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ using namespace nanogui;
|
|||
MainWindow::MainWindow(Widget *parent): ContentWindow(parent, "Moonlight") {
|
||||
set_box_layout(Orientation::Horizontal, Alignment::Minimum);
|
||||
|
||||
set_right_title_button(FA_SYNC, [this] {
|
||||
this->reload();
|
||||
});
|
||||
set_right_title_button(FA_COG, [this] {
|
||||
push<SettingsWindow>();
|
||||
});
|
||||
|
@ -51,7 +54,13 @@ void MainWindow::reload() {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
screen()->add<MessageDialog>(MessageDialog::Type::Information, "Error", "Innactive host...");
|
||||
auto alert = screen()->add<MessageDialog>(MessageDialog::Type::Information, "Error", "Innactive host...", "OK", "Delete", true);
|
||||
alert->set_callback([this, button](int action) {
|
||||
if (action) {
|
||||
Settings::settings()->remove_host(button->address());
|
||||
reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue