mirror of
https://github.com/joel16/SwitchIdent.git
synced 2024-11-23 03:39:40 +00:00
Fix compile errors with new version of libnx
This commit is contained in:
parent
816ef0a32b
commit
fa7f9094bf
@ -41,17 +41,17 @@ char *SwitchIdent_GetDramDesc(void) {
|
||||
return dram_desc[id];
|
||||
}
|
||||
|
||||
char *SwitchIdent_GetFirmwareVersion(Service *srv) {
|
||||
char *SwitchIdent_GetFirmwareVersion(void) {
|
||||
Result ret = 0;
|
||||
SetSysFirmwareVersion ver;
|
||||
|
||||
if (R_FAILED(ret = setsysGetFirmwareVersion(srv, &ver))) {
|
||||
if (R_FAILED(ret = setsysGetFirmwareVersion(&ver))) {
|
||||
printf("setsysGetFirmwareVersion() failed: 0x%x.\n\n", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char buf[9];
|
||||
snprintf(buf, 9, ver.version_long + 28);
|
||||
snprintf(buf, 9, "%u.%u.%u-%u%u", ver.major, ver.minor, ver.micro, ver.revision_major, ver.revision_minor);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define _SWITCHIDENT_KERNEL_H_
|
||||
|
||||
char *SwitchIdent_GetDramDesc(void);
|
||||
char *SwitchIdent_GetFirmwareVersion(Service *srv);
|
||||
char *SwitchIdent_GetFirmwareVersion(void);
|
||||
char *SwitchIdent_GetKernelVersion(void);
|
||||
char *SwitchIdent_GetHardwareType(void);
|
||||
char *SwitchIdent_GetUnit(void);
|
||||
|
@ -40,42 +40,6 @@ static Result psmIsBatteryChargingEnabled(Service *srv, bool *out) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result psmGetBatteryVoltageState(Service *srv, u32 *out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 12;
|
||||
|
||||
Result rc = serviceIpcDispatch(srv);
|
||||
|
||||
if(R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 voltage;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*out = resp->voltage;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result psmGetRawBatteryChargePercentage(Service *srv, u64 *out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
@ -258,7 +222,7 @@ char *SwitchIdent_GetVoltageState(Service *srv) {
|
||||
"Unknown"
|
||||
};
|
||||
|
||||
if (R_SUCCEEDED(ret = psmGetBatteryVoltageState(srv, &out))) {
|
||||
if (R_SUCCEEDED(ret = psmGetBatteryVoltageState(&out))) {
|
||||
if (out < 15)
|
||||
return states[out];
|
||||
}
|
||||
|
@ -1,92 +1,6 @@
|
||||
#include <string.h>
|
||||
#include <switch.h>
|
||||
|
||||
#include "setsys.h"
|
||||
|
||||
static Result GetFirmwareVersion(Service *srv, SetSysFirmwareVersion *ver) {
|
||||
char buffer[0x100];
|
||||
size_t size = sizeof(buffer);
|
||||
memset(buffer, 0, size);
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddRecvStatic(&c, buffer, size, 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 3;
|
||||
|
||||
Result rc = serviceIpcDispatch(srv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
}* resp = r.Raw;
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)){
|
||||
memcpy(ver, &buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result GetFirmwareVersion2(Service *srv, SetSysFirmwareVersion *ver) {
|
||||
char buffer[0x100];
|
||||
size_t size = sizeof(buffer);
|
||||
memset(buffer, 0, size);
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddRecvStatic(&c, buffer, size, 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 4;
|
||||
|
||||
Result rc = serviceIpcDispatch(srv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
}* resp = r.Raw;
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)){
|
||||
memcpy(ver, &buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result setsysGetFirmwareVersion(Service *srv, SetSysFirmwareVersion *ver) {
|
||||
if (kernelAbove200())
|
||||
return GetFirmwareVersion2(srv, ver);
|
||||
return GetFirmwareVersion(srv, ver);
|
||||
}
|
||||
|
||||
Result setcalGetBluetoothBdAddress(Service *srv, char *address) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
@ -1,15 +1,6 @@
|
||||
#ifndef _SWITCHIDENT_SETSYS_H_
|
||||
#define _SWITCHIDENT_SETSYS_H_
|
||||
|
||||
typedef struct {
|
||||
u8 version_raw[8];
|
||||
char platform[32];
|
||||
char hash[64];
|
||||
char version_short[24];
|
||||
char version_long[128];
|
||||
} SetSysFirmwareVersion;
|
||||
|
||||
Result setsysGetFirmwareVersion(Service *srv, SetSysFirmwareVersion *ver);
|
||||
Result setcalGetBluetoothBdAddress(Service *srv, char *address);
|
||||
Result setcalGetWirelessLanMacAddress(Service *srv, char *address);
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "utils.h"
|
||||
#include "wlan.h"
|
||||
|
||||
static Service setsys_service, psm_service, wlaninf_service;
|
||||
static Service psm_service, wlaninf_service;
|
||||
static FsDeviceOperator fsDeviceOperator;
|
||||
|
||||
static void SwitchIdent_InitServices(void) {
|
||||
@ -24,9 +24,6 @@ static void SwitchIdent_InitServices(void) {
|
||||
if (R_FAILED(ret = setsysInitialize()))
|
||||
printf("setsysInitialize() failed: 0x%x.\n\n", ret);
|
||||
|
||||
if (R_FAILED(ret = smGetService(&setsys_service, "set:sys")))
|
||||
printf("setsysInitialize() failed: 0x%x.\n\n", ret);
|
||||
|
||||
if (R_FAILED(ret = splInitialize()))
|
||||
printf("splInitialize() failed: 0x%x.\n\n", ret);
|
||||
|
||||
@ -69,7 +66,6 @@ static void SwitchIdent_TermServices(void) {
|
||||
socketExit();
|
||||
nifmExit();
|
||||
splExit();
|
||||
serviceClose(&setsys_service);
|
||||
setsysExit();
|
||||
setExit();
|
||||
}
|
||||
@ -86,7 +82,7 @@ int main(int argc, char **argv) {
|
||||
/*
|
||||
Kernel/Hardware info:
|
||||
*/
|
||||
printf("\x1b[31;1m*\x1b[0m Firmware version: \x1b[31;1m%s\n", SwitchIdent_GetFirmwareVersion(&setsys_service));
|
||||
printf("\x1b[31;1m*\x1b[0m Firmware version: \x1b[31;1m%s\n", SwitchIdent_GetFirmwareVersion());
|
||||
printf("\x1b[31;1m*\x1b[0m Kernel version: \x1b[31;1m%s\n", SwitchIdent_GetKernelVersion());
|
||||
printf("\x1b[31;1m*\x1b[0m Hardware: \x1b[31;1m%s\x1b[0m (\x1b[31;1m%s\x1b[0m) \x1b[0m\n", SwitchIdent_GetHardwareType(), SwitchIdent_GetUnit());
|
||||
printf("\x1b[31;1m*\x1b[0m Serial number: \x1b[31;1m%s\n", SwitchIdent_GetSerialNumber());
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
static u32 item_height = 0;
|
||||
|
||||
static Service setsys_service, setcal_service, psm_service, wlaninf_service;
|
||||
static Service setcal_service, psm_service, wlaninf_service;
|
||||
static FsDeviceOperator fsDeviceOperator;
|
||||
|
||||
static void Menu_DrawItem(int x, int y, char *item_title, const char *text, ...) {
|
||||
@ -34,7 +34,7 @@ static void Menu_DrawItem(int x, int y, char *item_title, const char *text, ...)
|
||||
}
|
||||
|
||||
static void Menu_Kernel(void) {
|
||||
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 50, "Firmware version:", SwitchIdent_GetFirmwareVersion(&setsys_service));
|
||||
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 50, "Firmware version:", SwitchIdent_GetFirmwareVersion());
|
||||
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 100, "Kernel version:", SwitchIdent_GetKernelVersion());
|
||||
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 150, "Hardware:", SwitchIdent_GetHardwareType());
|
||||
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 200, "Unit:", SwitchIdent_GetUnit());
|
||||
@ -139,9 +139,6 @@ void Menu_Main(void) {
|
||||
int selection = 0;
|
||||
Result ret = 0;
|
||||
|
||||
if (R_FAILED(ret = smGetService(&setsys_service, "set:sys")))
|
||||
printf("setsysInitialize() failed: 0x%x.\n\n", ret);
|
||||
|
||||
if (R_FAILED(ret = smGetService(&setcal_service, "set:cal")))
|
||||
printf("setcalInitialize() failed: 0x%x.\n\n", ret);
|
||||
|
||||
@ -213,5 +210,4 @@ void Menu_Main(void) {
|
||||
serviceClose(&wlaninf_service);
|
||||
serviceClose(&psm_service);
|
||||
serviceClose(&setcal_service);
|
||||
serviceClose(&setsys_service);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user