mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 13:09:39 -07:00
Fix switch PS5 discovery & wakeup PORT
This commit is contained in:
parent
05b22e15f1
commit
ad9b0f3d19
6 changed files with 132 additions and 134 deletions
|
@ -6,25 +6,26 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <chiaki/log.h>
|
|
||||||
#include <chiaki/discoveryservice.h>
|
#include <chiaki/discoveryservice.h>
|
||||||
|
#include <chiaki/log.h>
|
||||||
|
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
static void Discovery(ChiakiDiscoveryHost*, void*);
|
static void Discovery(ChiakiDiscoveryHost *, void *);
|
||||||
|
|
||||||
class DiscoveryManager
|
class DiscoveryManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Settings * settings;
|
Settings * settings = nullptr;
|
||||||
ChiakiLog * log;
|
ChiakiLog * log = nullptr;
|
||||||
ChiakiDiscoveryService service;
|
ChiakiDiscoveryService service;
|
||||||
ChiakiDiscovery discovery;
|
ChiakiDiscovery discovery;
|
||||||
struct sockaddr * host_addr;
|
struct sockaddr * host_addr = nullptr;
|
||||||
size_t host_addr_len;
|
size_t host_addr_len = 0;
|
||||||
uint32_t GetIPv4BroadcastAddr();
|
uint32_t GetIPv4BroadcastAddr();
|
||||||
bool service_enable;
|
bool service_enable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef enum hoststate
|
typedef enum hoststate
|
||||||
{
|
{
|
||||||
|
@ -34,13 +35,13 @@ class DiscoveryManager
|
||||||
SHUTDOWN,
|
SHUTDOWN,
|
||||||
} HostState;
|
} HostState;
|
||||||
|
|
||||||
DiscoveryManager(Settings *settings);
|
DiscoveryManager();
|
||||||
~DiscoveryManager();
|
~DiscoveryManager();
|
||||||
void SetService(bool);
|
void SetService(bool);
|
||||||
int Send();
|
int Send();
|
||||||
int Send(struct sockaddr *host_addr, size_t host_addr_len);
|
int Send(struct sockaddr * host_addr, size_t host_addr_len);
|
||||||
int Send(const char *);
|
int Send(const char *);
|
||||||
void DiscoveryCB(ChiakiDiscoveryHost*);
|
void DiscoveryCB(ChiakiDiscoveryHost *);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //CHIAKI_DISCOVERYMANAGER_H
|
#endif //CHIAKI_DISCOVERYMANAGER_H
|
||||||
|
|
|
@ -3,22 +3,22 @@
|
||||||
#ifndef CHIAKI_HOST_H
|
#ifndef CHIAKI_HOST_H
|
||||||
#define CHIAKI_HOST_H
|
#define CHIAKI_HOST_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <chiaki/log.h>
|
|
||||||
#include <chiaki/regist.h>
|
|
||||||
#include <chiaki/discovery.h>
|
|
||||||
#include <chiaki/opusdecoder.h>
|
|
||||||
#include <chiaki/controller.h>
|
#include <chiaki/controller.h>
|
||||||
|
#include <chiaki/discovery.h>
|
||||||
|
#include <chiaki/log.h>
|
||||||
|
#include <chiaki/opusdecoder.h>
|
||||||
|
#include <chiaki/regist.h>
|
||||||
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
class DiscoveryManager;
|
class DiscoveryManager;
|
||||||
static void Discovery(ChiakiDiscoveryHost*, void *);
|
static void Discovery(ChiakiDiscoveryHost *, void *);
|
||||||
static void InitAudioCB(unsigned int channels, unsigned int rate, void * user);
|
static void InitAudioCB(unsigned int channels, unsigned int rate, void * user);
|
||||||
static bool VideoCB(uint8_t * buf, size_t buf_size, void * user);
|
static bool VideoCB(uint8_t * buf, size_t buf_size, void * user);
|
||||||
static void AudioCB(int16_t * buf, size_t samples_count, void * user);
|
static void AudioCB(int16_t * buf, size_t samples_count, void * user);
|
||||||
|
@ -82,10 +82,11 @@ class Host
|
||||||
ChiakiOpusDecoder opus_decoder;
|
ChiakiOpusDecoder opus_decoder;
|
||||||
ChiakiConnectVideoProfile video_profile;
|
ChiakiConnectVideoProfile video_profile;
|
||||||
ChiakiControllerState keyboard_state;
|
ChiakiControllerState keyboard_state;
|
||||||
friend class DiscoveryManager;
|
|
||||||
friend class Settings;
|
friend class Settings;
|
||||||
|
friend class DiscoveryManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Host(ChiakiLog * log, Settings * settings, std::string host_name);
|
Host(std::string host_name);
|
||||||
~Host();
|
~Host();
|
||||||
int Register(std::string pin);
|
int Register(std::string pin);
|
||||||
int Wakeup();
|
int Wakeup();
|
||||||
|
@ -93,7 +94,7 @@ class Host
|
||||||
int FiniSession();
|
int FiniSession();
|
||||||
void StopSession();
|
void StopSession();
|
||||||
void StartSession();
|
void StartSession();
|
||||||
void SendFeedbackState(ChiakiControllerState*);
|
void SendFeedbackState(ChiakiControllerState *);
|
||||||
void RegistCB(ChiakiRegistEvent *);
|
void RegistCB(ChiakiRegistEvent *);
|
||||||
bool GetVideoResolution(int * ret_width, int * ret_height);
|
bool GetVideoResolution(int * ret_width, int * ret_height);
|
||||||
std::string GetHostName();
|
std::string GetHostName();
|
||||||
|
@ -108,6 +109,7 @@ class Host
|
||||||
bool IsDiscovered();
|
bool IsDiscovered();
|
||||||
bool IsReady();
|
bool IsReady();
|
||||||
bool HasRPkey();
|
bool HasRPkey();
|
||||||
|
bool IsPS5();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,32 +4,31 @@
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <discoverymanager.h>
|
#include <discoverymanager.h>
|
||||||
|
|
||||||
#define PING_MS 500
|
#define PING_MS 500
|
||||||
#define HOSTS_MAX 16
|
#define HOSTS_MAX 16
|
||||||
#define DROP_PINGS 3
|
#define DROP_PINGS 3
|
||||||
|
|
||||||
static void Discovery(ChiakiDiscoveryHost * discovered_hosts, size_t hosts_count, void * user)
|
static void Discovery(ChiakiDiscoveryHost * discovered_hosts, size_t hosts_count, void * user)
|
||||||
{
|
{
|
||||||
DiscoveryManager * dm = (DiscoveryManager *) user;
|
DiscoveryManager * dm = (DiscoveryManager *)user;
|
||||||
for(size_t i=0; i < hosts_count; i++)
|
for(size_t i = 0; i < hosts_count; i++)
|
||||||
{
|
{
|
||||||
dm->DiscoveryCB(discovered_hosts+i);
|
dm->DiscoveryCB(discovered_hosts + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiscoveryManager::DiscoveryManager()
|
||||||
DiscoveryManager::DiscoveryManager(Settings *settings)
|
|
||||||
: settings(settings), host_addr(nullptr), host_addr_len(0)
|
|
||||||
{
|
{
|
||||||
this->log = this->settings->GetLogger();
|
this->settings = Settings::GetInstance();
|
||||||
|
this->log = this->settings->GetLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscoveryManager::~DiscoveryManager()
|
DiscoveryManager::~DiscoveryManager()
|
||||||
|
@ -87,12 +86,12 @@ uint32_t DiscoveryManager::GetIPv4BroadcastAddr()
|
||||||
uint32_t current_addr, subnet_mask;
|
uint32_t current_addr, subnet_mask;
|
||||||
// init nintendo net interface service
|
// init nintendo net interface service
|
||||||
Result rc = nifmInitialize(NifmServiceType_User);
|
Result rc = nifmInitialize(NifmServiceType_User);
|
||||||
if (R_SUCCEEDED(rc))
|
if(R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
// read current IP and netmask
|
// read current IP and netmask
|
||||||
rc = nifmGetCurrentIpConfigInfo(
|
rc = nifmGetCurrentIpConfigInfo(
|
||||||
¤t_addr, &subnet_mask,
|
¤t_addr, &subnet_mask,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
nifmExit();
|
nifmExit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -106,15 +105,13 @@ uint32_t DiscoveryManager::GetIPv4BroadcastAddr()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int DiscoveryManager::Send(struct sockaddr *host_addr, size_t host_addr_len)
|
int DiscoveryManager::Send(struct sockaddr * host_addr, size_t host_addr_len)
|
||||||
{
|
{
|
||||||
if(!host_addr)
|
if(!host_addr)
|
||||||
{
|
{
|
||||||
CHIAKI_LOGE(log, "Null sockaddr");
|
CHIAKI_LOGE(log, "Null sockaddr");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
((struct sockaddr_in *)host_addr)->sin_port = htons(CHIAKI_DISCOVERY_PORT);
|
|
||||||
|
|
||||||
ChiakiDiscoveryPacket packet;
|
ChiakiDiscoveryPacket packet;
|
||||||
memset(&packet, 0, sizeof(packet));
|
memset(&packet, 0, sizeof(packet));
|
||||||
packet.cmd = CHIAKI_DISCOVERY_CMD_SRCH;
|
packet.cmd = CHIAKI_DISCOVERY_CMD_SRCH;
|
||||||
|
@ -136,7 +133,7 @@ int DiscoveryManager::Send(const char * discover_ip_dest)
|
||||||
struct sockaddr * host_addr = nullptr;
|
struct sockaddr * host_addr = nullptr;
|
||||||
socklen_t host_addr_len = 0;
|
socklen_t host_addr_len = 0;
|
||||||
|
|
||||||
for(struct addrinfo *ai=host_addrinfos; ai; ai=ai->ai_next)
|
for(struct addrinfo * ai = host_addrinfos; ai; ai = ai->ai_next)
|
||||||
{
|
{
|
||||||
if(ai->ai_protocol != IPPROTO_UDP)
|
if(ai->ai_protocol != IPPROTO_UDP)
|
||||||
continue;
|
continue;
|
||||||
|
@ -165,7 +162,6 @@ int DiscoveryManager::Send()
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_addr.s_addr = GetIPv4BroadcastAddr();
|
addr.sin_addr.s_addr = GetIPv4BroadcastAddr();
|
||||||
addr.sin_port = htons(CHIAKI_DISCOVERY_PORT);
|
|
||||||
|
|
||||||
this->host_addr_len = sizeof(sockaddr_in);
|
this->host_addr_len = sizeof(sockaddr_in);
|
||||||
this->host_addr = (struct sockaddr *)malloc(host_addr_len);
|
this->host_addr = (struct sockaddr *)malloc(host_addr_len);
|
||||||
|
@ -174,14 +170,13 @@ int DiscoveryManager::Send()
|
||||||
return DiscoveryManager::Send(this->host_addr, this->host_addr_len);
|
return DiscoveryManager::Send(this->host_addr, this->host_addr_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DiscoveryManager::DiscoveryCB(ChiakiDiscoveryHost * discovered_host)
|
void DiscoveryManager::DiscoveryCB(ChiakiDiscoveryHost * discovered_host)
|
||||||
{
|
{
|
||||||
// the user ptr is passed as
|
// the user ptr is passed as
|
||||||
// chiaki_discovery_thread_start arg
|
// chiaki_discovery_thread_start arg
|
||||||
|
|
||||||
std::string key = discovered_host->host_name;
|
std::string key = discovered_host->host_name;
|
||||||
Host *host = this->settings->GetOrCreateHost(&key);
|
Host * host = this->settings->GetOrCreateHost(&key);
|
||||||
|
|
||||||
CHIAKI_LOGI(this->log, "--");
|
CHIAKI_LOGI(this->log, "--");
|
||||||
CHIAKI_LOGI(this->log, "Discovered Host:");
|
CHIAKI_LOGI(this->log, "Discovered Host:");
|
||||||
|
@ -230,4 +225,3 @@ void DiscoveryManager::DiscoveryCB(ChiakiDiscoveryHost * discovered_host)
|
||||||
|
|
||||||
CHIAKI_LOGI(this->log, "--");
|
CHIAKI_LOGI(this->log, "--");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
||||||
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <chiaki/base64.h>
|
#include <chiaki/base64.h>
|
||||||
|
|
||||||
#include "io.h"
|
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
static void InitAudioCB(unsigned int channels, unsigned int rate, void * user)
|
static void InitAudioCB(unsigned int channels, unsigned int rate, void * user)
|
||||||
{
|
{
|
||||||
IO * io = (IO *) user;
|
IO * io = (IO *)user;
|
||||||
io->InitAudioCB(channels, rate);
|
io->InitAudioCB(channels, rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool VideoCB(uint8_t * buf, size_t buf_size, void * user)
|
static bool VideoCB(uint8_t * buf, size_t buf_size, void * user)
|
||||||
{
|
{
|
||||||
IO * io = (IO *) user;
|
IO * io = (IO *)user;
|
||||||
return io->VideoCB(buf, buf_size);
|
return io->VideoCB(buf, buf_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AudioCB(int16_t * buf, size_t samples_count, void * user)
|
static void AudioCB(int16_t * buf, size_t samples_count, void * user)
|
||||||
{
|
{
|
||||||
IO * io = (IO *) user;
|
IO * io = (IO *)user;
|
||||||
io->AudioCB(buf, samples_count);
|
io->AudioCB(buf, samples_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EventCB(ChiakiEvent * event, void * user)
|
static void EventCB(ChiakiEvent * event, void * user)
|
||||||
{
|
{
|
||||||
IO * io = (IO *) user;
|
IO * io = (IO *)user;
|
||||||
io->EventCB(event);
|
io->EventCB(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RegistEventCB(ChiakiRegistEvent * event, void * user)
|
static void RegistEventCB(ChiakiRegistEvent * event, void * user)
|
||||||
{
|
{
|
||||||
Host * host = (Host *) user;
|
Host * host = (Host *)user;
|
||||||
host->RegistCB(event);
|
host->RegistCB(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
Host::Host(ChiakiLog * log, Settings * settings, std::string host_name)
|
Host::Host(std::string host_name)
|
||||||
: log(log), settings(settings), host_name(host_name)
|
: host_name(host_name)
|
||||||
{
|
{
|
||||||
|
this->settings = Settings::GetInstance();
|
||||||
|
this->log = settings->GetLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
Host::~Host()
|
Host::~Host()
|
||||||
|
@ -55,14 +55,16 @@ int Host::Wakeup()
|
||||||
CHIAKI_LOGE(this->log, "Given registkey is too long");
|
CHIAKI_LOGE(this->log, "Given registkey is too long");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (strlen(this->rp_regist_key) <=0)
|
else if(strlen(this->rp_regist_key) <= 0)
|
||||||
{
|
{
|
||||||
CHIAKI_LOGE(this->log, "Given registkey is not defined");
|
CHIAKI_LOGE(this->log, "Given registkey is not defined");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t credential = (uint64_t)strtoull(this->rp_regist_key, NULL, 16);
|
uint64_t credential = (uint64_t)strtoull(this->rp_regist_key, NULL, 16);
|
||||||
ChiakiErrorCode ret = chiaki_discovery_wakeup(this->log, NULL, host_addr.c_str(), credential);
|
ChiakiErrorCode ret = chiaki_discovery_wakeup(this->log, NULL,
|
||||||
|
host_addr.c_str(), credential, this->IsPS5());
|
||||||
|
|
||||||
if(ret == CHIAKI_ERR_SUCCESS)
|
if(ret == CHIAKI_ERR_SUCCESS)
|
||||||
{
|
{
|
||||||
//FIXME
|
//FIXME
|
||||||
|
@ -86,7 +88,7 @@ int Host::Register(std::string pin)
|
||||||
if(account_id.length() > 0)
|
if(account_id.length() > 0)
|
||||||
{
|
{
|
||||||
chiaki_base64_decode(account_id.c_str(), account_id.length(),
|
chiaki_base64_decode(account_id.c_str(), account_id.length(),
|
||||||
regist_info.psn_account_id, &(account_id_size));
|
regist_info.psn_account_id, &(account_id_size));
|
||||||
regist_info.psn_online_id = nullptr;
|
regist_info.psn_online_id = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -119,7 +121,7 @@ int Host::Register(std::string pin)
|
||||||
this->regist_info.host = this->host_addr.c_str();
|
this->regist_info.host = this->host_addr.c_str();
|
||||||
this->regist_info.broadcast = false;
|
this->regist_info.broadcast = false;
|
||||||
|
|
||||||
if(this->system_version >= 7000000)
|
if(this->target >= CHIAKI_TARGET_PS4_9)
|
||||||
CHIAKI_LOGI(this->log, "Registering to host `%s` `%s` with PSN AccountID `%s` pin `%s`",
|
CHIAKI_LOGI(this->log, "Registering to host `%s` `%s` with PSN AccountID `%s` pin `%s`",
|
||||||
this->host_name.c_str(), this->host_addr.c_str(), account_id.c_str(), pin.c_str());
|
this->host_name.c_str(), this->host_addr.c_str(), account_id.c_str(), pin.c_str());
|
||||||
else
|
else
|
||||||
|
@ -133,19 +135,16 @@ int Host::Register(std::string pin)
|
||||||
int Host::InitSession(IO * user)
|
int Host::InitSession(IO * user)
|
||||||
{
|
{
|
||||||
chiaki_connect_video_profile_preset(&(this->video_profile),
|
chiaki_connect_video_profile_preset(&(this->video_profile),
|
||||||
this->video_resolution, this->video_fps);
|
this->video_resolution, this->video_fps);
|
||||||
// Build chiaki ps4 stream session
|
// Build chiaki ps4 stream session
|
||||||
chiaki_opus_decoder_init(&(this->opus_decoder), this->log);
|
chiaki_opus_decoder_init(&(this->opus_decoder), this->log);
|
||||||
ChiakiAudioSink audio_sink;
|
ChiakiAudioSink audio_sink;
|
||||||
ChiakiConnectInfo chiaki_connect_info = { 0 };
|
ChiakiConnectInfo chiaki_connect_info = {0};
|
||||||
|
|
||||||
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 = this->IsPS5();
|
||||||
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));
|
||||||
|
@ -208,43 +207,43 @@ void Host::RegistCB(ChiakiRegistEvent * event)
|
||||||
this->registered = false;
|
this->registered = false;
|
||||||
switch(event->type)
|
switch(event->type)
|
||||||
{
|
{
|
||||||
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_CANCELED:
|
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_CANCELED:
|
||||||
CHIAKI_LOGI(this->log, "Register event CHIAKI_REGIST_EVENT_TYPE_FINISHED_CANCELED");
|
CHIAKI_LOGI(this->log, "Register event CHIAKI_REGIST_EVENT_TYPE_FINISHED_CANCELED");
|
||||||
if(this->chiaki_regist_event_type_finished_canceled != nullptr)
|
if(this->chiaki_regist_event_type_finished_canceled != nullptr)
|
||||||
{
|
{
|
||||||
this->chiaki_regist_event_type_finished_canceled();
|
this->chiaki_regist_event_type_finished_canceled();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_FAILED:
|
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_FAILED:
|
||||||
CHIAKI_LOGI(this->log, "Register event CHIAKI_REGIST_EVENT_TYPE_FINISHED_FAILED");
|
CHIAKI_LOGI(this->log, "Register event CHIAKI_REGIST_EVENT_TYPE_FINISHED_FAILED");
|
||||||
if(this->chiaki_regist_event_type_finished_failed != nullptr)
|
if(this->chiaki_regist_event_type_finished_failed != nullptr)
|
||||||
{
|
{
|
||||||
this->chiaki_regist_event_type_finished_failed();
|
this->chiaki_regist_event_type_finished_failed();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_SUCCESS:
|
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_SUCCESS:
|
||||||
{
|
{
|
||||||
ChiakiRegisteredHost *r_host = event->registered_host;
|
ChiakiRegisteredHost * r_host = event->registered_host;
|
||||||
CHIAKI_LOGI(this->log, "Register event CHIAKI_REGIST_EVENT_TYPE_FINISHED_SUCCESS");
|
CHIAKI_LOGI(this->log, "Register event CHIAKI_REGIST_EVENT_TYPE_FINISHED_SUCCESS");
|
||||||
// copy values form ChiakiRegisteredHost object
|
// copy values form ChiakiRegisteredHost object
|
||||||
this->ap_ssid = r_host->ap_ssid;
|
this->ap_ssid = r_host->ap_ssid;
|
||||||
this->ap_key = r_host->ap_key;
|
this->ap_key = r_host->ap_key;
|
||||||
this->ap_name = r_host->ap_name;
|
this->ap_name = r_host->ap_name;
|
||||||
memcpy( &(this->server_mac), &(r_host->server_mac), sizeof(this->server_mac) );
|
memcpy(&(this->server_mac), &(r_host->server_mac), sizeof(this->server_mac));
|
||||||
this->server_nickname = r_host->server_nickname;
|
this->server_nickname = r_host->server_nickname;
|
||||||
memcpy( &(this->rp_regist_key), &(r_host->rp_regist_key), sizeof(this->rp_regist_key) );
|
memcpy(&(this->rp_regist_key), &(r_host->rp_regist_key), sizeof(this->rp_regist_key));
|
||||||
this->rp_key_type = r_host->rp_key_type;
|
this->rp_key_type = r_host->rp_key_type;
|
||||||
memcpy( &(this->rp_key), &(r_host->rp_key), sizeof(this->rp_key) );
|
memcpy(&(this->rp_key), &(r_host->rp_key), sizeof(this->rp_key));
|
||||||
// mark host as registered
|
// mark host as registered
|
||||||
this->registered = true;
|
this->registered = true;
|
||||||
this->rp_key_data = true;
|
this->rp_key_data = true;
|
||||||
CHIAKI_LOGI(this->log, "Register Success %s", this->host_name.c_str());
|
CHIAKI_LOGI(this->log, "Register Success %s", this->host_name.c_str());
|
||||||
|
|
||||||
if(this->chiaki_regist_event_type_finished_success != nullptr)
|
if(this->chiaki_regist_event_type_finished_success != nullptr)
|
||||||
this->chiaki_regist_event_type_finished_success();
|
this->chiaki_regist_event_type_finished_success();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// close registration socket
|
// close registration socket
|
||||||
chiaki_regist_stop(&this->regist);
|
chiaki_regist_stop(&this->regist);
|
||||||
|
@ -255,24 +254,24 @@ bool Host::GetVideoResolution(int * ret_width, int * ret_height)
|
||||||
{
|
{
|
||||||
switch(this->video_resolution)
|
switch(this->video_resolution)
|
||||||
{
|
{
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
||||||
*ret_width = 640;
|
*ret_width = 640;
|
||||||
*ret_height = 360;
|
*ret_height = 360;
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_540p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_540p:
|
||||||
*ret_width = 950;
|
*ret_width = 950;
|
||||||
*ret_height = 540;
|
*ret_height = 540;
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
||||||
*ret_width = 1280;
|
*ret_width = 1280;
|
||||||
*ret_height = 720;
|
*ret_height = 720;
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
||||||
*ret_width = 1920;
|
*ret_width = 1920;
|
||||||
*ret_height = 1080;
|
*ret_height = 1080;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -336,3 +335,11 @@ bool Host::HasRPkey()
|
||||||
{
|
{
|
||||||
return this->rp_key_data;
|
return this->rp_key_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Host::IsPS5()
|
||||||
|
{
|
||||||
|
if(this->target >= CHIAKI_TARGET_PS5_UNKNOWN)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
||||||
|
|
||||||
// chiaki modules
|
// chiaki modules
|
||||||
#include <chiaki/log.h>
|
|
||||||
#include <chiaki/discovery.h>
|
#include <chiaki/discovery.h>
|
||||||
|
#include <chiaki/log.h>
|
||||||
|
|
||||||
// discover and wakeup ps4 host
|
// discover and wakeup ps4 host
|
||||||
// from local network
|
// from local network
|
||||||
#include "discoverymanager.h"
|
#include "discoverymanager.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "io.h"
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
#include "io.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
@ -51,11 +51,11 @@ static int s_nxlinkSock = -1;
|
||||||
static void initNxLink()
|
static void initNxLink()
|
||||||
{
|
{
|
||||||
// use chiaki socket config initialization
|
// use chiaki socket config initialization
|
||||||
if (R_FAILED(socketInitialize(&g_chiakiSocketInitConfig)))
|
if(R_FAILED(socketInitialize(&g_chiakiSocketInitConfig)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_nxlinkSock = nxlinkStdio();
|
s_nxlinkSock = nxlinkStdio();
|
||||||
if (s_nxlinkSock >= 0)
|
if(s_nxlinkSock >= 0)
|
||||||
printf("initNxLink");
|
printf("initNxLink");
|
||||||
else
|
else
|
||||||
socketExit();
|
socketExit();
|
||||||
|
@ -63,7 +63,7 @@ static void initNxLink()
|
||||||
|
|
||||||
static void deinitNxLink()
|
static void deinitNxLink()
|
||||||
{
|
{
|
||||||
if (s_nxlinkSock >= 0)
|
if(s_nxlinkSock >= 0)
|
||||||
{
|
{
|
||||||
close(s_nxlinkSock);
|
close(s_nxlinkSock);
|
||||||
s_nxlinkSock = -1;
|
s_nxlinkSock = -1;
|
||||||
|
@ -105,7 +105,7 @@ extern "C" void userAppExit()
|
||||||
}
|
}
|
||||||
#endif // __SWITCH__
|
#endif // __SWITCH__
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
// load chiaki lib
|
// load chiaki lib
|
||||||
Settings * settings = Settings::GetInstance();
|
Settings * settings = Settings::GetInstance();
|
||||||
|
@ -121,7 +121,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
CHIAKI_LOGI(log, "Loading SDL audio / joystick");
|
CHIAKI_LOGI(log, "Loading SDL audio / joystick");
|
||||||
if(SDL_Init( SDL_INIT_AUDIO | SDL_INIT_JOYSTICK ))
|
if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK))
|
||||||
{
|
{
|
||||||
CHIAKI_LOGE(log, "SDL initialization failed: %s", SDL_GetError());
|
CHIAKI_LOGE(log, "SDL initialization failed: %s", SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -129,13 +129,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// build sdl OpenGl and AV decoders graphical interface
|
// build sdl OpenGl and AV decoders graphical interface
|
||||||
IO io = IO(log); // open Input Output class
|
IO io = IO(log); // open Input Output class
|
||||||
|
DiscoveryManager discoverymanager = DiscoveryManager();
|
||||||
// create host objects form config file
|
|
||||||
CHIAKI_LOGI(log, "Read chiaki settings file");
|
|
||||||
// FIXME use GUI for config
|
|
||||||
Host * host = nullptr;
|
|
||||||
|
|
||||||
DiscoveryManager discoverymanager = DiscoveryManager(settings);
|
|
||||||
MainApplication app = MainApplication(&discoverymanager, &io);
|
MainApplication app = MainApplication(&discoverymanager, &io);
|
||||||
app.Load();
|
app.Load();
|
||||||
|
|
||||||
|
@ -143,4 +137,3 @@ int main(int argc, char* argv[])
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ Settings::Settings()
|
||||||
#else
|
#else
|
||||||
chiaki_log_init(&this->log, CHIAKI_LOG_ALL ^ CHIAKI_LOG_VERBOSE, chiaki_log_cb_print, NULL);
|
chiaki_log_init(&this->log, CHIAKI_LOG_ALL ^ CHIAKI_LOG_VERBOSE, chiaki_log_cb_print, NULL);
|
||||||
#endif
|
#endif
|
||||||
CHIAKI_LOGI(&this->log, "Read chiaki settings file %s", this->filename);
|
|
||||||
this->ParseFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::ConfigurationItem Settings::ParseLine(std::string * line, std::string * value)
|
Settings::ConfigurationItem Settings::ParseLine(std::string * line, std::string * value)
|
||||||
|
@ -43,7 +41,10 @@ Settings * Settings::instance = nullptr;
|
||||||
Settings * Settings::GetInstance()
|
Settings * Settings::GetInstance()
|
||||||
{
|
{
|
||||||
if(instance == nullptr)
|
if(instance == nullptr)
|
||||||
|
{
|
||||||
instance = new Settings;
|
instance = new Settings;
|
||||||
|
instance->ParseFile();
|
||||||
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ Host * Settings::GetOrCreateHost(std::string * host_name)
|
||||||
if(this->hosts.find(*host_name) == hosts.end())
|
if(this->hosts.find(*host_name) == hosts.end())
|
||||||
{
|
{
|
||||||
// create host if udefined
|
// create host if udefined
|
||||||
Host h = Host(&this->log, this, *host_name);
|
Host h = Host(*host_name);
|
||||||
this->hosts.emplace(*host_name, h);
|
this->hosts.emplace(*host_name, h);
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue