From 741341132928773d6aa9efcd1820b73a9fe86eef Mon Sep 17 00:00:00 2001 From: joel16 Date: Sat, 14 Oct 2023 17:13:17 -0400 Subject: [PATCH] kernel: Display touchscreen firmware version --- include/common.hpp | 3 ++- source/{joycon.cpp => hid.cpp} | 14 ++++++++++++++ source/kernel.cpp | 2 ++ source/main.cpp | 5 +++++ source/menus.cpp | 6 ++++++ 5 files changed, 29 insertions(+), 1 deletion(-) rename source/{joycon.cpp => hid.cpp} (73%) diff --git a/include/common.hpp b/include/common.hpp index 18c9036..7f11489 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -93,9 +93,10 @@ namespace SwitchIdent { s32 GetWlanQuality(s32 dBm); u32 GetWlanRSSI(void); - // Joycon + // HID Result GetJoyconFirmwareVersion(HidDeviceTypeBits deviceType, HIDFirmwareVersion *version); HidPowerInfo GetJoyconPowerInfo(HidNpadIdType id); HidPowerInfo GetJoyconPowerInfoL(HidNpadIdType id); HidPowerInfo GetJoyconPowerInfoR(HidNpadIdType id); + Result GetTouchScreenFirmwareVersion(HIDFirmwareVersion *version); } diff --git a/source/joycon.cpp b/source/hid.cpp similarity index 73% rename from source/joycon.cpp rename to source/hid.cpp index 2804e0e..1e625f5 100644 --- a/source/joycon.cpp +++ b/source/hid.cpp @@ -41,4 +41,18 @@ namespace SwitchIdent { hidGetNpadPowerInfoSplit(id, &info_left, &info_right); return info_right; } + + static Result hidsysGetTouchScreenFirmwareVersion(HIDFirmwareVersion *version) { + return serviceDispatchOut(hidsysGetServiceSession(), 1151, *version); + } + + Result GetTouchScreenFirmwareVersion(HIDFirmwareVersion *version) { + Result ret = 0; + + if (R_FAILED(ret = hidsysGetTouchScreenFirmwareVersion(version))) { + std::printf("hidsysGetTouchScreenFirmwareVersion() failed: 0x%x.\n\n", ret); + } + + return ret; + } } diff --git a/source/kernel.cpp b/source/kernel.cpp index 47815b8..9483903 100644 --- a/source/kernel.cpp +++ b/source/kernel.cpp @@ -161,4 +161,6 @@ namespace SwitchIdent { return version; } + + } diff --git a/source/main.cpp b/source/main.cpp index 90975cb..be9aa90 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -8,6 +8,7 @@ namespace Services { void Exit(void) { gpioPadClose(&hp_inserted); gpioExit(); + hidsysExit(); hiddbgExit(); tsExit(); wlaninfExit(); @@ -106,6 +107,10 @@ namespace Services { std::printf("hiddbgInitialize() failed: 0x%x.\n\n", ret); } + if (R_FAILED(ret = hidsysInitialize())) { + std::printf("hidsysInitialize() failed: 0x%x.\n\n", ret); + } + if (R_FAILED(ret = gpioInitialize())) { std::printf("gpioInitialize() failed: 0x%x.\n\n", ret); } diff --git a/source/menus.cpp b/source/menus.cpp index b9b4591..7770dce 100644 --- a/source/menus.cpp +++ b/source/menus.cpp @@ -40,6 +40,7 @@ namespace Menus { SetSysSerialNumber serial_number; const char *dram_desc; u64 device_id; + HIDFirmwareVersion touchscreen_version; } KernelInfo; typedef struct { @@ -117,6 +118,10 @@ namespace Menus { Menus::DrawItem(5, "DRAM ID:", kernel_info.dram_desc); Menus::DrawItemf(6, "Device ID:", "%llu", kernel_info.device_id); + if (hosversionAtLeast(9, 0, 0)) { + Menus::DrawItemf(7, "Touchscreen firmware:", "%d.%d.%d.%d", kernel_info.touchscreen_version.major, kernel_info.touchscreen_version.minor, kernel_info.touchscreen_version.micro, kernel_info.touchscreen_version.rev); + } + // if (hosversionAtLeast(2, 0, 0) && g_applet_operation_mode == AppletOperationMode_Console) { // Menus::DrawItemf(7, "Dock firmware:", "%d.%d.%d.%d", kernel_info.dock_version.major, kernel_info.dock_version.minor, kernel_info.dock_version.micro, kernel_info.dock_version.rev); // } @@ -269,6 +274,7 @@ namespace Menus { kernel_info.serial_number = SwitchIdent::GetSerialNumber(); kernel_info.dram_desc = SwitchIdent::GetDramDesc(); kernel_info.device_id = SwitchIdent::GetDeviceID(); + SwitchIdent::GetTouchScreenFirmwareVersion(&kernel_info.touchscreen_version); SystemInfo system_info = { 0 }; system_info.region = SwitchIdent::GetRegion();