From f0863aacc223863e9d33f08438eaefea9c4cdd00 Mon Sep 17 00:00:00 2001 From: Question Date: Tue, 13 Jul 2021 01:25:32 -0500 Subject: [PATCH 1/5] Minor changes --- Makefile | 4 +- source/menus/book-chooser/MenuChooser.cpp | 27 ++++--- source/menus/book/menu_book_reader.cpp | 85 +++++++++++++---------- source/status_bar.c | 5 +- 4 files changed, 71 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index 12b5816..98d26e6 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ INCLUDES := include include/menus/book include/menus/book-chooser include/he ROMFS := romfs VERSION_MAJOR := 0 -VERSION_MINOR := 2 -VERSION_MICRO := 2 +VERSION_MINOR := 3 +VERSION_MICRO := 0 APP_TITLE := eBookReader APP_AUTHOR := SeanOMik diff --git a/source/menus/book-chooser/MenuChooser.cpp b/source/menus/book-chooser/MenuChooser.cpp index 67a4cf9..a2e2bfe 100644 --- a/source/menus/book-chooser/MenuChooser.cpp +++ b/source/menus/book-chooser/MenuChooser.cpp @@ -59,16 +59,25 @@ void Menu_StartChoosing() { SDL_ClearScreen(RENDERER, backColor); SDL_RenderClear(RENDERER); - hidScanInput(); + //hidScanInput(); + padConfigureInput(1, HidNpadStyleSet_NpadStandard); - u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); - u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO); + PadState pad; + padInitializeDefault(&pad); + + padUpdate(&pad); + + //u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); + //u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO); + + u64 kDown = padGetButtonsDown(&pad); + u64 kHeld = padGetButtons(&pad); /*if (!isWarningOnScreen && kDown & KEY_PLUS) { break; }*/ - if (kDown & KEY_B) { + if (kDown & HidNpadButton_B) { if (!isWarningOnScreen) { break; } else { @@ -76,7 +85,7 @@ void Menu_StartChoosing() { } } - if (kDown & KEY_A) { + if (kDown & HidNpadButton_A) { int bookIndex = 0; for (const auto & entry : fs::directory_iterator(path)) { string filename = entry.path().filename().string(); @@ -109,7 +118,7 @@ void Menu_StartChoosing() { } } - if (kDown & KEY_DUP) { + if (kDown & HidNpadButton_Up) { if (choosenIndex != 0 && !isWarningOnScreen) { choosenIndex--; } else if (choosenIndex == 0) { @@ -117,7 +126,7 @@ void Menu_StartChoosing() { } } - if (kDown & KEY_DDOWN) { + if (kDown & HidNpadButton_Down) { if (choosenIndex == amountOfFiles-1) { choosenIndex = 0; } else if (choosenIndex < amountOfFiles-1 && !isWarningOnScreen) { @@ -125,7 +134,7 @@ void Menu_StartChoosing() { } } - if (kDown & KEY_MINUS) { + if (kDown & HidNpadButton_Minus) { configDarkMode = !configDarkMode; } @@ -171,4 +180,4 @@ void Menu_StartChoosing() { SDL_RenderPresent(RENDERER); } -} \ No newline at end of file +} diff --git a/source/menus/book/menu_book_reader.cpp b/source/menus/book/menu_book_reader.cpp index 6f2a9bf..8fe9880 100644 --- a/source/menus/book/menu_book_reader.cpp +++ b/source/menus/book/menu_book_reader.cpp @@ -24,75 +24,86 @@ void Menu_OpenBook(char *path) { bool helpMenu = false; + // Configure our supported input layout: a single player with standard controller syles + padConfigureInput(1, HidNpadStyleSet_NpadStandard); + // Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller) + PadState pad; + padInitializeDefault(&pad); + //Touch_Process(&touchInfo); + while(result >= 0 && appletMainLoop()) { reader->draw(helpMenu); - hidScanInput(); - - //Touch_Process(&touchInfo); - - u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); - u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO); + //hidScanInput(); + + //u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); + //u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO); - if (!helpMenu && kDown & KEY_DLEFT) { - if (reader->currentPageLayout() == BookPageLayoutPortrait || (!hidGetHandheldMode())) { + padUpdate(&pad); + + u64 kDown = padGetButtonsDown(&pad); + u64 kHeld = padGetButtons(&pad); + u64 kUp = padGetButtonsUp(&pad); + + if (!helpMenu && kDown & HidNpadButton_Left) { + if (reader->currentPageLayout() == BookPageLayoutPortrait ) { reader->previous_page(1); - } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { reader->zoom_out(); } - } else if (!helpMenu && kDown & KEY_DRIGHT) { - if (reader->currentPageLayout() == BookPageLayoutPortrait || (!hidGetHandheldMode())) { + } else if (!helpMenu && kDown & HidNpadButton_Right) { + if (reader->currentPageLayout() == BookPageLayoutPortrait ) { reader->next_page(1); - } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { reader->zoom_in(); } } - if (!helpMenu && kDown & KEY_R) { + if (!helpMenu && kDown & HidNpadButton_R) { reader->next_page(10); - } else if (!helpMenu && kDown & KEY_L) { + } else if (!helpMenu && kDown & HidNpadButton_L) { reader->previous_page(10); } - if (!helpMenu && ((kDown & KEY_DUP) || (kHeld & KEY_RSTICK_UP))) { - if (reader->currentPageLayout() == BookPageLayoutPortrait || (!hidGetHandheldMode())) { + if (!helpMenu && ((kDown & HidNpadButton_Up) || (kHeld & HidNpadButton_StickRUp))) { + if (reader->currentPageLayout() == BookPageLayoutPortrait ) { reader->zoom_in(); - } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { reader->previous_page(1); } - } else if (!helpMenu && ((kDown & KEY_DDOWN) || (kHeld & KEY_RSTICK_DOWN))) { - if (reader->currentPageLayout() == BookPageLayoutPortrait || (!hidGetHandheldMode())) { + } else if (!helpMenu && ((kDown & HidNpadButton_Down) || (kHeld & HidNpadButton_StickRDown))) { + if (reader->currentPageLayout() == BookPageLayoutPortrait ) { reader->zoom_out(); - } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { reader->next_page(1); } } - if (!helpMenu && kHeld & KEY_LSTICK_UP) { - if (reader->currentPageLayout() == BookPageLayoutPortrait || (!hidGetHandheldMode())) { + if (!helpMenu && kHeld & HidNpadButton_StickLUp) { + if (reader->currentPageLayout() == BookPageLayoutPortrait ) { reader->move_page_up(); - } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { reader->move_page_left(); } - } else if (!helpMenu && kHeld & KEY_LSTICK_DOWN) { - if (reader->currentPageLayout() == BookPageLayoutPortrait || (!hidGetHandheldMode())) { + } else if (!helpMenu && kHeld & HidNpadButton_StickLDown) { + if (reader->currentPageLayout() == BookPageLayoutPortrait ) { reader->move_page_down(); - } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { reader->move_page_right(); } - } else if (!helpMenu && kHeld & KEY_LSTICK_RIGHT) { - if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if (!helpMenu && kHeld & HidNpadButton_StickLRight) { + if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { //reader->move_page_up(); reader->move_page_down(); } - } else if (!helpMenu && kHeld & KEY_LSTICK_LEFT) { - if ((reader->currentPageLayout() == BookPageLayoutLandscape) && (hidGetHandheldMode())) { + } else if (!helpMenu && kHeld & HidNpadButton_StickLLeft) { + if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) { //reader->move_page_down(); reader->move_page_up(); } } - if (kDown & KEY_B) { + if (kDown & HidNpadButton_B) { if (helpMenu) { helpMenu = !helpMenu; } else { @@ -100,27 +111,27 @@ void Menu_OpenBook(char *path) { } } - if (!helpMenu && kDown & KEY_X) { + if (!helpMenu && kDown & HidNpadButton_X) { reader->permStatusBar = !reader->permStatusBar; } - if (!helpMenu && kDown & KEY_LSTICK || kDown & KEY_RSTICK) { + if (!helpMenu && kDown & HidNpadButton_StickL || kDown & HidNpadButton_StickR) { reader->reset_page(); } - if (!helpMenu && kDown & KEY_Y) { + if (!helpMenu && kDown & HidNpadButton_Y) { reader->switch_page_layout(); } - if (!helpMenu && kDown & KEY_MINUS) { + if (!helpMenu && kUp & HidNpadButton_Minus) { configDarkMode = !configDarkMode; reader->previous_page(0); } - if (kDown & KEY_PLUS) { + if (kDown & HidNpadButton_Plus) { helpMenu = !helpMenu; } - + /*if (touchInfo.state == TouchEnded && touchInfo.tapType != TapNone) { float tapRegion = 120; diff --git a/source/status_bar.c b/source/status_bar.c index 1f2cf82..d334c2b 100644 --- a/source/status_bar.c +++ b/source/status_bar.c @@ -33,7 +33,8 @@ static char *Clock_GetCurrentTime(void) { static void StatusBar_GetBatteryStatus(int x, int y) { u32 percent = 0; - ChargerType state; + //ChargerType state; + PsmChargerType state; int width = 0; char buf[5]; @@ -140,4 +141,4 @@ void StatusBar_DisplayTime(bool portriat) { StatusBar_GetBatteryStatus(1260 - (timeWidth + helpWidth) - 110, (40 - timeHeight) / 2 + 34); // 34 is height of battery img } -} \ No newline at end of file +} From bf511e73b1da165b16b9676fe695441e506be36d Mon Sep 17 00:00:00 2001 From: Question Date: Tue, 13 Jul 2021 01:27:42 -0500 Subject: [PATCH 2/5] Changed README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96a5923..227e8f5 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Light Mode Landscape Reading: * NX-Shell Team - A good amount of the code is from an old version of their application. ### Building -* Release built with [libnx release v2.4.0](https://github.com/switchbrew/libnx). +* Release built with [libnx release v.4.1.3](https://github.com/switchbrew/libnx). * Uses `freetype` and other libs which comes with `switch-portlibs` via `devkitPro pacman`: ``` pacman -S libnx switch-portlibs From 4d8013da71770e8630ca8eb701d45e518e197883 Mon Sep 17 00:00:00 2001 From: Question Date: Tue, 13 Jul 2021 02:11:31 -0500 Subject: [PATCH 3/5] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 227e8f5..d93fad1 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,8 @@ make mupdf make ``` to build. + +if you don't have twili installed then delete the -ltwili flag on: +``` +LIBS: -ltwili +``` From 9265e72bbfc22cc228c023fa6b0b21809303548f Mon Sep 17 00:00:00 2001 From: Question Date: Tue, 13 Jul 2021 02:13:43 -0500 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d93fad1..6f18c6a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ make ``` to build. -if you don't have twili installed then delete the -ltwili flag on: +* If you don't have twili debugger installed then delete the -ltwili flag on the Makefile to compile: ``` LIBS: -ltwili ``` From 5ebf89658120788fb4cc9d857340a9165cf52813 Mon Sep 17 00:00:00 2001 From: Question Date: Tue, 13 Jul 2021 02:14:45 -0500 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f18c6a..3294914 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ make ``` to build. -* If you don't have twili debugger installed then delete the -ltwili flag on the Makefile to compile: +If you don't have twili debugger installed then delete the -ltwili flag on the Makefile to compile: ``` LIBS: -ltwili ```