From a1b081bfce66df328fb0aab5138bcbfee154cea5 Mon Sep 17 00:00:00 2001 From: h0neybadger Date: Sat, 26 Dec 2020 22:53:34 +0100 Subject: [PATCH] Fix switch GUI multiple hosts SetEventConnectedCallback --- switch/include/host.h | 1 - switch/src/gui.cpp | 13 +++++++------ switch/src/host.cpp | 2 -- switch/src/io.cpp | 6 ++++-- switch/src/main.cpp | 8 +++++++- switch/src/settings.cpp | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/switch/include/host.h b/switch/include/host.h index f0793eb..1966c1e 100644 --- a/switch/include/host.h +++ b/switch/include/host.h @@ -81,7 +81,6 @@ class Host ChiakiSession session; ChiakiOpusDecoder opus_decoder; ChiakiConnectVideoProfile video_profile; - ChiakiControllerState keyboard_state; friend class Settings; friend class DiscoveryManager; diff --git a/switch/src/gui.cpp b/switch/src/gui.cpp index 2d82fbd..3755cfe 100644 --- a/switch/src/gui.cpp +++ b/switch/src/gui.cpp @@ -37,10 +37,6 @@ HostInterface::HostInterface(IO * io, Host * host, Settings * settings) "Host configuration", true); this->addView(info); - // push opengl chiaki stream - // when the host is connected - this->io->SetEventConnectedCallback(std::bind(&HostInterface::Stream, this)); - this->io->SetEventQuitCallback(std::bind(&HostInterface::CloseStream, this, std::placeholders::_1)); } HostInterface::~HostInterface() @@ -173,7 +169,7 @@ void HostInterface::Connect(brls::View * view) } // ignore state for remote hosts - if(this->host->IsDiscovered() && this->host->IsReady()) + if(this->host->IsDiscovered() && !this->host->IsReady()) { // host in standby mode DIALOG(ptoyp, "Please turn on your PlayStation"); @@ -198,6 +194,11 @@ void HostInterface::ConnectSession() // user inputs are restored with the CloseStream brls::Application::blockInputs(); + // push opengl chiaki stream + // when the host is connected + this->io->SetEventConnectedCallback(std::bind(&HostInterface::Stream, this)); + this->io->SetEventQuitCallback(std::bind(&HostInterface::CloseStream, this, std::placeholders::_1)); + // connect host sesssion this->host->InitSession(this->io); this->host->StartSession(); @@ -596,7 +597,7 @@ PSRemotePlay::PSRemotePlay(IO * io, Host * host) void PSRemotePlay::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) { this->io->MainLoop(&this->state); - this->host->SendFeedbackState(&state); + this->host->SendFeedbackState(&this->state); // FPS calculation // this->frame_counter += 1; diff --git a/switch/src/host.cpp b/switch/src/host.cpp index 204a967..4dae777 100644 --- a/switch/src/host.cpp +++ b/switch/src/host.cpp @@ -148,8 +148,6 @@ int Host::InitSession(IO * user) memcpy(chiaki_connect_info.regist_key, this->rp_regist_key, sizeof(chiaki_connect_info.regist_key)); memcpy(chiaki_connect_info.morning, this->rp_key, sizeof(chiaki_connect_info.morning)); - // set keybord state to 0 - memset(&(this->keyboard_state), 0, sizeof(keyboard_state)); ChiakiErrorCode err = chiaki_session_init(&(this->session), &chiaki_connect_info, this->log); if(err != CHIAKI_ERR_SUCCESS) diff --git a/switch/src/io.cpp b/switch/src/io.cpp index bcbfd76..97c433a 100644 --- a/switch/src/io.cpp +++ b/switch/src/io.cpp @@ -439,6 +439,8 @@ bool IO::ReadGameKeys(SDL_Event *event, ChiakiControllerState *state) switch(event->type) { case SDL_JOYAXISMOTION: + // printf("SDL_JOYAXISMOTION jaxis %d axis %d value %d\n", + // event->jaxis.which, event->jaxis.axis, event->jaxis.value); if(event->jaxis.which == 0) { // left joystick @@ -474,7 +476,7 @@ bool IO::ReadGameKeys(SDL_Event *event, ChiakiControllerState *state) break; case SDL_JOYBUTTONDOWN: // printf("Joystick %d button %d DOWN\n", - // event->jbutton.which, event->jbutton.button); + // event->jbutton.which, event->jbutton.button); switch(event->jbutton.button) { case 0: state->buttons |= CHIAKI_CONTROLLER_BUTTON_MOON; break; // KEY_A @@ -501,7 +503,7 @@ bool IO::ReadGameKeys(SDL_Event *event, ChiakiControllerState *state) break; case SDL_JOYBUTTONUP: // printf("Joystick %d button %d UP\n", - // event->jbutton.which, event->jbutton.button); + // event->jbutton.which, event->jbutton.button); switch(event->jbutton.button) { case 0: state->buttons ^= CHIAKI_CONTROLLER_BUTTON_MOON; break; // KEY_A diff --git a/switch/src/main.cpp b/switch/src/main.cpp index 562f362..bdba8a8 100644 --- a/switch/src/main.cpp +++ b/switch/src/main.cpp @@ -56,7 +56,7 @@ static void initNxLink() s_nxlinkSock = nxlinkStdio(); if(s_nxlinkSock >= 0) - printf("initNxLink"); + printf("initNxLink\n"); else socketExit(); } @@ -83,6 +83,12 @@ extern "C" void userAppInit() // load socket custom config socketInitialize(&g_chiakiSocketInitConfig); setsysInitialize(); + + // padConfigureInput(1, HidNpadStyleSet_NpadStandard); + // PadState pad; + // padInitializeDefault(&pad); + + //hidInitializeTouchScreen(); } extern "C" void userAppExit() diff --git a/switch/src/settings.cpp b/switch/src/settings.cpp index 3488f6b..b1878ca 100644 --- a/switch/src/settings.cpp +++ b/switch/src/settings.cpp @@ -8,7 +8,7 @@ Settings::Settings() { #if defined(__SWITCH__) && !defined(CHIAKI_ENABLE_SWITCH_NXLINK) // null log for switch version - chiaki_log_init(&this->log, 0, chiaki_log_cb_print, NULL); + chiaki_log_init(&this->log, CHIAKI_LOG_ALL ^ CHIAKI_LOG_VERBOSE, chiaki_log_cb_print, NULL); #else chiaki_log_init(&this->log, CHIAKI_LOG_ALL ^ CHIAKI_LOG_VERBOSE, chiaki_log_cb_print, NULL); #endif