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