mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-01 14:24:02 +00:00
http: Add a screen under tools for the server.
This commit is contained in:
parent
0c0525ed87
commit
f4e2ca0359
@ -893,6 +893,7 @@ set(NativeAppSource
|
||||
UI/GamepadEmu.cpp
|
||||
UI/OnScreenDisplay.cpp
|
||||
UI/ControlMappingScreen.cpp
|
||||
UI/RemoteISOScreen.cpp
|
||||
UI/ReportScreen.cpp
|
||||
UI/SavedataScreen.cpp
|
||||
UI/Store.cpp
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "UI/ControlMappingScreen.h"
|
||||
#include "UI/DevScreens.h"
|
||||
#include "UI/DisplayLayoutScreen.h"
|
||||
#include "UI/RemoteISOScreen.h"
|
||||
#include "UI/SavedataScreen.h"
|
||||
#include "UI/TouchControlLayoutScreen.h"
|
||||
#include "UI/TouchControlVisibilityScreen.h"
|
||||
@ -499,6 +500,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
tools->Add(new Choice(sa->T("Savedata Manager")))->OnClick.Handle(this, &GameSettingsScreen::OnSavedataManager);
|
||||
tools->Add(new Choice(dev->T("System Information")))->OnClick.Handle(this, &GameSettingsScreen::OnSysInfo);
|
||||
tools->Add(new Choice(sy->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);
|
||||
tools->Add(new Choice(sy->T("Remote disc streaming")))->OnClick.Handle(this, &GameSettingsScreen::OnRemoteISO);
|
||||
|
||||
// System
|
||||
ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
@ -993,11 +995,17 @@ UI::EventReturn GameSettingsScreen::OnPostProcShaderChange(UI::EventParams &e) {
|
||||
Reporting::UpdateConfig();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnDeveloperTools(UI::EventParams &e) {
|
||||
screenManager()->push(new DeveloperToolsScreen());
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnRemoteISO(UI::EventParams &e) {
|
||||
screenManager()->push(new RemoteISOScreen());
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnControlMapping(UI::EventParams &e) {
|
||||
screenManager()->push(new ControlMappingScreen());
|
||||
return UI::EVENT_DONE;
|
||||
@ -1006,7 +1014,7 @@ UI::EventReturn GameSettingsScreen::OnControlMapping(UI::EventParams &e) {
|
||||
UI::EventReturn GameSettingsScreen::OnTouchControlLayout(UI::EventParams &e) {
|
||||
screenManager()->push(new TouchControlLayoutScreen());
|
||||
return UI::EVENT_DONE;
|
||||
};
|
||||
}
|
||||
|
||||
//when the tilt event type is modified, we need to reset all tilt settings.
|
||||
//refer to the ResetTiltEvents() function for a detailed explanation.
|
||||
|
@ -73,6 +73,7 @@ private:
|
||||
UI::EventReturn OnPostProcShader(UI::EventParams &e);
|
||||
UI::EventReturn OnPostProcShaderChange(UI::EventParams &e);
|
||||
UI::EventReturn OnDeveloperTools(UI::EventParams &e);
|
||||
UI::EventReturn OnRemoteISO(UI::EventParams &e);
|
||||
UI::EventReturn OnChangeNickname(UI::EventParams &e);
|
||||
UI::EventReturn OnChangeproAdhocServerAddress(UI::EventParams &e);
|
||||
UI::EventReturn OnChangeMacAddress(UI::EventParams &e);
|
||||
|
141
UI/RemoteISOScreen.cpp
Normal file
141
UI/RemoteISOScreen.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
// Copyright (c) 2014- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "i18n/i18n.h"
|
||||
#include "net/http_server.h"
|
||||
#include "net/resolve.h"
|
||||
#include "net/sinks.h"
|
||||
#include "thread/thread.h"
|
||||
#include "thread/threadutil.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/Config.h"
|
||||
#include "UI/RemoteISOScreen.h"
|
||||
|
||||
using namespace UI;
|
||||
|
||||
enum class ServerStatus {
|
||||
STOPPED,
|
||||
STARTING,
|
||||
RUNNING,
|
||||
STOPPING,
|
||||
};
|
||||
|
||||
static std::thread *serverThread = nullptr;
|
||||
static ServerStatus serverStatus;
|
||||
static recursive_mutex serverStatusLock;
|
||||
static condition_variable serverStatusCond;
|
||||
|
||||
static void UpdateStatus(ServerStatus s) {
|
||||
lock_guard guard(serverStatusLock);
|
||||
serverStatus = s;
|
||||
serverStatusCond.notify_one();
|
||||
}
|
||||
|
||||
static ServerStatus RetrieveStatus() {
|
||||
lock_guard guard(serverStatusLock);
|
||||
return serverStatus;
|
||||
}
|
||||
|
||||
static void ExecuteServer() {
|
||||
setCurrentThreadName("HTTPServer");
|
||||
|
||||
net::Init();
|
||||
auto http = new http::Server(new threading::SameThreadExecutor());
|
||||
|
||||
http->Listen(0);
|
||||
// TODO: Report local IP and port.
|
||||
UpdateStatus(ServerStatus::RUNNING);
|
||||
|
||||
while (RetrieveStatus() == ServerStatus::RUNNING) {
|
||||
http->RunSlice(5.0);
|
||||
}
|
||||
|
||||
net::Shutdown();
|
||||
|
||||
UpdateStatus(ServerStatus::STOPPED);
|
||||
}
|
||||
|
||||
RemoteISOScreen::RemoteISOScreen() {
|
||||
}
|
||||
|
||||
void RemoteISOScreen::CreateViews() {
|
||||
I18NCategory *rp = GetI18NCategory("Reporting");
|
||||
I18NCategory *di = GetI18NCategory("Dialog");
|
||||
I18NCategory *sy = GetI18NCategory("System");
|
||||
|
||||
Margins actionMenuMargins(0, 20, 15, 0);
|
||||
Margins contentMargins(0, 20, 5, 5);
|
||||
ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT, 0.4f, contentMargins));
|
||||
LinearLayout *leftColumnItems = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(WRAP_CONTENT, FILL_PARENT));
|
||||
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
|
||||
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL);
|
||||
|
||||
leftColumnItems->Add(new TextView(sy->T("RemoteISOWifi", "Note: Connect both devices to the same wifi"), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
|
||||
rightColumnItems->SetSpacing(0.0f);
|
||||
rightColumnItems->Add(new Choice(rp->T("Browse Games")));
|
||||
if (serverStatus != ServerStatus::STOPPED) {
|
||||
rightColumnItems->Add(new Choice(rp->T("Stop Sharing")))->OnClick.Handle(this, &RemoteISOScreen::HandleStopServer);
|
||||
} else {
|
||||
rightColumnItems->Add(new Choice(rp->T("Share Games (Server)")))->OnClick.Handle(this, &RemoteISOScreen::HandleStartServer);
|
||||
}
|
||||
|
||||
rightColumnItems->Add(new Spacer(25.0));
|
||||
rightColumnItems->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
|
||||
root_ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f));
|
||||
root_->Add(leftColumn);
|
||||
root_->Add(rightColumn);
|
||||
|
||||
leftColumn->Add(leftColumnItems);
|
||||
rightColumn->Add(rightColumnItems);
|
||||
}
|
||||
|
||||
UI::EventReturn RemoteISOScreen::HandleStartServer(UI::EventParams &e) {
|
||||
lock_guard guard(serverStatusLock);
|
||||
|
||||
if (serverStatus != ServerStatus::STOPPED) {
|
||||
return EVENT_SKIPPED;
|
||||
}
|
||||
|
||||
serverStatus = ServerStatus::STARTING;
|
||||
serverThread = new std::thread(&ExecuteServer);
|
||||
serverThread->detach();
|
||||
|
||||
serverStatusCond.wait(serverStatusLock);
|
||||
RecreateViews();
|
||||
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn RemoteISOScreen::HandleStopServer(UI::EventParams &e) {
|
||||
lock_guard guard(serverStatusLock);
|
||||
|
||||
if (serverStatus != ServerStatus::RUNNING) {
|
||||
return EVENT_SKIPPED;
|
||||
}
|
||||
|
||||
serverStatus = ServerStatus::STOPPING;
|
||||
serverStatusCond.wait(serverStatusLock);
|
||||
delete serverThread;
|
||||
serverThread = nullptr;
|
||||
|
||||
RecreateViews();
|
||||
|
||||
return EVENT_DONE;
|
||||
}
|
34
UI/RemoteISOScreen.h
Normal file
34
UI/RemoteISOScreen.h
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2016- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base/functional.h"
|
||||
#include "ui/ui_screen.h"
|
||||
#include "ui/viewgroup.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
|
||||
class RemoteISOScreen : public UIScreenWithBackground {
|
||||
public:
|
||||
RemoteISOScreen();
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
|
||||
UI::EventReturn HandleStartServer(UI::EventParams &e);
|
||||
UI::EventReturn HandleStopServer(UI::EventParams &e);
|
||||
};
|
@ -37,6 +37,7 @@
|
||||
<ClCompile Include="OnScreenDisplay.cpp" />
|
||||
<ClCompile Include="PauseScreen.cpp" />
|
||||
<ClCompile Include="ProfilerDraw.cpp" />
|
||||
<ClCompile Include="RemoteISOScreen.cpp" />
|
||||
<ClCompile Include="ReportScreen.cpp" />
|
||||
<ClCompile Include="SavedataScreen.cpp" />
|
||||
<ClCompile Include="Store.cpp" />
|
||||
@ -66,6 +67,7 @@
|
||||
<ClInclude Include="OnScreenDisplay.h" />
|
||||
<ClInclude Include="PauseScreen.h" />
|
||||
<ClInclude Include="ProfilerDraw.h" />
|
||||
<ClInclude Include="RemoteISOScreen.h" />
|
||||
<ClInclude Include="ReportScreen.h" />
|
||||
<ClInclude Include="SavedataScreen.h" />
|
||||
<ClInclude Include="Store.h" />
|
||||
|
@ -66,6 +66,9 @@
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DisplayLayoutEditor.cpp" />
|
||||
<ClCompile Include="RemoteISOScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameInfoCache.h" />
|
||||
@ -133,6 +136,9 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="DisplayLayoutEditor.h" />
|
||||
<ClInclude Include="HostTypes.h" />
|
||||
<ClInclude Include="RemoteISOScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Screens">
|
||||
|
@ -395,6 +395,7 @@ LOCAL_SRC_FILES := \
|
||||
$(SRC)/UI/EmuScreen.cpp \
|
||||
$(SRC)/UI/MainScreen.cpp \
|
||||
$(SRC)/UI/MiscScreens.cpp \
|
||||
$(SRC)/UI/RemoteISOScreen.cpp \
|
||||
$(SRC)/UI/ReportScreen.cpp \
|
||||
$(SRC)/UI/PauseScreen.cpp \
|
||||
$(SRC)/UI/SavedataScreen.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user