diff --git a/troposphere/haze/source/ptp_responder.cpp b/troposphere/haze/source/ptp_responder.cpp index 591cdd950..4064242fa 100644 --- a/troposphere/haze/source/ptp_responder.cpp +++ b/troposphere/haze/source/ptp_responder.cpp @@ -37,9 +37,7 @@ namespace haze { constexpr auto MtpVendorExtensionDesc = "microsoft.com: 1.0;"; constexpr u16 MtpFunctionalModeDefault = 0; constexpr auto MtpDeviceManufacturer = "Nintendo"; - constexpr auto MtpDeviceModel = "Switch"; - constexpr auto MtpDeviceVersion = "1.0.0"; - constexpr auto MtpDeviceSerialNumber = "SerialNumber"; + constexpr auto MtpDeviceModel = "Nintendo Switch"; enum StorageId : u32 { StorageId_SdmcFs = 0xffffffffu - 1, @@ -306,6 +304,16 @@ namespace haze { Result PtpResponder::GetDeviceInfo(PtpDataParser &dp) { PtpDataBuilder db(g_bulk_write_buffer, std::addressof(m_usb_server)); + /* Initialize set:sys, ensuring we clean up on exit. */ + R_TRY(setsysInitialize()); + ON_SCOPE_EXIT { setsysExit(); }; + + /* Get the device version and serial number. */ + SetSysFirmwareVersion version; + SetSysSerialNumber serial; + R_TRY(setsysGetFirmwareVersion(std::addressof(version))); + R_TRY(setsysGetSerialNumber(std::addressof(serial))); + /* Write the device info data. */ R_TRY(db.WriteVariableLengthData(m_request_header, [&] () { R_TRY(db.Add(MtpStandardVersion)); @@ -320,8 +328,8 @@ namespace haze { R_TRY(db.AddArray(SupportedPlaybackFormats, util::size(SupportedPlaybackFormats))); R_TRY(db.AddString(MtpDeviceManufacturer)); R_TRY(db.AddString(MtpDeviceModel)); - R_TRY(db.AddString(MtpDeviceVersion)); - R_TRY(db.AddString(MtpDeviceSerialNumber)); + R_TRY(db.AddString(version.display_version)); + R_TRY(db.AddString(serial.number)); R_SUCCEED(); })); diff --git a/troposphere/haze/source/usb_session.cpp b/troposphere/haze/source/usb_session.cpp index e6e98b041..18368ed32 100644 --- a/troposphere/haze/source/usb_session.cpp +++ b/troposphere/haze/source/usb_session.cpp @@ -165,11 +165,13 @@ namespace haze { static const u16 supported_langs[1] = { 0x0409 }; R_TRY(usbDsAddUsbLanguageStringDescriptor(nullptr, supported_langs, util::size(supported_langs))); + /* Initialize set:sys, ensuring we clean up on exit. */ + R_TRY(setsysInitialize()); + ON_SCOPE_EXIT { setsysExit(); }; + /* Get the device serial number. */ SetSysSerialNumber serial; - R_TRY(setsysInitialize()); R_TRY(setsysGetSerialNumber(std::addressof(serial))); - setsysExit(); /* Report strings. */ u8 iManufacturer, iProduct, iSerialNumber;