(LIBNX) Try to fix libnx

This commit is contained in:
twinaphex 2019-05-28 16:10:22 +02:00
parent 876e1a43aa
commit 8850f0735c

View File

@ -300,14 +300,12 @@ static void frontend_switch_exec(const char *path, bool should_load_game)
{
char game_path[PATH_MAX-4];
const char *arg_data[3];
char error_string[200 + PATH_MAX];
int args = 0;
int error = 0;
int args = 0;
game_path[0] = NULL;
arg_data[0] = NULL;
game_path[0] = NULL;
arg_data[0] = NULL;
arg_data[args] = elf_path_cst;
arg_data[args] = elf_path_cst;
arg_data[args + 1] = NULL;
args++;
@ -327,9 +325,8 @@ static void frontend_switch_exec(const char *path, bool should_load_game)
{
#ifdef IS_SALAMANDER
struct stat sbuff;
bool file_exists;
bool file_exists = stat(path, &sbuff) == 0;
file_exists = stat(path, &sbuff) == 0;
if (!file_exists)
{
char core_path[PATH_MAX];
@ -338,23 +335,14 @@ static void frontend_switch_exec(const char *path, bool should_load_game)
get_first_valid_core(&core_path[0]);
if (core_path[0] == '\0')
{
/*errorInit(&error_dialog, ERROR_TEXT, CFG_LANGUAGE_EN);
errorText(&error_dialog, "There are no cores installed, install a core to continue.");
errorDisp(&error_dialog);*/
svcExitProcess();
}
}
#endif
char *argBuffer = (char *)malloc(PATH_MAX);
if (should_load_game)
{
snprintf(argBuffer, PATH_MAX, "%s \"%s\"", path, game_path);
}
else
{
snprintf(argBuffer, PATH_MAX, "%s", path);
}
envSetNextLoad(path, argBuffer);
}
@ -487,7 +475,7 @@ bool rpng_load_image_argb(const char *path,
goto end;
}
if (!rpng_set_buf_ptr(rpng, (uint8_t *)ptr))
if (!rpng_set_buf_ptr(rpng, (uint8_t *)ptr, file_len))
{
ret = false;
goto end;
@ -694,23 +682,24 @@ extern void retro_get_system_info(struct retro_system_info *info);
static void frontend_switch_init(void *data)
{
(void)data;
#ifdef HAVE_LIBNX
bool recording_supported = false;
rarch_system_info_t *sys_info = NULL;
const char *core_name = NULL;
uint32_t width = 0;
uint32_t height = 0;
nifmInitialize();
if(hosversionBefore(8, 0, 0)) {
if(hosversionBefore(8, 0, 0))
pcvInitialize();
} else {
else
clkrstInitialize();
}
appletLockExit();
appletHook(&applet_hook_cookie, on_applet_hook, NULL);
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
bool recording_supported = false;
appletIsGamePlayRecordingSupported(&recording_supported);
if(recording_supported)
appletInitializeGamePlayRecording();
@ -726,20 +715,15 @@ static void frontend_switch_init(void *data)
Result rc;
rc = psmInitialize();
if (R_SUCCEEDED(rc))
{
psmInitialized = true;
}
else
{
RARCH_WARN("Error initializing psm\n");
}
rarch_system_info_t *sys_info = runloop_get_system_info();
sys_info = runloop_get_system_info();
retro_get_system_info(sys_info);
const char *core_name = NULL;
uint32_t width, height;
width = height = 0;
#ifndef HAVE_OPENGL
/* Load splash */
@ -747,11 +731,16 @@ static void frontend_switch_init(void *data)
{
if (sys_info)
{
core_name = sys_info->info.library_name;
char *full_core_splash_path = (char *)malloc(PATH_MAX);
snprintf(full_core_splash_path, PATH_MAX, "/retroarch/rgui/splash/%s.png", core_name);
char *full_core_splash_path;
core_name = sys_info->info.library_name;
full_core_splash_path = (char*)malloc(PATH_MAX);
snprintf(full_core_splash_path,
PATH_MAX, "/retroarch/rgui/splash/%s.png", core_name);
rpng_load_image_argb((const char *)
full_core_splash_path, &splashData, &width, &height);
rpng_load_image_argb((const char *)full_core_splash_path, &splashData, &width, &height);
if (splashData)
{
argb_to_rgba8(splashData, height, width);
@ -759,7 +748,10 @@ static void frontend_switch_init(void *data)
}
else
{
rpng_load_image_argb("/retroarch/rgui/splash/RetroArch.png", &splashData, &width, &height);
rpng_load_image_argb(
"/retroarch/rgui/splash/RetroArch.png",
&splashData, &width, &height);
if (splashData)
{
argb_to_rgba8(splashData, height, width);
@ -771,7 +763,10 @@ static void frontend_switch_init(void *data)
}
else
{
rpng_load_image_argb("/retroarch/rgui/splash/RetroArch.png", &splashData, &width, &height);
rpng_load_image_argb(
"/retroarch/rgui/splash/RetroArch.png",
&splashData, &width, &height);
if (splashData)
{
argb_to_rgba8(splashData, height, width);
@ -801,14 +796,17 @@ static int frontend_switch_parse_drive_list(void *data, bool load_content)
{
#ifndef IS_SALAMANDER
file_list_t *list = (file_list_t *)data;
enum msg_hash_enums enum_idx = load_content ? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR : MSG_UNKNOWN;
enum msg_hash_enums enum_idx = load_content
? MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR
: MSG_UNKNOWN;
if (!list)
return -1;
menu_entries_append_enum(list, "/", msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
enum_idx,
FILE_TYPE_DIRECTORY, 0, 0);
menu_entries_append_enum(list,
"/", msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
enum_idx,
FILE_TYPE_DIRECTORY, 0, 0);
#endif
return 0;
@ -831,14 +829,14 @@ static uint64_t frontend_switch_get_mem_used(void)
return memoryUsed;
}
static enum frontend_powerstate frontend_switch_get_powerstate(int *seconds, int *percent)
static enum frontend_powerstate
frontend_switch_get_powerstate(int *seconds, int *percent)
{
if (!psmInitialized)
return FRONTEND_POWERSTATE_NONE;
uint32_t pct;
ChargerType ct;
Result rc;
if (!psmInitialized)
return FRONTEND_POWERSTATE_NONE;
rc = psmGetBatteryChargePercentage(&pct);
if (!R_SUCCEEDED(rc))
@ -855,41 +853,47 @@ static enum frontend_powerstate frontend_switch_get_powerstate(int *seconds, int
switch (ct)
{
case ChargerType_Charger:
case ChargerType_Usb:
return FRONTEND_POWERSTATE_CHARGING;
default:
break;
case ChargerType_Charger:
case ChargerType_Usb:
return FRONTEND_POWERSTATE_CHARGING;
default:
break;
}
return FRONTEND_POWERSTATE_NO_SOURCE;
}
static void frontend_switch_get_os(char *s, size_t len, int *major, int *minor)
static void frontend_switch_get_os(
char *s, size_t len, int *major, int *minor)
{
#ifdef HAVE_LIBNX
u32 hosVersion;
#else
int patch;
char firmware_version[0x100];
result_t r; /* used by LIB_ASSERT_OK macros */
ipc_object_t set_sys;
ipc_request_t rq;
#endif
strlcpy(s, "Horizon OS", len);
#ifdef HAVE_LIBNX
*major = 0;
*minor = 0;
u32 hosVersion = hosversionGet();
*major = HOSVER_MAJOR(hosVersion);
*minor = HOSVER_MINOR(hosVersion);
hosVersion = hosversionGet();
*major = HOSVER_MAJOR(hosVersion);
*minor = HOSVER_MINOR(hosVersion);
#else
/* defaults in case we error out */
*major = 0;
*minor = 0;
*major = 0;
*minor = 0;
char firmware_version[0x100];
result_t r; /* used by LIB_ASSERT_OK macros */
LIB_ASSERT_OK(fail, sm_init());
ipc_object_t set_sys;
LIB_ASSERT_OK(fail_sm, sm_get_service(&set_sys, "set:sys"));
ipc_request_t rq = ipc_make_request(3);
rq = ipc_make_request(3);
ipc_buffer_t buffers[] = {
ipc_make_buffer(firmware_version, 0x100, 0x1a),
};
@ -897,7 +901,6 @@ static void frontend_switch_get_os(char *s, size_t len, int *major, int *minor)
LIB_ASSERT_OK(fail_object, ipc_send(set_sys, &rq, &ipc_default_response_fmt));
int patch;
sscanf(firmware_version + 0x68, "%d.%d.%d", major, minor, &patch);
fail_object: