diff --git a/Makefile b/Makefile index 7c18946..76e3bb7 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ include $(DEVKITPRO)/libnx/switch_rules VERSION_MAJOR := 1 VERSION_MINOR := 1 -VERSION_MICRO := 12 +VERSION_MICRO := 13 APP_TITLE := nxdumptool APP_AUTHOR := DarkMatterCore diff --git a/README.md b/README.md index 6a826c0..29a08e5 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,13 @@ Thanks to Changelog -------------- +**v1.1.13:** + +* Fixed compatibility with latest libnx release. +* Now using the `AtmosphereHasService` SM API extension to check if a service is running. More than a year and a half has passed since this feature was introduced in Atmosphère, and it is now part of both SX OS and ReiNX, so it's a justified change. Fixes issues related to sysmodules and SM port exhaustion. + +This is only a bugfix release. I don't expect to release any new versions until the rewrite is finished - the only exception being fixing some kind of feature-breaking bug. Please understand. + **v1.1.12:** * Fixed RomFS dumping/browsing support for games with base Program NCAs without a RomFS section (e.g. Fortnite, World of Tanks Blitz, etc.). Big thanks to [bigkahuna666](https://github.com/bigkahuna666) for reporting the issue and providing with testing. diff --git a/source/dumper.c b/source/dumper.c index d5bbc68..3c066a3 100644 --- a/source/dumper.c +++ b/source/dumper.c @@ -2795,16 +2795,16 @@ int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg) uiUpdateStatusMsg(); uiRefreshDisplay(); - hidScanInput(); + scanPads(); - keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); - keysHeld = hidKeysAllHeld(CONTROLLER_P1_AUTO); + keysDown = getButtonsDown(); + keysHeld = getButtonsHeld(); - if ((keysDown && !(keysDown & KEY_TOUCH)) || (keysHeld && !(keysHeld & KEY_TOUCH))) break; + if (keysDown || keysHeld) break; } // Exit - if (keysDown & KEY_PLUS) + if (keysDown & HidNpadButton_Plus) { ret = -2; proceed = false; @@ -2812,7 +2812,7 @@ int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg) } // Start batch dump process - if (keysDown & KEY_A) + if (keysDown & HidNpadButton_A) { // Check if we have at least a single enabled entry for(i = 0; i < totalTitleCount; i++) @@ -2830,29 +2830,29 @@ int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg) } // Cancel batch dump process - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { proceed = false; break; } // Toggle selected entry - if (keysDown & KEY_Y) batchEntries[selectedSummaryEntry].enabled ^= 0x01; + if (keysDown & HidNpadButton_Y) batchEntries[selectedSummaryEntry].enabled ^= 0x01; // Disable all entries - if (keysDown & KEY_L) + if (keysDown & HidNpadButton_L) { for(i = 0; i < totalTitleCount; i++) batchEntries[i].enabled = false; } // Enable all entries - if (keysDown & KEY_R) + if (keysDown & HidNpadButton_R) { for(i = 0; i < totalTitleCount; i++) batchEntries[i].enabled = true; } // Change page (left) - if ((keysDown & KEY_ZL) && totalTitleCount > maxSummaryFileCount) + if ((keysDown & HidNpadButton_ZL) && totalTitleCount > maxSummaryFileCount) { if (summaryPage > 0) { @@ -2862,7 +2862,7 @@ int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg) } // Change page (right) - if ((keysDown & KEY_ZR) && totalTitleCount > maxSummaryFileCount) + if ((keysDown & HidNpadButton_ZR) && totalTitleCount > maxSummaryFileCount) { if (((summaryPage + 1) * maxSummaryFileCount) < totalTitleCount) { @@ -2872,13 +2872,13 @@ int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg) } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { if (selectedSummaryEntry > (summaryPage * maxSummaryFileCount)) { selectedSummaryEntry--; } else { - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)) { if (((summaryPage + 1) * maxSummaryFileCount) < totalTitleCount) { @@ -2891,13 +2891,13 @@ int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg) } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { if (((((summaryPage + 1) * maxSummaryFileCount) < totalTitleCount) && selectedSummaryEntry < (((summaryPage + 1) * maxSummaryFileCount) - 1)) || ((((summaryPage + 1) * maxSummaryFileCount) >= totalTitleCount) && selectedSummaryEntry < (totalTitleCount - 1))) { selectedSummaryEntry++; } else { - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)) { selectedSummaryEntry = (summaryPage * maxSummaryFileCount); } diff --git a/source/ui.c b/source/ui.c index 4adb780..0c8817d 100644 --- a/source/ui.c +++ b/source/ui.c @@ -1113,21 +1113,21 @@ UIResult uiProcess() res = resultShowGameCardMenu; - hidScanInput(); - keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); + scanPads(); + keysDown = getButtonsDown(); // Exit - if (keysDown & KEY_PLUS) res = resultExit; + if (keysDown & HidNpadButton_Plus) res = resultExit; // Back - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { res = resultShowMainMenu; menuType = MENUTYPE_MAIN; } // Forced XCI dump - if ((keysDown & KEY_Y) && forcedXciDump) + if ((keysDown & HidNpadButton_Y) && forcedXciDump) { uiPrintHeadline(); @@ -1172,21 +1172,21 @@ UIResult uiProcess() res = resultShowSdCardEmmcMenu; - hidScanInput(); - keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); + scanPads(); + keysDown = getButtonsDown(); // Exit - if (keysDown & KEY_PLUS) res = resultExit; + if (keysDown & HidNpadButton_Plus) res = resultExit; // Back - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { res = resultShowMainMenu; menuType = MENUTYPE_MAIN; } // Dump installed content with missing base application - if ((titlePatchCount || titleAddOnCount) && (keysDown & KEY_Y)) + if ((titlePatchCount || titleAddOnCount) && (keysDown & HidNpadButton_Y)) { res = resultShowSdCardEmmcOrphanPatchAddOnMenu; orphanMode = true; @@ -2615,16 +2615,16 @@ UIResult uiProcess() uiUpdateStatusMsg(); uiRefreshDisplay(); - hidScanInput(); + scanPads(); - keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); - keysHeld = hidKeysAllHeld(CONTROLLER_P1_AUTO); + keysDown = getButtonsDown(); + keysHeld = getButtonsHeld(); - if ((keysDown && !(keysDown & KEY_TOUCH)) || (keysHeld && !(keysHeld & KEY_TOUCH)) || (menuType == MENUTYPE_GAMECARD && gameCardInfo.isInserted != curGcStatus)) break; + if (keysDown || keysHeld || (menuType == MENUTYPE_GAMECARD && gameCardInfo.isInserted != curGcStatus)) break; } // Exit - if (keysDown & KEY_PLUS) res = resultExit; + if (keysDown & HidNpadButton_Plus) res = resultExit; // Process key inputs only if the UI state hasn't been changed if (res == resultNone) @@ -2632,7 +2632,7 @@ UIResult uiProcess() // Process base application info change if (menuType == MENUTYPE_GAMECARD && titleAppCount > 1 && uiState != stateHfs0Browser && uiState != stateExeFsSectionBrowser && uiState != stateRomFsSectionBrowser) { - if ((keysDown & KEY_L) || (keysDown & KEY_ZL)) + if ((keysDown & HidNpadButton_L) || (keysDown & HidNpadButton_ZL)) { if (selectedAppInfoIndex > 0) { @@ -2641,7 +2641,7 @@ UIResult uiProcess() } } - if ((keysDown & KEY_R) || (keysDown & KEY_ZR)) + if ((keysDown & HidNpadButton_R) || (keysDown & HidNpadButton_ZR)) { if ((selectedAppInfoIndex + 1) < titleAppCount) { @@ -2654,13 +2654,13 @@ UIResult uiProcess() if (uiState == stateXciDumpMenu) { // Select - if ((keysDown & KEY_A) && cursor == 0) res = resultDumpXci; + if ((keysDown & HidNpadButton_A) && cursor == 0) res = resultDumpXci; // Back - if (keysDown & KEY_B) res = resultShowGameCardMenu; + if (keysDown & HidNpadButton_B) res = resultShowGameCardMenu; // Change option to false - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -2694,7 +2694,7 @@ UIResult uiProcess() } // Change option to true - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -2728,30 +2728,30 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateNspAppDumpMenu || uiState == stateNspPatchDumpMenu || uiState == stateNspAddOnDumpMenu) { // Select - if ((keysDown & KEY_A) && cursor == 0) + if ((keysDown & HidNpadButton_A) && cursor == 0) { selectedNspDumpType = (uiState == stateNspAppDumpMenu ? DUMP_APP_NSP : (uiState == stateNspPatchDumpMenu ? DUMP_PATCH_NSP : DUMP_ADDON_NSP)); res = resultDumpNsp; } // Back - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { if (menuType == MENUTYPE_GAMECARD) { @@ -2779,7 +2779,7 @@ UIResult uiProcess() } // Change option to false - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -2886,7 +2886,7 @@ UIResult uiProcess() } // Change option to true - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -2991,29 +2991,29 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateSdCardEmmcBatchModeMenu) { // Select - if ((keysDown & KEY_A) && cursor == 0 && (dumpCfg.batchDumpCfg.dumpAppTitles || dumpCfg.batchDumpCfg.dumpPatchTitles || dumpCfg.batchDumpCfg.dumpAddOnTitles)) res = resultSdCardEmmcBatchDump; + if ((keysDown & HidNpadButton_A) && cursor == 0 && (dumpCfg.batchDumpCfg.dumpAppTitles || dumpCfg.batchDumpCfg.dumpPatchTitles || dumpCfg.batchDumpCfg.dumpAddOnTitles)) res = resultSdCardEmmcBatchDump; // Back - if (keysDown & KEY_B) res = resultShowSdCardEmmcMenu; + if (keysDown & HidNpadButton_B) res = resultShowSdCardEmmcMenu; // Change option to false - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -3087,7 +3087,7 @@ UIResult uiProcess() } // Change option to true - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -3161,23 +3161,23 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateExeFsMenu) { // Select - if (keysDown & KEY_A) + if (keysDown & HidNpadButton_A) { // Reset option to its default value selectedAppIndex = (menuType == MENUTYPE_GAMECARD ? 0 : selectedAppInfoIndex); @@ -3196,7 +3196,7 @@ UIResult uiProcess() } // Back - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { if (menuType == MENUTYPE_GAMECARD) { @@ -3208,7 +3208,7 @@ UIResult uiProcess() } // Go left - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -3242,7 +3242,7 @@ UIResult uiProcess() } // Go right - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -3278,29 +3278,29 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateExeFsSectionDataDumpMenu || uiState == stateExeFsSectionBrowserMenu) { // Select - if ((keysDown & KEY_A) && cursor == 0) res = (uiState == stateExeFsSectionDataDumpMenu ? resultDumpExeFsSectionData : resultExeFsSectionBrowserGetList); + if ((keysDown & HidNpadButton_A) && cursor == 0) res = (uiState == stateExeFsSectionDataDumpMenu ? resultDumpExeFsSectionData : resultExeFsSectionBrowserGetList); // Back - if (keysDown & KEY_B) res = resultShowExeFsMenu; + if (keysDown & HidNpadButton_B) res = resultShowExeFsMenu; // Change option to false - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -3337,7 +3337,7 @@ UIResult uiProcess() } // Change option to true - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -3376,23 +3376,23 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateRomFsMenu) { // Select - if (keysDown & KEY_A) + if (keysDown & HidNpadButton_A) { // Reset option to its default value if (!orphanMode) selectedAppIndex = (menuType == MENUTYPE_GAMECARD ? 0 : selectedAppInfoIndex); @@ -3411,7 +3411,7 @@ UIResult uiProcess() } // Back - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { if (menuType == MENUTYPE_GAMECARD) { @@ -3424,7 +3424,7 @@ UIResult uiProcess() } // Go left - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -3477,7 +3477,7 @@ UIResult uiProcess() } // Go right - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -3538,29 +3538,29 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateRomFsSectionDataDumpMenu || uiState == stateRomFsSectionBrowserMenu) { // Select - if ((keysDown & KEY_A) && cursor == 0) res = (uiState == stateRomFsSectionDataDumpMenu ? resultDumpRomFsSectionData : resultRomFsSectionBrowserGetEntries); + if ((keysDown & HidNpadButton_A) && cursor == 0) res = (uiState == stateRomFsSectionDataDumpMenu ? resultDumpRomFsSectionData : resultRomFsSectionBrowserGetEntries); // Back - if (keysDown & KEY_B) res = resultShowRomFsMenu; + if (keysDown & HidNpadButton_B) res = resultShowRomFsMenu; // Change option to false - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -3617,7 +3617,7 @@ UIResult uiProcess() } // Change option to true - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -3681,29 +3681,29 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else if (uiState == stateTicketMenu) { // Select - if ((keysDown & KEY_A) && cursor == 0) res = resultDumpTicket; + if ((keysDown & HidNpadButton_A) && cursor == 0) res = resultDumpTicket; // Back - if (keysDown & KEY_B) res = resultShowSdCardEmmcTitleMenu; + if (keysDown & HidNpadButton_B) res = resultShowSdCardEmmcTitleMenu; // Go left - if (keysDown & KEY_LEFT) + if (keysDown & HidNpadButton_AnyLeft) { switch(cursor) { @@ -3754,7 +3754,7 @@ UIResult uiProcess() } // Go right - if (keysDown & KEY_RIGHT) + if (keysDown & HidNpadButton_AnyRight) { switch(cursor) { @@ -3811,21 +3811,21 @@ UIResult uiProcess() } // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } } else { // Select - if (keysDown & KEY_A) + if (keysDown & HidNpadButton_A) { if (uiState == stateMainMenu) { @@ -4108,7 +4108,7 @@ UIResult uiProcess() } // Back - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { if (uiState == stateGameCardMenu || uiState == stateSdCardEmmcMenu || uiState == stateUpdateMenu) { @@ -4171,7 +4171,7 @@ UIResult uiProcess() } // Special action #1 - if (keysDown & KEY_Y) + if (keysDown & HidNpadButton_Y) { if (uiState == stateSdCardEmmcMenu && (calculateOrphanPatchOrAddOnCount(false) || calculateOrphanPatchOrAddOnCount(true))) { @@ -4187,7 +4187,7 @@ UIResult uiProcess() } // Special action #2 - if (keysDown & KEY_X) + if (keysDown & HidNpadButton_X) { if (uiState == stateSdCardEmmcMenu && (titleAppCount || titlePatchCount || titleAddOnCount)) { @@ -4207,22 +4207,22 @@ UIResult uiProcess() if (menu && menuItemsCount) { // Go up - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { scrollAmount = -1; - scrollWithKeysDown = ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp)); } - if ((keysDown & KEY_DLEFT) || (keysDown & KEY_LSTICK_LEFT) || (keysHeld & KEY_RSTICK_LEFT)) scrollAmount = -5; + if ((keysDown & HidNpadButton_Left) || (keysDown & HidNpadButton_StickLLeft) || (keysHeld & HidNpadButton_StickRLeft)) scrollAmount = -5; // Go down - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { scrollAmount = 1; - scrollWithKeysDown = ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN)); + scrollWithKeysDown = ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown)); } - if ((keysDown & KEY_DRIGHT) || (keysDown & KEY_LSTICK_RIGHT) || (keysHeld & KEY_RSTICK_RIGHT)) scrollAmount = 5; + if ((keysDown & HidNpadButton_Right) || (keysDown & HidNpadButton_StickLRight) || (keysHeld & HidNpadButton_StickRRight)) scrollAmount = 5; } } diff --git a/source/util.c b/source/util.c index c8c12d1..7eb4f3f 100644 --- a/source/util.c +++ b/source/util.c @@ -43,6 +43,8 @@ extern nca_keyset_t nca_keyset; /* Statically allocated variables */ +static PadState g_padState = {0}; + static bool initNcm = false, initNs = false, initCsrng = false, initSpl = false, initPmdmnt = false, initPl = false, initNet = false; static bool openFsDevOp = false, openGcEvtNotifier = false, loadGcKernEvt = false, gcThreadInit = false, homeBtnBlocked = false; @@ -396,20 +398,23 @@ void unmountSysEmmcPartition() } } +static Result smAtmosphereHasService(bool *out, SmServiceName name) +{ + u8 tmp = 0; + Result rc = serviceDispatchInOut(smGetServiceSession(), 65100, name, tmp); + if (R_SUCCEEDED(rc) && out) *out = tmp; + return rc; +} + static bool isServiceRunning(const char *name) { - if (!name || !strlen(name)) return false; + if (!name || !*name) return false; - Handle handle; - SmServiceName serviceName = smEncodeName(name); - Result result = smRegisterService(&handle, serviceName, false, 1); - bool running = R_FAILED(result); + bool out = false; + SmServiceName service_name = smEncodeName(name); - svcCloseHandle(handle); - - if (!running) smUnregisterService(serviceName); - - return running; + Result rc = smAtmosphereHasService(&out, service_name); + return (R_SUCCEEDED(rc) && out); } static void retrieveRunningCfwDir() @@ -809,24 +814,19 @@ static void freeGlobalData() freeFilenameBuffer(); } -u64 hidKeysAllDown() +void scanPads(void) { - u8 controller; - u64 keysDown = 0; - - for(controller = 0; controller < (u8)CONTROLLER_P1_AUTO; controller++) keysDown |= hidKeysDown((HidControllerID)controller); - - return keysDown; + padUpdate(&g_padState); } -u64 hidKeysAllHeld() +u64 getButtonsDown(void) { - u8 controller; - u64 keysHeld = 0; - - for(controller = 0; controller < (u8)CONTROLLER_P1_AUTO; controller++) keysHeld |= hidKeysHeld((HidControllerID)controller); - - return keysHeld; + return padGetButtonsDown(&g_padState); +} + +u64 getButtonsHeld(void) +{ + return padGetButtons(&g_padState); } void consoleErrorScreen(const char *fmt, ...) @@ -839,17 +839,16 @@ void consoleErrorScreen(const char *fmt, ...) va_end(va); printf("\nPress any button to exit.\n"); + consoleUpdate(NULL); + + /* Don't consider stick movement as button inputs. */ + u64 flag = ~(HidNpadButton_StickLLeft | HidNpadButton_StickLRight | HidNpadButton_StickLUp | HidNpadButton_StickLDown | HidNpadButton_StickRLeft | HidNpadButton_StickRRight | \ + HidNpadButton_StickRUp | HidNpadButton_StickRDown); while(appletMainLoop()) { - hidScanInput(); - - u64 keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); - - if (keysDown && !((keysDown & KEY_TOUCH) || (keysDown & KEY_LSTICK_LEFT) || (keysDown & KEY_LSTICK_RIGHT) || (keysDown & KEY_LSTICK_UP) || (keysDown & KEY_LSTICK_DOWN) || \ - (keysDown & KEY_RSTICK_LEFT) || (keysDown & KEY_RSTICK_RIGHT) || (keysDown & KEY_RSTICK_UP) || (keysDown & KEY_RSTICK_DOWN))) break; - - consoleUpdate(NULL); + scanPads(); + if (getButtonsDown() && flag) break; } consoleExit(NULL); @@ -948,6 +947,12 @@ bool initApplicationResources(int argc, char **argv) Result result = 0; bool success = false; + /* Configure input. */ + /* Up to 8 different, full controller inputs. */ + /* Individual Joy-Cons not supported. */ + padConfigureInput(8, HidNpadStyleSet_NpadFullCtrl); + padInitializeWithMask(&g_padState, 0x1000000FFUL); + /* Copy launch path */ if (argc > 0 && argv && !envIsNso()) { @@ -998,7 +1003,7 @@ bool initApplicationResources(int argc, char **argv) appletSetMediaPlaybackState(true); /* Enable CPU boost mode */ - appletSetCpuBoostMode(ApmCpuBoostMode_Type1); + appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad); /* Mount eMMC BIS System partition */ if (!mountSysEmmcPartition()) goto out; @@ -1123,7 +1128,7 @@ void deinitApplicationResources() unmountSysEmmcPartition(); /* Disable CPU boost mode */ - appletSetCpuBoostMode(ApmCpuBoostMode_Disabled); + appletSetCpuBoostMode(ApmCpuBoostMode_Normal); /* Enable screen dimming and auto sleep */ appletSetMediaPlaybackState(false); @@ -2523,31 +2528,31 @@ bool listDesiredNcaType(NcmContentInfo *titleContentInfos, u32 titleContentInfoC uiUpdateStatusMsg(); uiRefreshDisplay(); - hidScanInput(); + scanPads(); - keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); - keysHeld = hidKeysAllHeld(CONTROLLER_P1_AUTO); + keysDown = getButtonsDown(); + keysHeld = getButtonsHeld(); - if ((keysDown && !(keysDown & KEY_TOUCH)) || (keysHeld && !(keysHeld & KEY_TOUCH))) break; + if (keysDown || keysHeld) break; } - if (keysDown & KEY_A) + if (keysDown & HidNpadButton_A) { idx = (int)indexes[selectedContent]; break; } - if ((keysDown & KEY_DUP) || (keysDown & KEY_LSTICK_UP) || (keysHeld & KEY_RSTICK_UP)) + if ((keysDown & HidNpadButton_Up) || (keysDown & HidNpadButton_StickLUp) || (keysHeld & HidNpadButton_StickRUp)) { if (selectedContent > 0) selectedContent--; } - if ((keysDown & KEY_DDOWN) || (keysDown & KEY_LSTICK_DOWN) || (keysHeld & KEY_RSTICK_DOWN)) + if ((keysDown & HidNpadButton_Down) || (keysDown & HidNpadButton_StickLDown) || (keysHeld & HidNpadButton_StickRDown)) { if (selectedContent < (cnt - 1)) selectedContent++; } - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { breaks = initial_breaks; uiFill(0, 8 + (breaks * LINE_HEIGHT), FB_WIDTH, FB_HEIGHT - (8 + (breaks * LINE_HEIGHT)), BG_COLOR_RGB); @@ -3672,17 +3677,17 @@ void waitForButtonPress() { uiDrawString(STRING_X_POS, STRING_Y_POS(breaks), FONT_COLOR_RGB, "Press any button to continue"); + /* Don't consider stick movement as button inputs. */ + u64 flag = ~(HidNpadButton_StickLLeft | HidNpadButton_StickLRight | HidNpadButton_StickLUp | HidNpadButton_StickLDown | HidNpadButton_StickRLeft | HidNpadButton_StickRRight | \ + HidNpadButton_StickRUp | HidNpadButton_StickRDown); + while(true) { uiUpdateStatusMsg(); uiRefreshDisplay(); - hidScanInput(); - - u64 keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); - - if (keysDown && !((keysDown & KEY_TOUCH) || (keysDown & KEY_LSTICK_LEFT) || (keysDown & KEY_LSTICK_RIGHT) || (keysDown & KEY_LSTICK_UP) || (keysDown & KEY_LSTICK_DOWN) || \ - (keysDown & KEY_RSTICK_LEFT) || (keysDown & KEY_RSTICK_RIGHT) || (keysDown & KEY_RSTICK_UP) || (keysDown & KEY_RSTICK_DOWN))) break; + scanPads(); + if (getButtonsDown() & flag) break; } } @@ -3745,9 +3750,9 @@ bool cancelProcessCheck(progress_ctx_t *progressCtx) { if (!progressCtx) return false; - hidScanInput(); + scanPads(); - progressCtx->cancelBtnState = (hidKeysAllHeld(CONTROLLER_P1_AUTO) & KEY_B); + progressCtx->cancelBtnState = (getButtonsHeld() & HidNpadButton_B); if (progressCtx->cancelBtnState && progressCtx->cancelBtnState != progressCtx->cancelBtnStatePrev) { @@ -3818,16 +3823,16 @@ bool yesNoPrompt(const char *message) uiUpdateStatusMsg(); uiRefreshDisplay(); - hidScanInput(); + scanPads(); - u64 keysDown = hidKeysAllDown(CONTROLLER_P1_AUTO); + u64 keysDown = getButtonsDown(); - if (keysDown & KEY_A) + if (keysDown & HidNpadButton_A) { ret = true; break; } else - if (keysDown & KEY_B) + if (keysDown & HidNpadButton_B) { ret = false; break; diff --git a/source/util.h b/source/util.h index b869c2e..c26e39b 100644 --- a/source/util.h +++ b/source/util.h @@ -346,8 +346,9 @@ void freeBktrContext(); void freeRomFsBrowserEntries(); void freeHfs0ExeFsEntriesSizes(); -u64 hidKeysAllDown(); -u64 hidKeysAllHeld(); +void scanPads(void); +u64 getButtonsDown(void); +u64 getButtonsHeld(void); void consoleErrorScreen(const char *fmt, ...); bool initApplicationResources(int argc, char **argv);