Touch screen controls and some other minor changes
This commit is contained in:
parent
5ebf896581
commit
77cce54ca6
10
README.md
10
README.md
|
@ -8,6 +8,8 @@ This is a project I've recently just started working on again. Currently its usi
|
||||||
* Dark and light mode
|
* Dark and light mode
|
||||||
* Landscape reading view
|
* Landscape reading view
|
||||||
* Portrait reading view
|
* Portrait reading view
|
||||||
|
* Touch screen controls
|
||||||
|
* Touch the botton/top of the screen to zoom in/out and left and right to change the page.
|
||||||
|
|
||||||
### Current State:
|
### Current State:
|
||||||
* Most PDF files work, and all epub, cbz and xps files I've tested work.
|
* Most PDF files work, and all epub, cbz and xps files I've tested work.
|
||||||
|
@ -15,7 +17,6 @@ This is a project I've recently just started working on again. Currently its usi
|
||||||
### TODO:
|
### TODO:
|
||||||
* Do some extra testing on file compatibility.
|
* Do some extra testing on file compatibility.
|
||||||
* 2 pages side by side in landscape.
|
* 2 pages side by side in landscape.
|
||||||
* Touch screen for going to next page.
|
|
||||||
* Hardware lock to prevent accidental touches (maybe Vol- ?) (?).
|
* Hardware lock to prevent accidental touches (maybe Vol- ?) (?).
|
||||||
* Save orientation, and dark mode settings.
|
* Save orientation, and dark mode settings.
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ Light Mode Landscape Reading:
|
||||||
* NX-Shell Team - A good amount of the code is from an old version of their application.
|
* NX-Shell Team - A good amount of the code is from an old version of their application.
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
* Release built with [libnx release v.4.1.3](https://github.com/switchbrew/libnx).
|
* Release built with [libnx release v2.4.0](https://github.com/switchbrew/libnx).
|
||||||
* Uses `freetype` and other libs which comes with `switch-portlibs` via `devkitPro pacman`:
|
* Uses `freetype` and other libs which comes with `switch-portlibs` via `devkitPro pacman`:
|
||||||
```
|
```
|
||||||
pacman -S libnx switch-portlibs
|
pacman -S libnx switch-portlibs
|
||||||
|
@ -61,8 +62,3 @@ make mupdf
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
to build.
|
to build.
|
||||||
|
|
||||||
If you don't have twili debugger installed then delete the -ltwili flag on the Makefile to compile:
|
|
||||||
```
|
|
||||||
LIBS: -ltwili
|
|
||||||
```
|
|
||||||
|
|
|
@ -48,6 +48,12 @@ void Menu_StartChoosing() {
|
||||||
SDL_GetWindowSize(WINDOW, &windowX, &windowY);
|
SDL_GetWindowSize(WINDOW, &windowX, &windowY);
|
||||||
int warningWidth = 700;
|
int warningWidth = 700;
|
||||||
int warningHeight = 300;
|
int warningHeight = 300;
|
||||||
|
|
||||||
|
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||||
|
|
||||||
|
PadState pad;
|
||||||
|
padInitializeDefault(&pad);
|
||||||
|
|
||||||
while(appletMainLoop()) {
|
while(appletMainLoop()) {
|
||||||
if (readingBook) {
|
if (readingBook) {
|
||||||
break;
|
break;
|
||||||
|
@ -59,23 +65,15 @@ void Menu_StartChoosing() {
|
||||||
SDL_ClearScreen(RENDERER, backColor);
|
SDL_ClearScreen(RENDERER, backColor);
|
||||||
SDL_RenderClear(RENDERER);
|
SDL_RenderClear(RENDERER);
|
||||||
|
|
||||||
//hidScanInput();
|
|
||||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
|
||||||
|
|
||||||
PadState pad;
|
|
||||||
padInitializeDefault(&pad);
|
|
||||||
|
|
||||||
padUpdate(&pad);
|
padUpdate(&pad);
|
||||||
|
|
||||||
//u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
|
||||||
//u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
|
|
||||||
|
|
||||||
u64 kDown = padGetButtonsDown(&pad);
|
u64 kDown = padGetButtonsDown(&pad);
|
||||||
u64 kHeld = padGetButtons(&pad);
|
u64 kHeld = padGetButtons(&pad);
|
||||||
|
u64 kUp = padGetButtonsUp(&pad);
|
||||||
|
|
||||||
/*if (!isWarningOnScreen && kDown & KEY_PLUS) {
|
if (!isWarningOnScreen && kDown & HidNpadButton_Plus) {
|
||||||
break;
|
break;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (kDown & HidNpadButton_B) {
|
if (kDown & HidNpadButton_B) {
|
||||||
if (!isWarningOnScreen) {
|
if (!isWarningOnScreen) {
|
||||||
|
@ -118,7 +116,7 @@ void Menu_StartChoosing() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kDown & HidNpadButton_Up) {
|
if (kDown & HidNpadButton_Up || kDown & HidNpadButton_StickRUp) {
|
||||||
if (choosenIndex != 0 && !isWarningOnScreen) {
|
if (choosenIndex != 0 && !isWarningOnScreen) {
|
||||||
choosenIndex--;
|
choosenIndex--;
|
||||||
} else if (choosenIndex == 0) {
|
} else if (choosenIndex == 0) {
|
||||||
|
@ -126,7 +124,7 @@ void Menu_StartChoosing() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kDown & HidNpadButton_Down) {
|
if (kDown & HidNpadButton_Down || kDown & HidNpadButton_StickRDown) {
|
||||||
if (choosenIndex == amountOfFiles-1) {
|
if (choosenIndex == amountOfFiles-1) {
|
||||||
choosenIndex = 0;
|
choosenIndex = 0;
|
||||||
} else if (choosenIndex < amountOfFiles-1 && !isWarningOnScreen) {
|
} else if (choosenIndex < amountOfFiles-1 && !isWarningOnScreen) {
|
||||||
|
@ -134,7 +132,7 @@ void Menu_StartChoosing() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kDown & HidNpadButton_Minus) {
|
if (kUp & HidNpadButton_Minus) {
|
||||||
configDarkMode = !configDarkMode;
|
configDarkMode = !configDarkMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <mupdf/pdf.h>
|
#include <mupdf/pdf.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "PageLayout.hpp"
|
#include "PageLayout.hpp"
|
||||||
|
#include <switch.h>
|
||||||
struct SDL_Texture;
|
struct SDL_Texture;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -21,7 +21,9 @@ void Menu_OpenBook(char *path) {
|
||||||
|
|
||||||
/*TouchInfo touchInfo;
|
/*TouchInfo touchInfo;
|
||||||
Touch_Init(&touchInfo);*/
|
Touch_Init(&touchInfo);*/
|
||||||
|
hidInitializeTouchScreen();
|
||||||
|
|
||||||
|
s32 prev_touchcount=0;
|
||||||
bool helpMenu = false;
|
bool helpMenu = false;
|
||||||
|
|
||||||
// Configure our supported input layout: a single player with standard controller syles
|
// Configure our supported input layout: a single player with standard controller syles
|
||||||
|
@ -34,17 +36,46 @@ void Menu_OpenBook(char *path) {
|
||||||
while(result >= 0 && appletMainLoop()) {
|
while(result >= 0 && appletMainLoop()) {
|
||||||
reader->draw(helpMenu);
|
reader->draw(helpMenu);
|
||||||
|
|
||||||
//hidScanInput();
|
|
||||||
|
|
||||||
//u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
|
||||||
//u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
|
|
||||||
|
|
||||||
padUpdate(&pad);
|
padUpdate(&pad);
|
||||||
|
|
||||||
u64 kDown = padGetButtonsDown(&pad);
|
u64 kDown = padGetButtonsDown(&pad);
|
||||||
u64 kHeld = padGetButtons(&pad);
|
u64 kHeld = padGetButtons(&pad);
|
||||||
u64 kUp = padGetButtonsUp(&pad);
|
u64 kUp = padGetButtonsUp(&pad);
|
||||||
|
|
||||||
|
HidTouchScreenState state={0};
|
||||||
|
|
||||||
|
if(hidGetTouchScreenStates(&state, 1)) {
|
||||||
|
if(state.count != prev_touchcount) {
|
||||||
|
prev_touchcount = state.count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(s32 i=0; i<state.count; i++) {
|
||||||
|
if (state.touches[i].x > 1000)
|
||||||
|
if (reader->currentPageLayout() == BookPageLayoutPortrait)
|
||||||
|
reader->next_page(1);
|
||||||
|
else if (reader->currentPageLayout() == BookPageLayoutLandscape)
|
||||||
|
reader->zoom_in();
|
||||||
|
|
||||||
|
if (state.touches[i].x < 280)
|
||||||
|
if (reader->currentPageLayout() == BookPageLayoutPortrait)
|
||||||
|
reader->previous_page(1);
|
||||||
|
else if (reader->currentPageLayout() == BookPageLayoutLandscape)
|
||||||
|
reader->zoom_out();
|
||||||
|
|
||||||
|
if (state.touches[i].y < 200 && (state.touches[i].x > 280 || state.touches[i].x < 1000))
|
||||||
|
if (reader->currentPageLayout() == BookPageLayoutPortrait)
|
||||||
|
reader->zoom_in();
|
||||||
|
else if (reader->currentPageLayout() == BookPageLayoutLandscape)
|
||||||
|
reader->previous_page(1);
|
||||||
|
|
||||||
|
if (state.touches[i].y > 500 && (state.touches[i].x > 280 || state.touches[i].x < 1000))
|
||||||
|
if (reader->currentPageLayout() == BookPageLayoutPortrait)
|
||||||
|
reader->zoom_out();
|
||||||
|
else if (reader->currentPageLayout() == BookPageLayoutLandscape)
|
||||||
|
reader->next_page(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!helpMenu && kDown & HidNpadButton_Left) {
|
if (!helpMenu && kDown & HidNpadButton_Left) {
|
||||||
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
||||||
reader->previous_page(1);
|
reader->previous_page(1);
|
||||||
|
@ -83,26 +114,29 @@ void Menu_OpenBook(char *path) {
|
||||||
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
||||||
reader->move_page_up();
|
reader->move_page_up();
|
||||||
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
||||||
reader->move_page_left();
|
reader->move_page_right();
|
||||||
}
|
}
|
||||||
} else if (!helpMenu && kHeld & HidNpadButton_StickLDown) {
|
} else if (!helpMenu && kHeld & HidNpadButton_StickLDown) {
|
||||||
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
if (reader->currentPageLayout() == BookPageLayoutPortrait ) {
|
||||||
reader->move_page_down();
|
reader->move_page_down();
|
||||||
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
} else if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
||||||
reader->move_page_right();
|
reader->move_page_left();
|
||||||
}
|
}
|
||||||
} else if (!helpMenu && kHeld & HidNpadButton_StickLRight) {
|
} else if (!helpMenu && kHeld & HidNpadButton_StickLRight) {
|
||||||
if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
||||||
//reader->move_page_up();
|
|
||||||
reader->move_page_down();
|
reader->move_page_down();
|
||||||
}
|
}
|
||||||
} else if (!helpMenu && kHeld & HidNpadButton_StickLLeft) {
|
} else if (!helpMenu && kHeld & HidNpadButton_StickLLeft) {
|
||||||
if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
if ((reader->currentPageLayout() == BookPageLayoutLandscape) ) {
|
||||||
//reader->move_page_down();
|
|
||||||
reader->move_page_up();
|
reader->move_page_up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!helpMenu && kDown & HidNpadButton_LeftSR)
|
||||||
|
reader->next_page(10);
|
||||||
|
else if (!helpMenu && kDown & HidNpadButton_LeftSL)
|
||||||
|
reader->previous_page(10);
|
||||||
|
|
||||||
if (kDown & HidNpadButton_B) {
|
if (kDown & HidNpadButton_B) {
|
||||||
if (helpMenu) {
|
if (helpMenu) {
|
||||||
helpMenu = !helpMenu;
|
helpMenu = !helpMenu;
|
||||||
|
@ -115,7 +149,7 @@ void Menu_OpenBook(char *path) {
|
||||||
reader->permStatusBar = !reader->permStatusBar;
|
reader->permStatusBar = !reader->permStatusBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!helpMenu && kDown & HidNpadButton_StickL || kDown & HidNpadButton_StickR) {
|
if ((!helpMenu && kDown & HidNpadButton_StickL) || kDown & HidNpadButton_StickR) {
|
||||||
reader->reset_page();
|
reader->reset_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue