eBookReaderSwitch/source/menu_book_reader.cpp

67 lines
1.7 KiB
C++
Raw Normal View History

2019-08-29 02:40:26 +00:00
extern "C" {
#include "menu_book_reader.h"
//#include "touch_helper.h"
2019-08-29 02:40:26 +00:00
}
#include "BookReader.hpp"
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
2019-08-29 02:40:26 +00:00
void Menu_OpenBook(SDL_Renderer *renderer, SDL_Surface* window_surface, TTF_Font *font, char *path)
2019-08-29 02:40:26 +00:00
{
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, font);
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)
break;
if ((kDown & KEY_DLEFT) || (kDown & KEY_L))
reader->previous_page();
if ((kDown & KEY_DRIGHT) || (kDown & KEY_R))
reader->next_page();
if (kDown & KEY_LSTICK)
reader->reset_page();
if (kHeld & KEY_DUP)
reader->zoom_in();
if (kHeld & KEY_DDOWN)
reader->zoom_out();
if (kHeld & KEY_LSTICK_UP)
reader->move_page_up();
if (kHeld & KEY_LSTICK_DOWN)
reader->move_page_down();
if (kHeld & KEY_LSTICK_LEFT)
reader->move_page_left();
if (kHeld & KEY_LSTICK_RIGHT)
reader->move_page_right();
/*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
}
delete reader;
}