| 1465 | } |
| 1466 | |
| 1467 | void Initialize() { |
| 1468 | UL_RC_ASSERT(appletLoadAndApplyIdlePolicySettings()); |
| 1469 | UpdateOperationMode(); |
| 1470 | |
| 1471 | g_AmsIsEmuMMC = ul::os::IsEmuMMC(); |
| 1472 | |
| 1473 | // Clean old cache |
| 1474 | ul::fs::DeleteDirectory(ul::PreV100ApplicationCachePath); |
| 1475 | ul::fs::DeleteDirectory(ul::PreV100HomebrewCachePath); |
| 1476 | ul::fs::DeleteDirectory(ul::PreV100AccountCachePath); |
| 1477 | |
| 1478 | // Ensure root cache directory exists |
| 1479 | ul::fs::CreateDirectory(ul::RootCachePath); |
| 1480 | |
| 1481 | // Clean cache, everything except for theme cache |
| 1482 | ul::fs::CleanDirectory(ul::HomebrewCachePath); |
| 1483 | ul::fs::CleanDirectory(ul::ThemePreviewCachePath); |
| 1484 | |
| 1485 | g_CurrentRecords = ul::os::ListApplicationRecords(); |
| 1486 | ul::system::app::InitializeControlCache(g_CurrentRecords); |
| 1487 | ul::menu::CacheHomebrew(); |
| 1488 | CheckHomebrewTakeoverApplicationId(); |
| 1489 | |
| 1490 | // Test, until we figure out how to check if apps need updates |
| 1491 | DebugLogApplicationParameters(); |
| 1492 | |
| 1493 | LoadConfig(); |
| 1494 | |
| 1495 | UL_RC_ASSERT(sf::Initialize()); |
| 1496 | |
| 1497 | UL_RC_ASSERT(threadCreate(&g_EventManagerThread, EventManagerMain, nullptr, nullptr, EventManagerThreadStackSize, 34, -2)); |
| 1498 | UL_RC_ASSERT(threadStart(&g_EventManagerThread)); |
| 1499 | |
| 1500 | bool viewer_usb_enabled; |
| 1501 | { |
| 1502 | ul::ScopedLock lk(g_ConfigLock); |
| 1503 | UL_ASSERT_TRUE(g_Config.GetEntry(ul::cfg::ConfigEntryId::UsbScreenCaptureEnabled, viewer_usb_enabled)); |
| 1504 | } |
| 1505 | if(viewer_usb_enabled) { |
| 1506 | UL_RC_ASSERT(usbCommsInitialize()); |
| 1507 | UL_RC_ASSERT(capsscInitialize()); |
| 1508 | |
| 1509 | g_UsbViewerBuffer = reinterpret_cast<UsbPacketHeader*>(__libnx_aligned_alloc(ams::os::MemoryPageSize, UsbPacketSize)); |
| 1510 | memset(g_UsbViewerBuffer, 0, UsbPacketSize); |
| 1511 | |
| 1512 | void(*thread_read_fn)(void*) = nullptr; |
| 1513 | g_UsbViewerBufferDataOffset = reinterpret_cast<u8*>(g_UsbViewerBuffer) + sizeof(UsbMode) + sizeof(UsbPacketHeader::jpeg); |
| 1514 | if(hosversionAtLeast(9,0,0) && (CaptureJpegScreenshot() > 0)) { |
| 1515 | g_UsbViewerBuffer->mode = UsbMode::Jpeg; |
| 1516 | thread_read_fn = &UsbViewerJpegThread; |
| 1517 | } |
| 1518 | else { |
| 1519 | g_UsbViewerBuffer->mode = UsbMode::Rgba; |
| 1520 | g_UsbViewerBufferDataOffset = reinterpret_cast<u8*>(g_UsbViewerBuffer) + sizeof(UsbMode); |
| 1521 | thread_read_fn = &UsbViewerRgbaThread; |
| 1522 | capsscExit(); |
| 1523 | } |
| 1524 |
no test coverage detected