mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-26 04:02:11 +00:00
Support for HOS 11.0.0.
* Updated hardcoded system title list to match HOS 11.0.0. * Updated NcaKeyGeneration_Current. * Updated button input handling to match the new pad API from libnx.
This commit is contained in:
parent
9732bf9adf
commit
c29f994b35
13 changed files with 153 additions and 144 deletions
2
Makefile
2
Makefile
|
@ -170,7 +170,7 @@ $(BUILD): usbhsfs
|
|||
clean:
|
||||
@echo clean ...
|
||||
@$(MAKE) --no-print-directory -C libusbhsfs clean
|
||||
@rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
||||
@rm -fr $(BUILD) *.pfs0 *.nso *.nro *.nacp *.elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
3
build.sh
3
build.sh
|
@ -24,13 +24,12 @@ for f in ./code_templates/*.c; do
|
|||
cp $f ./source/main.c
|
||||
|
||||
make BUILD_TYPE="$filename" -j12
|
||||
rm -f ./build/main.o ./build/main.d
|
||||
|
||||
mkdir ./code_templates/tmp/$filename
|
||||
cp ./$filename.nro ./code_templates/tmp/$filename/nxdumptool-rewrite.nro
|
||||
#cp ./$filename.elf ./code_templates/tmp/$filename/nxdumptool-rewrite.elf
|
||||
|
||||
rm -f ./$filename.*
|
||||
rm -f ./build/main.o ./build/main.d ./build/utils.o ./build/utils.d ./build/usb.o ./build/usb.d ./$filename.*
|
||||
done
|
||||
|
||||
make clean
|
||||
|
|
|
@ -832,9 +832,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
|
||||
if (titleIsGameCardInfoUpdated())
|
||||
|
@ -862,7 +862,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (gc_update) continue;
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
|
@ -916,19 +916,19 @@ int main(int argc, char *argv[])
|
|||
if (error || menu >= 3)
|
||||
{
|
||||
consolePrint("press any button to continue\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
menu--;
|
||||
} else {
|
||||
selected_idx = scroll = 0;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= max_val)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -940,13 +940,13 @@ int main(int argc, char *argv[])
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (max_val - 1);
|
||||
scroll = (max_val >= page_size ? (max_val - page_size) : 0);
|
||||
|
@ -959,7 +959,7 @@ int main(int argc, char *argv[])
|
|||
scroll--;
|
||||
}
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
menu--;
|
||||
|
||||
|
@ -971,29 +971,29 @@ int main(int argc, char *argv[])
|
|||
scroll = (menu == 0 ? title_scroll : type_scroll);
|
||||
}
|
||||
} else
|
||||
if (((btn_down & KEY_DLEFT) || (btn_down & KEY_DRIGHT)) && menu == 2 && selected_idx != 0)
|
||||
if ((btn_down & (HidNpadButton_Left | HidNpadButton_Right)) && menu == 2 && selected_idx != 0)
|
||||
{
|
||||
options[selected_idx - 1].val ^= 1;
|
||||
} else
|
||||
if (((btn_down & KEY_L) || (btn_down & KEY_ZL)) && menu == 2 && title_info->previous)
|
||||
if ((btn_down & (HidNpadButton_L | HidNpadButton_ZL)) && menu == 2 && title_info->previous)
|
||||
{
|
||||
title_info = title_info->previous;
|
||||
list_idx--;
|
||||
} else
|
||||
if (((btn_down & KEY_R) || (btn_down & KEY_ZR)) && menu == 2 && title_info->next)
|
||||
if ((btn_down & (HidNpadButton_R | HidNpadButton_ZR)) && menu == 2 && title_info->next)
|
||||
{
|
||||
title_info = title_info->next;
|
||||
list_idx++;
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
out2:
|
||||
if (menu != UINT32_MAX)
|
||||
{
|
||||
consolePrint("press any button to exit\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
}
|
||||
|
||||
if (app_metadata) free(app_metadata);
|
||||
|
|
|
@ -880,9 +880,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
|
||||
if (titleIsGameCardInfoUpdated())
|
||||
|
@ -910,7 +910,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (gc_update) continue;
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
|
@ -964,19 +964,19 @@ int main(int argc, char *argv[])
|
|||
if (error || menu >= 3)
|
||||
{
|
||||
consolePrint("press any button to continue\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
menu--;
|
||||
} else {
|
||||
selected_idx = scroll = 0;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= max_val)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -988,13 +988,13 @@ int main(int argc, char *argv[])
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (max_val - 1);
|
||||
scroll = (max_val >= page_size ? (max_val - page_size) : 0);
|
||||
|
@ -1007,7 +1007,7 @@ int main(int argc, char *argv[])
|
|||
scroll--;
|
||||
}
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
menu--;
|
||||
|
||||
|
@ -1019,29 +1019,29 @@ int main(int argc, char *argv[])
|
|||
scroll = (menu == 0 ? title_scroll : type_scroll);
|
||||
}
|
||||
} else
|
||||
if (((btn_down & KEY_DLEFT) || (btn_down & KEY_DRIGHT)) && menu == 2 && selected_idx != 0)
|
||||
if ((btn_down & (HidNpadButton_Left | HidNpadButton_Right)) && menu == 2 && selected_idx != 0)
|
||||
{
|
||||
options[selected_idx - 1].val ^= 1;
|
||||
} else
|
||||
if (((btn_down & KEY_L) || (btn_down & KEY_ZL)) && menu == 2 && title_info->previous)
|
||||
if ((btn_down & (HidNpadButton_L | HidNpadButton_ZL)) && menu == 2 && title_info->previous)
|
||||
{
|
||||
title_info = title_info->previous;
|
||||
list_idx--;
|
||||
} else
|
||||
if (((btn_down & KEY_R) || (btn_down & KEY_ZR)) && menu == 2 && title_info->next)
|
||||
if ((btn_down & (HidNpadButton_R | HidNpadButton_ZR)) && menu == 2 && title_info->next)
|
||||
{
|
||||
title_info = title_info->next;
|
||||
list_idx++;
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
out2:
|
||||
if (menu != UINT32_MAX)
|
||||
{
|
||||
consolePrint("press any button to exit\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
}
|
||||
|
||||
if (app_metadata) free(app_metadata);
|
||||
|
|
|
@ -264,24 +264,24 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
id_offset = content_infos[selected_idx]->id_offset;
|
||||
break;
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= program_count)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -293,13 +293,13 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (program_count - 1);
|
||||
scroll = (program_count >= page_size ? (program_count - page_size) : 0);
|
||||
|
@ -313,7 +313,7 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
|
|||
}
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
free(content_infos);
|
||||
|
@ -413,9 +413,9 @@ int main(int argc, char *argv[])
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
|
||||
if (titleIsGameCardInfoUpdated())
|
||||
|
@ -434,7 +434,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
if (!titleGetUserApplicationData(app_metadata[selected_idx]->title_id, &user_app_data) || !user_app_data.app_info)
|
||||
{
|
||||
|
@ -445,13 +445,13 @@ int main(int argc, char *argv[])
|
|||
|
||||
break;
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= app_count)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -463,13 +463,13 @@ int main(int argc, char *argv[])
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (app_count - 1);
|
||||
scroll = (app_count >= page_size ? (app_count - page_size) : 0);
|
||||
|
@ -482,13 +482,13 @@ int main(int argc, char *argv[])
|
|||
scroll--;
|
||||
}
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
exit_prompt = false;
|
||||
goto out2;
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
u32 program_count = titleGetContentCountByType(user_app_data.app_info, NcmContentType_Program);
|
||||
|
@ -572,8 +572,8 @@ int main(int argc, char *argv[])
|
|||
struct tm *ts = localtime(&now);
|
||||
size_t size = shared_data.data_written;
|
||||
|
||||
hidScanInput();
|
||||
btn_cancel_cur_state = (utilsHidKeysAllHeld() & KEY_B);
|
||||
utilsScanPads();
|
||||
btn_cancel_cur_state = (utilsGetButtonsHeld() & HidNpadButton_B);
|
||||
|
||||
if (btn_cancel_cur_state && btn_cancel_cur_state != btn_cancel_prev_state)
|
||||
{
|
||||
|
@ -634,7 +634,7 @@ out2:
|
|||
if (exit_prompt)
|
||||
{
|
||||
consolePrint("press any button to exit\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
}
|
||||
|
||||
romfsFreeContext(&romfs_ctx);
|
||||
|
|
|
@ -320,12 +320,12 @@ int main(int argc, char *argv[])
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(!btn_down && !btn_held)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
|
@ -370,19 +370,19 @@ int main(int argc, char *argv[])
|
|||
if (error || menu >= 3)
|
||||
{
|
||||
consolePrint("press any button to continue\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
menu--;
|
||||
} else {
|
||||
selected_idx = scroll = 0;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= max_val)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -394,13 +394,13 @@ int main(int argc, char *argv[])
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (max_val - 1);
|
||||
scroll = (max_val >= page_size ? (max_val - page_size) : 0);
|
||||
|
@ -413,7 +413,7 @@ int main(int argc, char *argv[])
|
|||
scroll--;
|
||||
}
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
menu--;
|
||||
|
||||
|
@ -426,14 +426,14 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
out2:
|
||||
if (menu != UINT32_MAX)
|
||||
{
|
||||
consolePrint("press any button to exit\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
}
|
||||
|
||||
if (nca_ctx) free(nca_ctx);
|
||||
|
|
|
@ -233,12 +233,12 @@ int main(int argc, char *argv[])
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(!btn_down && !btn_held)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
Menu *child_menu = (Menu*)selected_element->child_menu;
|
||||
|
||||
|
@ -253,13 +253,13 @@ int main(int argc, char *argv[])
|
|||
selected_element->task_func();
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
cur_menu->selected++;
|
||||
|
||||
if (!cur_menu->elements[cur_menu->selected])
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
cur_menu->selected = 0;
|
||||
cur_menu->scroll = 0;
|
||||
|
@ -272,13 +272,13 @@ int main(int argc, char *argv[])
|
|||
cur_menu->scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
cur_menu->selected--;
|
||||
|
||||
if (cur_menu->selected == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
cur_menu->selected = (element_count - 1);
|
||||
cur_menu->scroll = (element_count > page_size ? (element_count - page_size) : 0);
|
||||
|
@ -291,19 +291,19 @@ int main(int argc, char *argv[])
|
|||
cur_menu->scroll--;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & (KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT)) && selected_element_options)
|
||||
if ((btn_down & (HidNpadButton_Right | HidNpadButton_StickLRight | HidNpadButton_StickRRight)) && selected_element_options)
|
||||
{
|
||||
selected_element_options->selected++;
|
||||
if (!selected_element_options->options[selected_element_options->selected]) selected_element_options->selected--;
|
||||
if (selected_element_options->options_func) selected_element_options->options_func(selected_element_options->selected);
|
||||
} else
|
||||
if ((btn_down & (KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT)) && selected_element_options)
|
||||
if ((btn_down & (HidNpadButton_Left | HidNpadButton_StickLLeft | HidNpadButton_StickRLeft)) && selected_element_options)
|
||||
{
|
||||
selected_element_options->selected--;
|
||||
if (selected_element_options->selected == UINT32_MAX) selected_element_options->selected = 0;
|
||||
if (selected_element_options->options_func) selected_element_options->options_func(selected_element_options->selected);
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
if (!cur_menu->parent) break;
|
||||
|
||||
|
@ -311,7 +311,7 @@ int main(int argc, char *argv[])
|
|||
element_count = menuGetElementCount(cur_menu);
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -419,7 +419,7 @@ end:
|
|||
utilsChangeHomeButtonBlockStatus(false);
|
||||
|
||||
consolePrint("press any button to continue");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ end:
|
|||
utilsChangeHomeButtonBlockStatus(false);
|
||||
|
||||
consolePrint("press any button to continue");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -550,8 +550,8 @@ static bool sendGameCardImageViaUsb(void)
|
|||
struct tm *ts = localtime(&now);
|
||||
size_t size = shared_data.data_written;
|
||||
|
||||
hidScanInput();
|
||||
btn_cancel_cur_state = (utilsHidKeysAllHeld() & KEY_B);
|
||||
utilsScanPads();
|
||||
btn_cancel_cur_state = (utilsGetButtonsHeld() & HidNpadButton_B);
|
||||
|
||||
if (btn_cancel_cur_state && btn_cancel_cur_state != btn_cancel_prev_state)
|
||||
{
|
||||
|
@ -624,7 +624,7 @@ end:
|
|||
utilsChangeHomeButtonBlockStatus(false);
|
||||
|
||||
consolePrint("press any button to continue");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -242,24 +242,24 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
id_offset = content_infos[selected_idx]->id_offset;
|
||||
break;
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= program_count)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -271,13 +271,13 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (program_count - 1);
|
||||
scroll = (program_count >= page_size ? (program_count - page_size) : 0);
|
||||
|
@ -291,7 +291,7 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
|
|||
}
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
free(content_infos);
|
||||
|
@ -391,9 +391,9 @@ int main(int argc, char *argv[])
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
|
||||
if (titleIsGameCardInfoUpdated())
|
||||
|
@ -412,7 +412,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
if (!titleGetUserApplicationData(app_metadata[selected_idx]->title_id, &user_app_data) || !user_app_data.app_info)
|
||||
{
|
||||
|
@ -423,13 +423,13 @@ int main(int argc, char *argv[])
|
|||
|
||||
break;
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= app_count)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -441,13 +441,13 @@ int main(int argc, char *argv[])
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (app_count - 1);
|
||||
scroll = (app_count >= page_size ? (app_count - page_size) : 0);
|
||||
|
@ -460,13 +460,13 @@ int main(int argc, char *argv[])
|
|||
scroll--;
|
||||
}
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
exit_prompt = false;
|
||||
goto out2;
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
u32 program_count = titleGetContentCountByType(user_app_data.app_info, NcmContentType_Program);
|
||||
|
@ -572,8 +572,8 @@ int main(int argc, char *argv[])
|
|||
struct tm *ts = localtime(&now);
|
||||
size_t size = shared_data.data_written;
|
||||
|
||||
hidScanInput();
|
||||
btn_cancel_cur_state = (utilsHidKeysAllHeld() & KEY_B);
|
||||
utilsScanPads();
|
||||
btn_cancel_cur_state = (utilsGetButtonsHeld() & HidNpadButton_B);
|
||||
|
||||
if (btn_cancel_cur_state && btn_cancel_cur_state != btn_cancel_prev_state)
|
||||
{
|
||||
|
@ -635,7 +635,7 @@ out2:
|
|||
if (exit_prompt)
|
||||
{
|
||||
consolePrint("press any button to exit\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
}
|
||||
|
||||
romfsFreeContext(&romfs_ctx);
|
||||
|
|
|
@ -118,9 +118,9 @@ int main(int argc, char *argv[])
|
|||
u64 btn_down = 0, btn_held = 0;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
btn_down = utilsHidKeysAllDown();
|
||||
btn_held = utilsHidKeysAllHeld();
|
||||
utilsScanPads();
|
||||
btn_down = utilsGetButtonsDown();
|
||||
btn_held = utilsGetButtonsHeld();
|
||||
if (btn_down || btn_held) break;
|
||||
|
||||
if (titleIsGameCardInfoUpdated())
|
||||
|
@ -139,7 +139,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (btn_down & KEY_A)
|
||||
if (btn_down & HidNpadButton_A)
|
||||
{
|
||||
if (!titleGetUserApplicationData(app_metadata[selected_idx]->title_id, &user_app_data) || !user_app_data.app_info)
|
||||
{
|
||||
|
@ -150,13 +150,13 @@ int main(int argc, char *argv[])
|
|||
|
||||
break;
|
||||
} else
|
||||
if ((btn_down & KEY_DDOWN) || (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN)))
|
||||
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
||||
{
|
||||
selected_idx++;
|
||||
|
||||
if (selected_idx >= app_count)
|
||||
{
|
||||
if (btn_down & KEY_DDOWN)
|
||||
if (btn_down & HidNpadButton_Down)
|
||||
{
|
||||
selected_idx = scroll = 0;
|
||||
} else {
|
||||
|
@ -168,13 +168,13 @@ int main(int argc, char *argv[])
|
|||
scroll++;
|
||||
}
|
||||
} else
|
||||
if ((btn_down & KEY_DUP) || (btn_held & (KEY_LSTICK_UP | KEY_RSTICK_UP)))
|
||||
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
||||
{
|
||||
selected_idx--;
|
||||
|
||||
if (selected_idx == UINT32_MAX)
|
||||
{
|
||||
if (btn_down & KEY_DUP)
|
||||
if (btn_down & HidNpadButton_Up)
|
||||
{
|
||||
selected_idx = (app_count - 1);
|
||||
scroll = (app_count >= page_size ? (app_count - page_size) : 0);
|
||||
|
@ -187,13 +187,13 @@ int main(int argc, char *argv[])
|
|||
scroll--;
|
||||
}
|
||||
} else
|
||||
if (btn_down & KEY_B)
|
||||
if (btn_down & HidNpadButton_B)
|
||||
{
|
||||
exit_prompt = false;
|
||||
goto out2;
|
||||
}
|
||||
|
||||
if (btn_held & (KEY_LSTICK_DOWN | KEY_RSTICK_DOWN | KEY_LSTICK_UP | KEY_RSTICK_UP)) svcSleepThread(50000000); // 50 ms
|
||||
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
||||
}
|
||||
|
||||
consoleClear();
|
||||
|
@ -388,7 +388,7 @@ out2:
|
|||
if (exit_prompt)
|
||||
{
|
||||
consolePrint("press any button to exit\n");
|
||||
utilsWaitForButtonPress(KEY_ANY);
|
||||
utilsWaitForButtonPress(0);
|
||||
}
|
||||
|
||||
if (legal_info_ctx)
|
||||
|
|
|
@ -85,8 +85,8 @@ typedef enum {
|
|||
NcaKeyGeneration_700_801 = 8,
|
||||
NcaKeyGeneration_810_811 = 9,
|
||||
NcaKeyGeneration_900_901 = 10,
|
||||
NcaKeyGeneration_910_1020 = 11,
|
||||
NcaKeyGeneration_Current = NcaKeyGeneration_910_1020
|
||||
NcaKeyGeneration_910_1100 = 11,
|
||||
NcaKeyGeneration_Current = NcaKeyGeneration_910_1100
|
||||
} NcaKeyGeneration;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -107,7 +107,7 @@ static const SystemTitleName g_systemTitles[] = {
|
|||
{ 0x0100000000000018, "ldn" },
|
||||
{ 0x0100000000000019, "nvservices" },
|
||||
{ 0x010000000000001A, "pcv" },
|
||||
{ 0x010000000000001B, "ppc" },
|
||||
{ 0x010000000000001B, "capmtp" },
|
||||
{ 0x010000000000001C, "nvnflinger" },
|
||||
{ 0x010000000000001D, "pcie" },
|
||||
{ 0x010000000000001E, "account" },
|
||||
|
@ -341,12 +341,13 @@ static const SystemTitleName g_systemTitles[] = {
|
|||
{ 0x010000000000B1BA, "ProdFwdbgPackage" },
|
||||
{ 0x010000000000B22A, "scs" },
|
||||
{ 0x010000000000B22B, "ControllerFirmwareDebug" },
|
||||
{ 0x010000000000B240, "htc" },
|
||||
{ 0x010000000000B240, "htc.stub" },
|
||||
{ 0x010000000000C600, "BdkSample01" },
|
||||
{ 0x010000000000C601, "BdkSample02" },
|
||||
{ 0x010000000000C602, "BdkSample03" },
|
||||
{ 0x010000000000C603, "BdkSample04" },
|
||||
{ 0x010000000000D609, "dmnt.gen2" },
|
||||
{ 0x010000000000D623, "DevServer" },
|
||||
|
||||
/* System applications. */
|
||||
{ 0x01008BB00013C000, "flog" },
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
static bool g_resourcesInitialized = false, g_isDevUnit = false;
|
||||
static Mutex g_resourcesMutex = 0;
|
||||
|
||||
static PadState g_padState = {0};
|
||||
|
||||
static FsFileSystem *g_sdCardFileSystem = NULL;
|
||||
|
||||
static FsStorage g_emmcBisSystemPartitionStorage = {0};
|
||||
|
@ -80,6 +82,13 @@ bool utilsInitializeResources(void)
|
|||
bool ret = g_resourcesInitialized;
|
||||
if (ret) goto end;
|
||||
|
||||
/* Configure input. */
|
||||
/* Up to 8 different, full controller inputs. */
|
||||
/* Individual Joy-Cons not supported. */
|
||||
padConfigureInput(8, HidNpadStyleSet_NpadFullCtrl);
|
||||
padInitializeWithMask(&g_padState, 0x1000000FFUL);
|
||||
|
||||
/* Create logfile. */
|
||||
utilsWriteLogBufferToLogFile("________________________________________________________________\r\n");
|
||||
LOGFILE(APP_TITLE " v%u.%u.%u starting. Built on " __DATE__ " - " __TIME__ ".", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
|
||||
|
||||
|
@ -109,7 +118,7 @@ bool utilsInitializeResources(void)
|
|||
goto end;
|
||||
}
|
||||
|
||||
/* Initialize USB host FS interface. */
|
||||
/* Initialize USB Mass Storage Host interface. */
|
||||
rc = usbHsFsInitialize(0);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
|
@ -226,7 +235,7 @@ void utilsCloseResources(void)
|
|||
/* Free NCA crypto buffer. */
|
||||
ncaFreeCryptoBuffer();
|
||||
|
||||
/* Close USB host FS interface. */
|
||||
/* Close USB Mass Storage Host interface. */
|
||||
usbHsFsExit();
|
||||
|
||||
/* Close USB interface. */
|
||||
|
@ -326,30 +335,31 @@ bool utilsIsDevelopmentUnit(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
u64 utilsHidKeysAllDown(void)
|
||||
void utilsScanPads(void)
|
||||
{
|
||||
u64 keys_down = 0;
|
||||
for(u32 i = 0; i < CONTROLLER_UNKNOWN; i++) keys_down |= hidKeysDown(i);
|
||||
return keys_down;
|
||||
padUpdate(&g_padState);
|
||||
}
|
||||
|
||||
u64 utilsHidKeysAllHeld(void)
|
||||
u64 utilsGetButtonsDown(void)
|
||||
{
|
||||
u64 keys_held = 0;
|
||||
for(u32 i = 0; i < CONTROLLER_UNKNOWN; i++) keys_held |= hidKeysHeld(i);
|
||||
return keys_held;
|
||||
return padGetButtonsDown(&g_padState);
|
||||
}
|
||||
|
||||
u64 utilsGetButtonsHeld(void)
|
||||
{
|
||||
return padGetButtons(&g_padState);
|
||||
}
|
||||
|
||||
void utilsWaitForButtonPress(u64 flag)
|
||||
{
|
||||
/* Don't consider touch screen presses nor stick movement as button inputs. */
|
||||
if (!flag) flag = ~(KEY_TOUCH | KEY_LSTICK_LEFT | KEY_LSTICK_RIGHT | KEY_LSTICK_UP | KEY_LSTICK_DOWN | KEY_RSTICK_LEFT | KEY_RSTICK_RIGHT | KEY_RSTICK_UP | KEY_RSTICK_DOWN);
|
||||
/* Don't consider stick movement as button inputs. */
|
||||
if (!flag) flag = (HidNpadButton_StickLLeft | HidNpadButton_StickLRight | HidNpadButton_StickLUp | HidNpadButton_StickLDown | HidNpadButton_StickRLeft | HidNpadButton_StickRRight | \
|
||||
HidNpadButton_StickRUp | HidNpadButton_StickRDown);
|
||||
|
||||
while(appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
u64 keys_down = utilsHidKeysAllDown();
|
||||
if (keys_down & flag) break;
|
||||
utilsScanPads();
|
||||
if (utilsGetButtonsDown() & flag) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
|
||||
#define BIS_SYSTEM_PARTITION_MOUNT_NAME "sys:"
|
||||
|
||||
#define KEY_ANY 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -85,13 +83,14 @@ void utilsJoinThread(Thread *thread);
|
|||
/// Returns true if the application is running under a development unit.
|
||||
bool utilsIsDevelopmentUnit(void);
|
||||
|
||||
/// Functions to retrieve down/held keys from all input controllers.
|
||||
/// hidScanInput() must be called before any of these.
|
||||
u64 utilsHidKeysAllDown(void);
|
||||
u64 utilsHidKeysAllHeld(void);
|
||||
/// Functions to retrieve down/held buttons from all input controllers.
|
||||
/// utilsScanPads() must be called before utilsGetButtonsDown() / utilsGetButtonsHeld().
|
||||
void utilsScanPads(void);
|
||||
u64 utilsGetButtonsDown(void);
|
||||
u64 utilsGetButtonsHeld(void);
|
||||
|
||||
/// Waits until any key matching the provided input flag is pressed.
|
||||
/// If 'flag' is set to zero (KEY_ANY), any key press will count.
|
||||
/// Waits until any button matching the provided input flag is pressed.
|
||||
/// If 'flag' is set to zero, any button press will count.
|
||||
void utilsWaitForButtonPress(u64 flag);
|
||||
|
||||
/// Formats a string and appends it to the provided buffer.
|
||||
|
|
Loading…
Reference in a new issue