eBookReaderSwitch/source/menu_book_reader.cpp

90 lines
2.4 KiB
C++
Raw Normal View History

#include <iostream>
2019-08-29 02:40:26 +00:00
extern "C" {
#include "menu_book_reader.h"
#include "common.h"
//#include "touch_helper.h"
2019-08-29 02:40:26 +00:00
}
#include "BookReader.hpp"
extern SDL_Renderer* RENDERER;
extern SDL_Window* WINDOW;
extern SDL_Surface* WINDOW_SURFACE;
void Menu_OpenBook(char *path) {
BookReader *reader = new BookReader(RENDERER, path);
2019-08-29 02:40:26 +00:00
/*TouchInfo touchInfo;
Touch_Init(&touchInfo);*/
2019-08-29 02:40:26 +00:00
while(appletMainLoop()) {
reader->draw(WINDOW_SURFACE, ARIAL_UNICODE);
2019-08-29 02:40:26 +00:00
hidScanInput();
//Touch_Process(&touchInfo);
2019-08-29 02:40:26 +00:00
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
u64 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
if ((kDown & KEY_B) || (kDown & KEY_PLUS)) {
std::cout << "B | PLUS" << std::endl;
2019-08-29 02:40:26 +00:00
break;
}
2019-08-29 02:40:26 +00:00
if ((kDown & KEY_DLEFT) || (kDown & KEY_L)) {
std::cout << "B | LEFT" << std::endl;
2019-08-29 02:40:26 +00:00
reader->previous_page();
}
2019-08-29 02:40:26 +00:00
if ((kDown & KEY_DRIGHT) || (kDown & KEY_R)) {
std::cout << "B | RIGHT" << std::endl;
2019-08-29 02:40:26 +00:00
reader->next_page();
}
2019-08-29 02:40:26 +00:00
if (kDown & KEY_LSTICK) {
std::cout << "B | LEFT STICK KEY" << std::endl;
2019-08-29 02:40:26 +00:00
reader->reset_page();
}
2019-08-29 02:40:26 +00:00
if (kHeld & KEY_DUP) {
std::cout << "B | UP" << std::endl;
2019-08-29 02:40:26 +00:00
reader->zoom_in();
}
2019-08-29 02:40:26 +00:00
if (kHeld & KEY_DDOWN) {
std::cout << "B | DOWN" << std::endl;
2019-08-29 02:40:26 +00:00
reader->zoom_out();
}
2019-08-29 02:40:26 +00:00
if (kHeld & KEY_LSTICK_UP) {
std::cout << "B | LEFT STICK UP" << std::endl;
2019-08-29 02:40:26 +00:00
reader->move_page_up();
}
2019-08-29 02:40:26 +00:00
if (kHeld & KEY_LSTICK_DOWN) {
std::cout << "B | LEFT STICK DOWN" << std::endl;
2019-08-29 02:40:26 +00:00
reader->move_page_down();
}
2019-08-29 02:40:26 +00:00
if (kHeld & KEY_LSTICK_LEFT) {
std::cout << "B | LEFT STICK LEFT" << std::endl;
2019-08-29 02:40:26 +00:00
reader->move_page_left();
}
2019-08-29 02:40:26 +00:00
if (kHeld & KEY_LSTICK_RIGHT) {
std::cout << "B | LEFT STICK RIGHT" << std::endl;
2019-08-29 02:40:26 +00:00
reader->move_page_right();
}
2019-08-29 02:40:26 +00:00
/*if (touchInfo.state == TouchEnded && touchInfo.tapType != TapNone)
2019-08-29 02:40:26 +00:00
{
if (tapped_inside(touchInfo, 0, 0, 120, 720))
reader->previous_page();
else if (tapped_inside(touchInfo, 1160, 0, 1280, 720))
reader->next_page();
}*/
2019-08-29 02:40:26 +00:00
}
2019-08-29 02:40:26 +00:00
delete reader;
}