From 578562356834a0df32ec07ca62f14ecbdba0ce8c Mon Sep 17 00:00:00 2001 From: joel16 Date: Sun, 18 Jun 2023 17:47:44 -0400 Subject: [PATCH] kernel: Get cradle FW version (stubbed for now) --- include/common.hpp | 8 ++++++++ source/kernel.cpp | 11 +++++++++++ source/menus.cpp | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/include/common.hpp b/include/common.hpp index 6ac0ea1..c7b8264 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -29,6 +29,13 @@ typedef struct { u8 device_identifier[0xC]; } HIDFirmwareVersion; +typedef struct { + u32 major; + u32 minor; + u32 micro; + u32 rev; +} DockFirmwareVersion; + namespace SwitchIdent { // Kernel const char *GetDramDesc(void); @@ -39,6 +46,7 @@ namespace SwitchIdent { bool IsSafeMode(void); u64 GetDeviceID(void); SetSysSerialNumber GetSerialNumber(void); + DockFirmwareVersion GetDockFirmware(void); // Misc const char *GetOperationMode(void); diff --git a/source/kernel.cpp b/source/kernel.cpp index cca0aa0..47815b8 100644 --- a/source/kernel.cpp +++ b/source/kernel.cpp @@ -150,4 +150,15 @@ namespace SwitchIdent { return serial; } + + DockFirmwareVersion GetDockFirmware(void) { + Result ret = 0; + DockFirmwareVersion version; + + if (R_FAILED(ret = appletGetCradleFwVersion(&version.major, &version.minor, &version.micro, &version.rev))) { + std::printf("appletGetCradleFwVersion() failed: 0x%x.\n\n", ret); + } + + return version; + } } diff --git a/source/menus.cpp b/source/menus.cpp index 440ed7b..242ca41 100644 --- a/source/menus.cpp +++ b/source/menus.cpp @@ -55,6 +55,7 @@ namespace Menus { void KernelInfo(void) { SetSysFirmwareVersion ver = SwitchIdent::GetFirmwareVersion(); + //DockFirmwareVersion dock_ver = SwitchIdent::GetDockFirmware(); Menus::DrawItemf(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 60, "Firmware version:", "%u.%u.%u-%u%u", ver.major, ver.minor, ver.micro, ver.revision_major, ver.revision_minor); Menus::DrawItem(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 120, "Hardware:", SwitchIdent::GetHardwareType()); @@ -62,6 +63,10 @@ namespace Menus { Menus::DrawItem(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 240, "Serial:", SwitchIdent::GetSerialNumber().number); Menus::DrawItem(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 300, "DRAM ID:", SwitchIdent::GetDramDesc()); Menus::DrawItemf(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 360, "Device ID:", "%llu", SwitchIdent::GetDeviceID()); + + // if (hosversionAtLeast(2, 0, 0) && appletGetOperationMode() == AppletOperationMode_Console) { + // Menus::DrawItemf(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 420, "Dock firmware:", "%d.%d.%d.%d", dock_ver.major, dock_ver.minor, dock_ver.micro, dock_ver.rev); + // } } void SystemInfo(void) {