mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-26 21:40:18 +00:00
Allow to set custom button mapping and combo keys for each game
This commit is contained in:
parent
dc26386d8e
commit
96c61cd3f3
3 changed files with 24 additions and 2 deletions
|
@ -2,7 +2,9 @@
|
|||
#include "Application.hpp"
|
||||
#include "GameStreamClient.hpp"
|
||||
#include "BoxArtManager.hpp"
|
||||
#include "InputSettingsWindow.hpp"
|
||||
#include "nanovg.h"
|
||||
#include <nanogui/opengl.h>
|
||||
|
||||
using namespace nanogui;
|
||||
|
||||
|
@ -32,6 +34,16 @@ AppButton::AppButton(Widget* parent, const std::string &address, APP_LIST app, i
|
|||
}
|
||||
}
|
||||
|
||||
bool AppButton::gamepad_button_event(int jid, int button, int action) {
|
||||
if (action && button == NANOGUI_GAMEPAD_BUTTON_Y) {
|
||||
if (auto application = dynamic_cast<Application *>(screen())) {
|
||||
application->push_window<InputSettingsWindow>(m_app.id, m_app.name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Button::gamepad_button_event(jid, button, action);
|
||||
}
|
||||
|
||||
void AppButton::draw(NVGcontext *ctx) {
|
||||
int handle = BoxArtManager::manager()->texture_id(m_app.id);
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ class AppButton: public nanogui::Button {
|
|||
public:
|
||||
AppButton(Widget* parent, const std::string &address, APP_LIST app, int current_game);
|
||||
|
||||
bool gamepad_button_event(int jid, int button, int action) override;
|
||||
|
||||
void draw(NVGcontext *ctx) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
#include "LoadingOverlay.hpp"
|
||||
#include "AppButton.hpp"
|
||||
#include "StreamWindow.hpp"
|
||||
#include "GamepadMapper.hpp"
|
||||
|
||||
using namespace nanogui;
|
||||
|
||||
AppListWindow::AppListWindow(Widget *parent, const std::string &address): ContentWindow(parent, "Applications"), m_address(address) {
|
||||
set_left_pop_button();
|
||||
|
||||
container()->set_layout(new GridLayout(Orientation::Horizontal, 5, Alignment::Minimum, 30, 18));
|
||||
set_box_layout(Orientation::Vertical, Alignment::Minimum, 30, 10);
|
||||
}
|
||||
|
||||
void AppListWindow::window_appear() {
|
||||
|
@ -35,10 +36,16 @@ void AppListWindow::reload() {
|
|||
loader->dispose();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
container()->add<Label>("* For adjust Gamepad buttons and Combo keys for a specific game, select this game by a Dpad and press Y");
|
||||
container()->add<Widget>()->set_fixed_height(6);
|
||||
|
||||
auto button_container = container()->add<Widget>();
|
||||
button_container->set_layout(new GridLayout(Orientation::Horizontal, 5, Alignment::Minimum, 0, 18));
|
||||
|
||||
PAPP_LIST app = result.value();
|
||||
|
||||
while (app != NULL) {
|
||||
auto button = container()->add<AppButton>(m_address, *app, currentGame);
|
||||
auto button = button_container->add<AppButton>(m_address, *app, currentGame);
|
||||
button->set_callback([this, app] {
|
||||
run_game(app->id);
|
||||
});
|
||||
|
@ -57,6 +64,7 @@ void AppListWindow::reload() {
|
|||
}
|
||||
|
||||
void AppListWindow::run_game(int app_id) {
|
||||
GamepadMapper::mapper()->load_gamepad_map(app_id);
|
||||
push<StreamWindow>(m_address, app_id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue