Add switch PS5 ChiakiTarget config

This commit is contained in:
h0neybadger 2020-12-24 19:55:05 +01:00 committed by Florian Märkl
commit 7378b31bc1
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
7 changed files with 193 additions and 98 deletions

View file

@ -56,7 +56,7 @@ class MainApplication
// add_host local settings // add_host local settings
std::string remote_display_name = ""; std::string remote_display_name = "";
std::string remote_addr = ""; std::string remote_addr = "";
int remote_ps4_version = 8000000; ChiakiTarget remote_ps_version = CHIAKI_TARGET_PS5_1;
bool BuildConfigurationMenu(brls::List *, Host * host = nullptr); bool BuildConfigurationMenu(brls::List *, Host * host = nullptr);
void BuildAddHostConfigurationMenu(brls::List *); void BuildAddHostConfigurationMenu(brls::List *);

View file

@ -42,8 +42,6 @@ class Host
//video config //video config
ChiakiVideoResolutionPreset video_resolution = CHIAKI_VIDEO_RESOLUTION_PRESET_720p; ChiakiVideoResolutionPreset video_resolution = CHIAKI_VIDEO_RESOLUTION_PRESET_720p;
ChiakiVideoFPSPreset video_fps = CHIAKI_VIDEO_FPS_PRESET_60; ChiakiVideoFPSPreset video_fps = CHIAKI_VIDEO_FPS_PRESET_60;
// info from discovery manager
int device_discovery_protocol_version = 0;
std::string host_type; std::string host_type;
// user info // user info
std::string psn_online_id = ""; std::string psn_online_id = "";
@ -55,11 +53,24 @@ class Host
std::function<void()> chiaki_regist_event_type_finished_failed = nullptr; std::function<void()> chiaki_regist_event_type_finished_failed = nullptr;
std::function<void()> chiaki_regist_event_type_finished_success = nullptr; std::function<void()> chiaki_regist_event_type_finished_success = nullptr;
// internal state
bool discovered = false;
bool registered = false;
// rp_key_data is true when rp_key, rp_regist_key, rp_key_type
bool rp_key_data = false;
std::string host_name;
// sony's host_id == mac addr without colon
std::string host_id;
std::string host_addr;
std::string ap_ssid; std::string ap_ssid;
std::string ap_bssid; std::string ap_bssid;
std::string ap_key; std::string ap_key;
std::string ap_name; std::string ap_name;
std::string server_nickname; std::string server_nickname;
ChiakiTarget target = CHIAKI_TARGET_PS4_UNKNOWN;
ChiakiDiscoveryHostState state = CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN;
// mac address = 48 bits // mac address = 48 bits
uint8_t server_mac[6] = {0}; uint8_t server_mac[6] = {0};
char rp_regist_key[CHIAKI_SESSION_AUTH_SIZE] = {0}; char rp_regist_key[CHIAKI_SESSION_AUTH_SIZE] = {0};
@ -74,20 +85,8 @@ class Host
friend class DiscoveryManager; friend class DiscoveryManager;
friend class Settings; friend class Settings;
public: public:
// internal state
ChiakiDiscoveryHostState state = CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN;
bool discovered = false;
bool registered = false;
// rp_key_data is true when rp_key, rp_regist_key, rp_key_type
bool rp_key_data = false;
std::string host_name;
int system_version = 0;
// sony's host_id == mac addr without colon
std::string host_id;
std::string host_addr;
Host(ChiakiLog * log, Settings * settings, std::string host_name); Host(ChiakiLog * log, Settings * settings, std::string host_name);
~Host(); ~Host();
bool GetVideoResolution(int * ret_width, int * ret_height);
int Register(std::string pin); int Register(std::string pin);
int Wakeup(); int Wakeup();
int InitSession(IO *); int InitSession(IO *);
@ -96,19 +95,19 @@ class Host
void StartSession(); void StartSession();
void SendFeedbackState(ChiakiControllerState*); void SendFeedbackState(ChiakiControllerState*);
void RegistCB(ChiakiRegistEvent *); void RegistCB(ChiakiRegistEvent *);
bool GetVideoResolution(int * ret_width, int * ret_height);
void SetRegistEventTypeFinishedCanceled(std::function<void()> chiaki_regist_event_type_finished_canceled) std::string GetHostName();
{ std::string GetHostAddr();
this->chiaki_regist_event_type_finished_canceled = chiaki_regist_event_type_finished_canceled; ChiakiTarget GetChiakiTarget();
}; void SetChiakiTarget(ChiakiTarget target);
void SetRegistEventTypeFinishedFailed(std::function<void()> chiaki_regist_event_type_finished_failed) void SetHostAddr(std::string host_addr);
{ void SetRegistEventTypeFinishedCanceled(std::function<void()> chiaki_regist_event_type_finished_canceled);
this->chiaki_regist_event_type_finished_failed = chiaki_regist_event_type_finished_failed; void SetRegistEventTypeFinishedFailed(std::function<void()> chiaki_regist_event_type_finished_failed);
}; void SetRegistEventTypeFinishedSuccess(std::function<void()> chiaki_regist_event_type_finished_success);
void SetRegistEventTypeFinishedSuccess(std::function<void()> chiaki_regist_event_type_finished_success) bool IsRegistered();
{ bool IsDiscovered();
this->chiaki_regist_event_type_finished_success = chiaki_regist_event_type_finished_success; bool IsReady();
}; bool HasRPkey();
}; };
#endif #endif

View file

@ -36,6 +36,7 @@ class Settings
RP_REGIST_KEY, RP_REGIST_KEY,
VIDEO_RESOLUTION, VIDEO_RESOLUTION,
VIDEO_FPS, VIDEO_FPS,
TARGET,
} ConfigurationItem; } ConfigurationItem;
// dummy parser implementation // dummy parser implementation
@ -51,6 +52,7 @@ class Settings
{ RP_REGIST_KEY, std::regex("^\\s*rp_regist_key\\s*=\\s*\"?([\\w/=+]+)\"?") }, { RP_REGIST_KEY, std::regex("^\\s*rp_regist_key\\s*=\\s*\"?([\\w/=+]+)\"?") },
{ VIDEO_RESOLUTION, std::regex("^\\s*video_resolution\\s*=\\s*\"?(1080p|720p|540p|360p)\"?") }, { VIDEO_RESOLUTION, std::regex("^\\s*video_resolution\\s*=\\s*\"?(1080p|720p|540p|360p)\"?") },
{ VIDEO_FPS, std::regex("^\\s*video_fps\\s*=\\s*\"?(60|30)\"?") }, { VIDEO_FPS, std::regex("^\\s*video_fps\\s*=\\s*\"?(60|30)\"?") },
{ TARGET, std::regex("^\\s*target\\s*=\\s*\"?(\\d+)\"?") },
}; };
ConfigurationItem ParseLine(std::string * line, std::string * value); ConfigurationItem ParseLine(std::string * line, std::string * value);
@ -75,6 +77,8 @@ class Settings
void SetVideoFPS(Host * host, ChiakiVideoFPSPreset value); void SetVideoFPS(Host * host, ChiakiVideoFPSPreset value);
void SetVideoResolution(Host * host, std::string value); void SetVideoResolution(Host * host, std::string value);
void SetVideoFPS(Host * host, std::string value); void SetVideoFPS(Host * host, std::string value);
bool SetChiakiTarget(Host * host, ChiakiTarget target);
bool SetChiakiTarget(Host * host, std::string value);
std::string GetHostAddr(Host * host); std::string GetHostAddr(Host * host);
std::string GetHostName(Host * host); std::string GetHostName(Host * host);
bool SetHostRPKeyType(Host * host, std::string value); bool SetHostRPKeyType(Host * host, std::string value);
@ -83,6 +87,7 @@ class Settings
std::string GetHostRPRegistKey(Host * host); std::string GetHostRPRegistKey(Host * host);
bool SetHostRPKey(Host * host, std::string rp_key_b64); bool SetHostRPKey(Host * host, std::string rp_key_b64);
bool SetHostRPRegistKey(Host * host, std::string rp_regist_key_b64); bool SetHostRPRegistKey(Host * host, std::string rp_regist_key_b64);
ChiakiTarget GetChiakiTarget(Host * host);
void ParseFile(); void ParseFile();
int WriteFile(); int WriteFile();
}; };

View file

@ -186,29 +186,19 @@ void DiscoveryManager::DiscoveryCB(ChiakiDiscoveryHost * discovered_host)
CHIAKI_LOGI(this->log, "--"); CHIAKI_LOGI(this->log, "--");
CHIAKI_LOGI(this->log, "Discovered Host:"); CHIAKI_LOGI(this->log, "Discovered Host:");
CHIAKI_LOGI(this->log, "State: %s", chiaki_discovery_host_state_string(discovered_host->state)); CHIAKI_LOGI(this->log, "State: %s", chiaki_discovery_host_state_string(discovered_host->state));
/*
host attr
uint32_t host_addr;
int system_version;
int device_discovery_protocol_version;
std::string host_name;
std::string host_type;
std::string host_id;
*/
host->state = discovered_host->state; host->state = discovered_host->state;
// add host ptr to list // add host ptr to list
if(discovered_host->system_version) if(discovered_host->system_version && discovered_host->device_discovery_protocol_version)
{ {
// example: 07020001 // example: 07020001
host->system_version = atoi(discovered_host->system_version); ChiakiTarget target = chiaki_discovery_host_system_version_target(discovered_host);
CHIAKI_LOGI(this->log, "System Version: %s", discovered_host->system_version); host->SetChiakiTarget(target);
}
if(discovered_host->device_discovery_protocol_version) CHIAKI_LOGI(this->log, "System Version: %s", discovered_host->system_version);
{
host->device_discovery_protocol_version = atoi(discovered_host->device_discovery_protocol_version);
CHIAKI_LOGI(this->log, "Device Discovery Protocol Version: %s", discovered_host->device_discovery_protocol_version); CHIAKI_LOGI(this->log, "Device Discovery Protocol Version: %s", discovered_host->device_discovery_protocol_version);
CHIAKI_LOGI(this->log, "PlayStation ChiakiTarget Version: %d", target);
} }
if(discovered_host->host_request_port) if(discovered_host->host_request_port)

View file

@ -53,13 +53,15 @@ void HostInterface::Register(IO * io, Host * host, Settings * settings, std::fun
// user must provide psn id for registration // user must provide psn id for registration
std::string account_id = settings->GetPSNAccountID(host); std::string account_id = settings->GetPSNAccountID(host);
std::string online_id = settings->GetPSNOnlineID(host); std::string online_id = settings->GetPSNOnlineID(host);
if(host->system_version >= 7000000 && account_id.length() <= 0) ChiakiTarget target = host->GetChiakiTarget();
if(target >= CHIAKI_TARGET_PS4_9 && account_id.length() <= 0)
{ {
// PS4 firmware > 7.0 // PS4 firmware > 7.0
DIALOG(upaid, "Undefined PSN Account ID (Please configure a valid psn_account_id)"); DIALOG(upaid, "Undefined PSN Account ID (Please configure a valid psn_account_id)");
return; return;
} }
else if( host->system_version < 7000000 && host->system_version > 0 && online_id.length() <= 0) else if(target < CHIAKI_TARGET_PS4_9 && online_id.length() <= 0)
{ {
// use oline ID for ps4 < 7.0 // use oline ID for ps4 < 7.0
DIALOG(upoid, "Undefined PSN Online ID (Please configure a valid psn_online_id)"); DIALOG(upoid, "Undefined PSN Online ID (Please configure a valid psn_online_id)");
@ -141,7 +143,7 @@ void HostInterface::Register()
void HostInterface::Wakeup(brls::View * view) void HostInterface::Wakeup(brls::View * view)
{ {
if(!this->host->rp_key_data) if(!this->host->HasRPkey())
{ {
// the host is not registered yet // the host is not registered yet
DIALOG(prypf, "Please register your PlayStation first"); DIALOG(prypf, "Please register your PlayStation first");
@ -163,7 +165,7 @@ void HostInterface::Wakeup(brls::View * view)
void HostInterface::Connect(brls::View * view) void HostInterface::Connect(brls::View * view)
{ {
// check that all requirements are met // check that all requirements are met
if(!this->host->discovered && !this->host->rp_key_data) if(!this->host->IsDiscovered() && !this->host->HasRPkey())
{ {
// at this point the host must be discovered or registered manually // at this point the host must be discovered or registered manually
// to validate the system_version accuracy // to validate the system_version accuracy
@ -171,14 +173,14 @@ void HostInterface::Connect(brls::View * view)
} }
// ignore state for remote hosts // ignore state for remote hosts
if(this->host->discovered && this->host->state != CHIAKI_DISCOVERY_HOST_STATE_READY) if(this->host->IsDiscovered() && this->host->IsReady())
{ {
// host in standby mode // host in standby mode
DIALOG(ptoyp, "Please turn on your PlayStation"); DIALOG(ptoyp, "Please turn on your PlayStation");
return; return;
} }
if(!this->host->rp_key_data) if(!this->host->HasRPkey())
{ {
this->Register(); this->Register();
} }
@ -309,14 +311,14 @@ bool MainApplication::Load()
{ {
// add host to the gui only if the host is registered or discovered // add host to the gui only if the host is registered or discovered
if(this->host_menuitems.find(&it->second) == this->host_menuitems.end() if(this->host_menuitems.find(&it->second) == this->host_menuitems.end()
&& (it->second.rp_key_data == true || it->second.discovered == true)) && (it->second.HasRPkey() == true || it->second.IsDiscovered() == true))
{ {
brls::List* new_host = new brls::List(); brls::List* new_host = new brls::List();
this->host_menuitems[&it->second] = new_host; this->host_menuitems[&it->second] = new_host;
// create host if udefined // create host if udefined
HostInterface host_menu = HostInterface(new_host, this->io, &it->second, this->settings); HostInterface host_menu = HostInterface(new_host, this->io, &it->second, this->settings);
BuildConfigurationMenu(new_host, &it->second); BuildConfigurationMenu(new_host, &it->second);
this->rootFrame->addTab(it->second.host_name.c_str(), new_host); this->rootFrame->addTab(it->second.GetHostName().c_str(), new_host);
} }
} }
} }
@ -325,6 +327,26 @@ bool MainApplication::Load()
bool MainApplication::BuildConfigurationMenu(brls::List * ls, Host * host) bool MainApplication::BuildConfigurationMenu(brls::List * ls, Host * host)
{ {
std::string psn_account_id_string = this->settings->GetPSNAccountID(host);
brls::ListItem* psn_account_id = new brls::ListItem("PSN Account ID", "PS5 or PS4 v7.0 and greater (base64 account_id)");
psn_account_id->setValue(psn_account_id_string.c_str());
auto psn_account_id_cb = [this, host, psn_account_id](brls::View * view)
{
char account_id[CHIAKI_PSN_ACCOUNT_ID_SIZE * 2] = {0};
bool input = this->io->ReadUserKeyboard(account_id, sizeof(account_id));
if(input)
{
// update gui
psn_account_id->setValue(account_id);
// push in setting
this->settings->SetPSNAccountID(host, account_id);
// write on disk
this->settings->WriteFile();
}
};
psn_account_id->getClickEvent()->subscribe(psn_account_id_cb);
ls->addView(psn_account_id);
std::string psn_online_id_string = this->settings->GetPSNOnlineID(host); std::string psn_online_id_string = this->settings->GetPSNOnlineID(host);
brls::ListItem* psn_online_id = new brls::ListItem("PSN Online ID"); brls::ListItem* psn_online_id = new brls::ListItem("PSN Online ID");
psn_online_id->setValue(psn_online_id_string.c_str()); psn_online_id->setValue(psn_online_id_string.c_str());
@ -345,26 +367,6 @@ bool MainApplication::BuildConfigurationMenu(brls::List * ls, Host * host)
psn_online_id->getClickEvent()->subscribe(psn_online_id_cb); psn_online_id->getClickEvent()->subscribe(psn_online_id_cb);
ls->addView(psn_online_id); ls->addView(psn_online_id);
std::string psn_account_id_string = this->settings->GetPSNAccountID(host);
brls::ListItem* psn_account_id = new brls::ListItem("PSN Account ID", "v7.0 and greater");
psn_account_id->setValue(psn_account_id_string.c_str());
auto psn_account_id_cb = [this, host, psn_account_id](brls::View * view)
{
char account_id[CHIAKI_PSN_ACCOUNT_ID_SIZE * 2] = {0};
bool input = this->io->ReadUserKeyboard(account_id, sizeof(account_id));
if(input)
{
// update gui
psn_account_id->setValue(account_id);
// push in setting
this->settings->SetPSNAccountID(host, account_id);
// write on disk
this->settings->WriteFile();
}
};
psn_account_id->getClickEvent()->subscribe(psn_account_id_cb);
ls->addView(psn_account_id);
int value; int value;
ChiakiVideoResolutionPreset resolution_preset = this->settings->GetVideoResolution(host); ChiakiVideoResolutionPreset resolution_preset = this->settings->GetVideoResolution(host);
switch(resolution_preset) switch(resolution_preset)
@ -517,25 +519,32 @@ void MainApplication::BuildAddHostConfigurationMenu(brls::List * add_host)
// brls::ListItem* port = new brls::ListItem("Remote session port", "tcp/udp 9295"); // brls::ListItem* port = new brls::ListItem("Remote session port", "tcp/udp 9295");
// brls::ListItem* port = new brls::ListItem("Remote stream port", "udp 9296"); // brls::ListItem* port = new brls::ListItem("Remote stream port", "udp 9296");
// brls::ListItem* port = new brls::ListItem("Remote Senkusha port", "udp 9297"); // brls::ListItem* port = new brls::ListItem("Remote Senkusha port", "udp 9297");
brls::SelectListItem* ps4_version = new brls::SelectListItem("PS4 Version", brls::SelectListItem* ps_version = new brls::SelectListItem("PlayStation Version",
{ "PS4 > 8", "7 < PS4 < 8", "PS4 < 7"}); { "PS5", "PS4 > 8", "7 < PS4 < 8", "PS4 < 7"});
auto ps4_version_cb = [this, ps4_version](int result) auto ps_version_cb = [this, ps_version](int result)
{ {
switch(result) switch(result)
{ {
case 0: case 0:
this->remote_ps4_version = 8000000; // ps5 v1
this->remote_ps_version = CHIAKI_TARGET_PS5_1;
break; break;
case 1: case 1:
this->remote_ps4_version = 7000000; // ps4 v8
this->remote_ps_version = CHIAKI_TARGET_PS4_10;
break; break;
case 2: case 2:
this->remote_ps4_version = 6000000; // ps4 v7
this->remote_ps_version = CHIAKI_TARGET_PS4_9;
break;
case 3:
// ps4 v6
this->remote_ps_version = CHIAKI_TARGET_PS4_8;
break; break;
} }
}; };
ps4_version->getValueSelectedEvent()->subscribe(ps4_version_cb); ps_version->getValueSelectedEvent()->subscribe(ps_version_cb);
add_host->addView(ps4_version); add_host->addView(ps_version);
brls::ListItem* register_host = new brls::ListItem("Register"); brls::ListItem* register_host = new brls::ListItem("Register");
auto register_host_cb = [this](brls::View * view) auto register_host_cb = [this](brls::View * view)
@ -553,9 +562,9 @@ void MainApplication::BuildAddHostConfigurationMenu(brls::List * add_host)
err = true; err = true;
} }
if(this->remote_ps4_version < 0) if(this->remote_ps_version < 0)
{ {
brls::Application::notify("No PS4 Version provided"); brls::Application::notify("No PlayStation Version provided");
err = true; err = true;
} }
@ -563,8 +572,8 @@ void MainApplication::BuildAddHostConfigurationMenu(brls::List * add_host)
return; return;
Host * host = this->settings->GetOrCreateHost(&this->remote_display_name); Host * host = this->settings->GetOrCreateHost(&this->remote_display_name);
host->host_addr = this->remote_addr; host->SetHostAddr(this->remote_addr);
host->system_version = this->remote_ps4_version; host->SetChiakiTarget(this->remote_ps_version);
HostInterface::Register(this->io, host, this->settings); HostInterface::Register(this->io, host, this->settings);
}; };

View file

@ -74,14 +74,13 @@ int Host::Register(std::string pin)
{ {
// use pin and accont_id to negociate secrets for session // use pin and accont_id to negociate secrets for session
// //
// convert psn_account_id into uint8_t[CHIAKI_PSN_ACCOUNT_ID_SIZE]
// CHIAKI_PSN_ACCOUNT_ID_SIZE == 8
std::string account_id = this->settings->GetPSNAccountID(this); std::string account_id = this->settings->GetPSNAccountID(this);
std::string online_id = this->settings->GetPSNOnlineID(this); std::string online_id = this->settings->GetPSNOnlineID(this);
size_t account_id_size = sizeof(uint8_t[CHIAKI_PSN_ACCOUNT_ID_SIZE]); size_t account_id_size = sizeof(uint8_t[CHIAKI_PSN_ACCOUNT_ID_SIZE]);
// PS4 firmware > 7.0 regist_info.target = this->target;
if(this->system_version >= 7000000)
if(this->target >= CHIAKI_TARGET_PS4_9)
{ {
// use AccountID for ps4 > 7.0 // use AccountID for ps4 > 7.0
if(account_id.length() > 0) if(account_id.length() > 0)
@ -95,12 +94,8 @@ int Host::Register(std::string pin)
CHIAKI_LOGE(this->log, "Undefined PSN Account ID (Please configure a valid psn_account_id)"); CHIAKI_LOGE(this->log, "Undefined PSN Account ID (Please configure a valid psn_account_id)");
return HOST_REGISTER_ERROR_SETTING_PSNACCOUNTID; return HOST_REGISTER_ERROR_SETTING_PSNACCOUNTID;
} }
if(this->system_version >= 8000000)
regist_info.target = CHIAKI_TARGET_PS4_10;
else
regist_info.target = CHIAKI_TARGET_PS4_9;
} }
else if( this->system_version < 7000000 && this->system_version > 0) else if(this->target > CHIAKI_TARGET_PS4_UNKNOWN)
{ {
// use oline ID for ps4 < 7.0 // use oline ID for ps4 < 7.0
if(online_id.length() > 0) if(online_id.length() > 0)
@ -113,7 +108,6 @@ int Host::Register(std::string pin)
CHIAKI_LOGE(this->log, "Undefined PSN Online ID (Please configure a valid psn_online_id)"); CHIAKI_LOGE(this->log, "Undefined PSN Online ID (Please configure a valid psn_online_id)");
return HOST_REGISTER_ERROR_SETTING_PSNONLINEID; return HOST_REGISTER_ERROR_SETTING_PSNONLINEID;
} }
regist_info.target = CHIAKI_TARGET_PS4_8;
} }
else else
{ {
@ -147,6 +141,12 @@ int Host::InitSession(IO * user)
chiaki_connect_info.host = this->host_addr.c_str(); chiaki_connect_info.host = this->host_addr.c_str();
chiaki_connect_info.video_profile = this->video_profile; chiaki_connect_info.video_profile = this->video_profile;
if(this->target >= CHIAKI_TARGET_PS5_UNKNOWN)
chiaki_connect_info.ps5 = true;
else
chiaki_connect_info.ps5 = false;
memcpy(chiaki_connect_info.regist_key, this->rp_regist_key, sizeof(chiaki_connect_info.regist_key)); 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)); memcpy(chiaki_connect_info.morning, this->rp_key, sizeof(chiaki_connect_info.morning));
// set keybord state to 0 // set keybord state to 0
@ -277,3 +277,62 @@ bool Host::GetVideoResolution(int * ret_width, int * ret_height)
return true; return true;
} }
std::string Host::GetHostName()
{
return this->host_name;
}
std::string Host::GetHostAddr()
{
return this->host_addr;
}
ChiakiTarget Host::GetChiakiTarget()
{
return this->target;
}
void Host::SetChiakiTarget(ChiakiTarget target)
{
this->target = target;
}
void Host::SetHostAddr(std::string host_addr)
{
this->host_addr = host_addr;
}
void Host::SetRegistEventTypeFinishedCanceled(std::function<void()> chiaki_regist_event_type_finished_canceled)
{
this->chiaki_regist_event_type_finished_canceled = chiaki_regist_event_type_finished_canceled;
}
void Host::SetRegistEventTypeFinishedFailed(std::function<void()> chiaki_regist_event_type_finished_failed)
{
this->chiaki_regist_event_type_finished_failed = chiaki_regist_event_type_finished_failed;
}
void Host::SetRegistEventTypeFinishedSuccess(std::function<void()> chiaki_regist_event_type_finished_success)
{
this->chiaki_regist_event_type_finished_success = chiaki_regist_event_type_finished_success;
}
bool Host::IsRegistered()
{
return this->registered;
}
bool Host::IsDiscovered()
{
return this->discovered;
}
bool Host::IsReady()
{
return this->state == CHIAKI_DISCOVERY_HOST_STATE_READY;
}
bool Host::HasRPkey()
{
return this->rp_key_data;
}

View file

@ -262,7 +262,7 @@ void Settings::SetCPUOverclock(Host * host, std::string value)
std::string Settings::GetHostAddr(Host * host) std::string Settings::GetHostAddr(Host * host)
{ {
if(host != nullptr) if(host != nullptr)
return host->host_addr; return host->GetHostAddr();
else else
CHIAKI_LOGE(this->log, "Cannot GetHostAddr from nullptr host"); CHIAKI_LOGE(this->log, "Cannot GetHostAddr from nullptr host");
return ""; return "";
@ -271,7 +271,7 @@ std::string Settings::GetHostAddr(Host * host)
std::string Settings::GetHostName(Host * host) std::string Settings::GetHostName(Host * host)
{ {
if(host != nullptr) if(host != nullptr)
return host->host_name; return host->GetHostName();
else else
CHIAKI_LOGE(this->log, "Cannot GetHostName from nullptr host"); CHIAKI_LOGE(this->log, "Cannot GetHostName from nullptr host");
return ""; return "";
@ -386,6 +386,31 @@ bool Settings::SetHostRPRegistKey(Host * host, std::string rp_regist_key_b64)
return false; return false;
} }
ChiakiTarget Settings::GetChiakiTarget(Host * host)
{
return host->GetChiakiTarget();
}
bool Settings::SetChiakiTarget(Host * host, ChiakiTarget target)
{
if(host != nullptr)
{
host->SetChiakiTarget(target);
return true;
}
else
{
CHIAKI_LOGE(this->log, "Cannot SetChiakiTarget from nullptr host");
return false;
}
}
bool Settings::SetChiakiTarget(Host * host, std::string value)
{
// TODO Check possible target values
return this->SetChiakiTarget(host, static_cast<ChiakiTarget>(std::atoi(value.c_str())));
}
void Settings::ParseFile() void Settings::ParseFile()
{ {
CHIAKI_LOGI(this->log, "Parse config file %s", this->filename); CHIAKI_LOGI(this->log, "Parse config file %s", this->filename);
@ -456,6 +481,11 @@ void Settings::ParseFile()
case VIDEO_FPS: case VIDEO_FPS:
this->SetVideoFPS(current_host, value); this->SetVideoFPS(current_host, value);
break; break;
case TARGET:
CHIAKI_LOGV(this->log, "TARGET %s", value.c_str());
if(current_host != nullptr)
this->SetChiakiTarget(current_host, value);
break;
} // ci switch } // ci switch
if(rp_key_b && rp_regist_key_b && rp_key_type_b) if(rp_key_b && rp_regist_key_b && rp_key_type_b)
// the current host contains rp key data // the current host contains rp key data
@ -509,8 +539,10 @@ int Settings::WriteFile()
CHIAKI_LOGD(this->log, "Write Host config file %s", it->first.c_str()); CHIAKI_LOGD(this->log, "Write Host config file %s", it->first.c_str());
config_file << "[" << it->first << "]\n" config_file << "[" << it->first << "]\n"
<< "host_addr = \"" << it->second.host_addr << "\"\n"; << "host_addr = \"" << it->second.GetHostAddr() << "\"\n"
<< "target = " << it->second.GetChiakiTarget() << "\"\n";
config_file << "target = \"" << it->second.psn_account_id << "\"\n";
if(it->second.video_resolution) if(it->second.video_resolution)
config_file << "video_resolution = \"" config_file << "video_resolution = \""
<< this->ResolutionPresetToString(this->GetVideoResolution(&it->second)) << this->ResolutionPresetToString(this->GetVideoResolution(&it->second))
@ -535,7 +567,8 @@ int Settings::WriteFile()
config_file << "rp_key = \"" << this->GetHostRPKey(&it->second) << "\"\n" config_file << "rp_key = \"" << this->GetHostRPKey(&it->second) << "\"\n"
<< "rp_regist_key = \"" << this->GetHostRPRegistKey(&it->second) << "\"\n" << "rp_regist_key = \"" << this->GetHostRPRegistKey(&it->second) << "\"\n"
<< "rp_key_type = " << rp_key_type << "\n"; << "rp_key_type = " << rp_key_type << "\n";
} // }
config_file << "\n"; config_file << "\n";
} // for host } // for host
} // is_open } // is_open