mirror of
https://github.com/MiyooCFW/buildroot.git
synced 2025-09-27 22:24:19 +03:00
PACKAGE/DEFCONFIG: add sdlbook
app (#99)
with miyoo&optimization changes
This commit is contained in:
0
board/miyoo/main/books/.gitkeep
Normal file
0
board/miyoo/main/books/.gitkeep
Normal file
5
board/miyoo/main/gmenu2x/sections/applications/sdlbook
Normal file
5
board/miyoo/main/gmenu2x/sections/applications/sdlbook
Normal file
@@ -0,0 +1,5 @@
|
||||
title=SDLbook
|
||||
description=DJVU/PDF/EPUB viewer & more
|
||||
exec=/usr/bin/sdlbook
|
||||
manual=/mnt/manuals/sdlbook.man.txt
|
||||
selectordir=/mnt/books
|
15
board/miyoo/main/manuals/sdlbook.man.txt
Normal file
15
board/miyoo/main/manuals/sdlbook.man.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
SDLbook hotkeys:
|
||||
-----------------------
|
||||
A = accept
|
||||
B = cancel
|
||||
UP = scroll up
|
||||
DOWN = scroll down
|
||||
L2/R2+UP = scroll fast upwards
|
||||
L2/R2+DOWN = scroll fast downwards
|
||||
L1 = scroll one page up
|
||||
R1 = scroll one page down
|
||||
X = zoom in page
|
||||
Y = zoom out page
|
||||
SELECT = jump to inserted page number
|
||||
RESET = quit app
|
||||
START = show HELP screen
|
@@ -63,6 +63,8 @@ convert board/miyoo/miyoo-splash.png -pointsize 12 -fill white -annotate +10+230
|
||||
# Workaround for build apss and configs being placed in /usr/ after img generation (as we use MAIN)
|
||||
test -d "${BINARIES_DIR}/gmenu2x" && cp -r "${BINARIES_DIR}/gmenu2x/" "${BINARIES_DIR}/main/"
|
||||
test -d "${BINARIES_DIR}/emus" && cp -r "${BINARIES_DIR}/emus/" "${BINARIES_DIR}/main/"
|
||||
test -d "${BINARIES_DIR}/apps" && cp -r "${BINARIES_DIR}/apps/" "${BINARIES_DIR}/main/"
|
||||
test -d "${BINARIES_DIR}/games" && cp -r "${BINARIES_DIR}/games/" "${BINARIES_DIR}/main/"
|
||||
if test -d "${BINARIES_DIR}/retroarch"; then
|
||||
rsync -avzh "${BINARIES_DIR}/retroarch/" "${BINARIES_DIR}/main/.retroarch/"
|
||||
## Generate list of cores to be used
|
||||
|
@@ -234,6 +234,7 @@ BR2_PACKAGE_MIYOO_CTL=y
|
||||
BR2_PACKAGE_FBCAT=y
|
||||
BR2_PACKAGE_ST_SDL=y
|
||||
BR2_PACKAGE_COMMANDER=y
|
||||
BR2_PACKAGE_SDLBOOK=y
|
||||
BR2_PACKAGE_OPKG=y
|
||||
BR2_PACKAGE_OPKG_UTILS=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
|
@@ -211,6 +211,7 @@ BR2_PACKAGE_MIYOO_CTL=y
|
||||
BR2_PACKAGE_FBCAT=y
|
||||
BR2_PACKAGE_ST_SDL=y
|
||||
BR2_PACKAGE_COMMANDER=y
|
||||
BR2_PACKAGE_SDLBOOK=y
|
||||
BR2_PACKAGE_OPKG=y
|
||||
BR2_PACKAGE_OPKG_UTILS=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
|
@@ -2219,6 +2219,7 @@ menu "Miscellaneous"
|
||||
source "package/fbcat/Config.in"
|
||||
source "package/st-sdl/Config.in"
|
||||
source "package/commander/Config.in"
|
||||
source "package/sdlbook/Config.in"
|
||||
|
||||
endmenu
|
||||
|
||||
|
@@ -0,0 +1,99 @@
|
||||
From 5ed7374aa765b8e0a5380590efcefa5c6ddcdb06 Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Wed, 27 Mar 2024 21:26:08 +0100
|
||||
Subject: [PATCH 1/7] mod input_loop() char result stack with arrow keys
|
||||
|
||||
---
|
||||
sdlbook.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
1 file changed, 47 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index 33a2f29..d608aba 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -589,6 +589,7 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
ezsdl_update_region(0, 0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height()));
|
||||
char* p = result;
|
||||
*p = 0;
|
||||
+ int p_n = 48;
|
||||
struct event event;
|
||||
while(1) {
|
||||
enum eventtypes e;
|
||||
@@ -597,20 +598,61 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
case EV_QUIT:
|
||||
case EV_KEYUP:
|
||||
switch(event.which) {
|
||||
- case SDLK_BACKSPACE:
|
||||
+ case SDLK_BACKSPACE: case SDLK_LEFT:
|
||||
+ if(flags == INPUT_LOOP_RET)
|
||||
+ goto out;
|
||||
if(p > result) p--;
|
||||
+ p_n = *(p - 1);
|
||||
*p = 0;
|
||||
goto drawit;
|
||||
- case SDLK_RETURN: case SDLK_ESCAPE:
|
||||
+ case SDLK_RIGHT:
|
||||
+ if(flags == INPUT_LOOP_RET)
|
||||
+ goto out;
|
||||
+ if(p - result < 20) {
|
||||
+ p_n = 48;
|
||||
+ *(p++) = p_n;
|
||||
+ *p = 0;
|
||||
+ goto drawit;
|
||||
+ } else
|
||||
+ break;
|
||||
+ case SDLK_RETURN: case SDLK_ESCAPE: case SDLK_g:
|
||||
out:;
|
||||
*p = 0;
|
||||
ezsdl_clear();
|
||||
return;
|
||||
+ case SDLK_UP:
|
||||
+ if(flags == INPUT_LOOP_RET)
|
||||
+ goto out;
|
||||
+ p_n = *(p - 1);
|
||||
+ if(p_n < 48 || p_n > 57) p_n = 48;
|
||||
+ if(p >= result && p_n < 57 && (p - result < 20)) {
|
||||
+ if (p > result) p--;
|
||||
+ p_n++;
|
||||
+ *(p++) = p_n;
|
||||
+ *p = 0;
|
||||
+ goto drawit;
|
||||
+ } else
|
||||
+ break;
|
||||
+ case SDLK_DOWN:
|
||||
+ if(flags == INPUT_LOOP_RET)
|
||||
+ goto out;
|
||||
+ p_n = *(p - 1);
|
||||
+ if(p_n < 48 || p_n > 57) p_n = 48;
|
||||
+ if(p >= result && p_n >= 48 && (p - result < 20)) {
|
||||
+ if (p_n == 48 ) p_n++;
|
||||
+ if (p > result) p--;
|
||||
+ p_n--;
|
||||
+ *(p++) = p_n;
|
||||
+ *p = 0;
|
||||
+ goto drawit;
|
||||
+ } else
|
||||
+ break;
|
||||
default:
|
||||
if(flags == INPUT_LOOP_RET)
|
||||
goto out;
|
||||
- else if(flags == INPUT_LOOP_NUMERIC && isdigit(event.which) && (p - result < 20)) {
|
||||
- *(p++) = event.which;
|
||||
+ else if(flags == INPUT_LOOP_NUMERIC && (p - result < 20)) {
|
||||
+ if(isdigit(event.which)) *(p++) = event.which;
|
||||
+ else if (event.which == 275) *(p++) = 48;
|
||||
*p = 0;
|
||||
}
|
||||
drawit:
|
||||
@@ -865,7 +907,7 @@ int main(int argc, char **argv) {
|
||||
{
|
||||
char buf[32];
|
||||
buf[0] = 0;
|
||||
- input_loop("enter page no", buf, INPUT_LOOP_NUMERIC);
|
||||
+ input_loop("Enter page No.: (use number/arrow keys)", buf, INPUT_LOOP_NUMERIC);
|
||||
if(*buf) need_redraw = set_page(atoi(buf));
|
||||
else need_redraw = 1;
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
253
package/sdlbook/0002-add-custom-Input-mapping-with-header.patch
Normal file
253
package/sdlbook/0002-add-custom-Input-mapping-with-header.patch
Normal file
@@ -0,0 +1,253 @@
|
||||
From 4126f952f021b7e8fca7880e072092fcb3812f29 Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Sat, 23 Mar 2024 16:30:20 +0100
|
||||
Subject: [PATCH 2/7] add custom Input mapping with header
|
||||
|
||||
---
|
||||
inputmap.h | 40 ++++++++++++++++++++++++++++++
|
||||
sdlbook.c | 73 +++++++++++++++++++++++++++---------------------------
|
||||
2 files changed, 77 insertions(+), 36 deletions(-)
|
||||
create mode 100644 inputmap.h
|
||||
|
||||
diff --git a/inputmap.h b/inputmap.h
|
||||
new file mode 100644
|
||||
index 0000000..0210a24
|
||||
--- /dev/null
|
||||
+++ b/inputmap.h
|
||||
@@ -0,0 +1,40 @@
|
||||
+#ifndef INPUTMAP_H
|
||||
+#define INPUTMAP_H
|
||||
+
|
||||
+#define INPUT_UP SDLK_UP
|
||||
+#define INPUT_DOWN SDLK_DOWN
|
||||
+#define INPUT_LEFT SDLK_LEFT
|
||||
+#define INPUT_RIGHT SDLK_RIGHT
|
||||
+#define INPUT_LMOD SDLK_LCTRL
|
||||
+#define INPUT_RMOD SDLK_RCTRL
|
||||
+#define INPUT_PGDOWN SDLK_PAGEDOWN
|
||||
+#define INPUT_PGUP SDLK_PAGEUP
|
||||
+#define INPUT_ZOOMIN SDLK_KP_PLUS
|
||||
+#define INPUT_ZOOMOUT SDLK_KP_MINUS
|
||||
+#define INPUT_PAGEN SDLK_g
|
||||
+#define INPUT_CLEAR SDLK_c
|
||||
+#define INPUT_CANCEL SDLK_BACKSPACE
|
||||
+#define INPUT_CONFIRM SDLK_RETURN
|
||||
+#define INPUT_EXIT SDLK_ESCAPE
|
||||
+#define INPUT_QUIT SDLK_q
|
||||
+#define INPUT_HELP SDLK_F1
|
||||
+
|
||||
+#define STR_UP "UP"
|
||||
+#define STR_DOWN "DOWN"
|
||||
+#define STR_LEFT "LEFT"
|
||||
+#define STR_RIGHT "RIGHT"
|
||||
+#define STR_LMOD "LCTRL"
|
||||
+#define STR_RMOD "RCTRL"
|
||||
+#define STR_PGDOWN "PAGE_DOWN"
|
||||
+#define STR_PGUP "PAGE_UP"
|
||||
+#define STR_ZOOMIN "NUM+"
|
||||
+#define STR_ZOOMOUT "NUM-"
|
||||
+#define STR_PAGEN "G"
|
||||
+#define STR_CLEAR "C"
|
||||
+#define STR_CANCEL "BACKSPACE"
|
||||
+#define STR_CONFIRM "RETURN"
|
||||
+#define STR_EXIT "ESC"
|
||||
+#define STR_QUIT "Q"
|
||||
+#define STR_HELP "F1"
|
||||
+
|
||||
+#endif
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index d608aba..79b77f3 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <mupdf/fitz.h>
|
||||
#include "ezsdl.h"
|
||||
#include "topaz.h"
|
||||
+#include "inputmap.h"
|
||||
|
||||
#pragma RcB2 LINK "-ldjvulibre" "-lSSL" "-lmupdf"
|
||||
|
||||
@@ -550,13 +551,13 @@ static int change_scroll_h(int incr) {
|
||||
|
||||
#define HELP_TEXT \
|
||||
"HELP SCREEN - HIT ANY KEY TO EXIT\n" \
|
||||
- "UP, DOWN ARROW - SCROLL 32 PIX\n" \
|
||||
- "CTRL + UP, DOWN ARROW - SCROLL 96 PIX\n" \
|
||||
- "PAGE_UP/DOWN - SCROLL ONE PAGE\n" \
|
||||
- "KEYPAD +/- OR CTRL-WHEEL - ZOOM\n" \
|
||||
- "G - ENTER PAGE NUMBER\n" \
|
||||
- "Q/ESC - QUIT\n" \
|
||||
- "F1 - SHOW HELP SCREEN\n"
|
||||
+ STR_UP ", " STR_DOWN " - SCROLL 32 PIX\n" \
|
||||
+ STR_LMOD "/" STR_RMOD " + " STR_UP "/" STR_DOWN " - SCROLL 96 PIX\n" \
|
||||
+ STR_PGUP "/" STR_PGDOWN " - SCROLL ONE PAGE\n" \
|
||||
+ STR_ZOOMIN "/" STR_ZOOMOUT " OR " STR_LMOD "/" STR_RMOD " + WHEEL - ZOOM\n" \
|
||||
+ STR_PAGEN " - ENTER PAGE NUMBER\n" \
|
||||
+ STR_QUIT "/" STR_EXIT " - QUIT\n" \
|
||||
+ STR_HELP " - SHOW HELP SCREEN\n"
|
||||
|
||||
static int get_return_count(const char* text) {
|
||||
int count = 0;
|
||||
@@ -598,14 +599,14 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
case EV_QUIT:
|
||||
case EV_KEYUP:
|
||||
switch(event.which) {
|
||||
- case SDLK_BACKSPACE: case SDLK_LEFT:
|
||||
+ case INPUT_CANCEL: case INPUT_LEFT:
|
||||
if(flags == INPUT_LOOP_RET)
|
||||
goto out;
|
||||
if(p > result) p--;
|
||||
p_n = *(p - 1);
|
||||
*p = 0;
|
||||
goto drawit;
|
||||
- case SDLK_RIGHT:
|
||||
+ case INPUT_RIGHT:
|
||||
if(flags == INPUT_LOOP_RET)
|
||||
goto out;
|
||||
if(p - result < 20) {
|
||||
@@ -615,12 +616,12 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
goto drawit;
|
||||
} else
|
||||
break;
|
||||
- case SDLK_RETURN: case SDLK_ESCAPE: case SDLK_g:
|
||||
+ case INPUT_CONFIRM: case INPUT_EXIT: case INPUT_PAGEN:
|
||||
out:;
|
||||
*p = 0;
|
||||
ezsdl_clear();
|
||||
return;
|
||||
- case SDLK_UP:
|
||||
+ case INPUT_UP:
|
||||
if(flags == INPUT_LOOP_RET)
|
||||
goto out;
|
||||
p_n = *(p - 1);
|
||||
@@ -633,7 +634,7 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
goto drawit;
|
||||
} else
|
||||
break;
|
||||
- case SDLK_DOWN:
|
||||
+ case INPUT_DOWN:
|
||||
if(flags == INPUT_LOOP_RET)
|
||||
goto out;
|
||||
p_n = *(p - 1);
|
||||
@@ -821,51 +822,51 @@ int main(int argc, char **argv) {
|
||||
goto dun_goofed;
|
||||
case EV_KEYDOWN:
|
||||
switch(event.which) {
|
||||
- case SDLK_LCTRL:
|
||||
+ case INPUT_LMOD:
|
||||
left_ctrl_pressed = 1;
|
||||
break;
|
||||
- case SDLK_RCTRL:
|
||||
+ case INPUT_RMOD:
|
||||
right_ctrl_pressed = 1;
|
||||
break;
|
||||
- case SDLK_q:
|
||||
+ case INPUT_QUIT:
|
||||
goto dun_goofed;
|
||||
- case SDLK_KP_PLUS:
|
||||
+ case INPUT_ZOOMIN:
|
||||
need_redraw = change_scale(+10);
|
||||
break;
|
||||
- case SDLK_KP_MINUS:
|
||||
+ case INPUT_ZOOMOUT:
|
||||
need_redraw = change_scale(-10);
|
||||
break;
|
||||
- case SDLK_PAGEDOWN:
|
||||
+ case INPUT_PGDOWN:
|
||||
scroll_dist_v += page_dims.h;
|
||||
break;
|
||||
- case SDLK_PAGEUP:
|
||||
+ case INPUT_PGUP:
|
||||
scroll_dist_v -= page_dims.h;
|
||||
break;
|
||||
- case SDLK_UP:
|
||||
+ case INPUT_UP:
|
||||
if((event.mod & KMOD_LCTRL) || (event.mod & KMOD_RCTRL))
|
||||
scroll_dist_v += -96;
|
||||
else
|
||||
scroll_dist_v += -32;
|
||||
break;
|
||||
- case SDLK_DOWN:
|
||||
+ case INPUT_DOWN:
|
||||
if((event.mod & KMOD_LCTRL) || (event.mod & KMOD_RCTRL))
|
||||
scroll_dist_v += +96;
|
||||
else
|
||||
scroll_dist_v += +32;
|
||||
break;
|
||||
- case SDLK_LEFT:
|
||||
+ case INPUT_LEFT:
|
||||
if((event.mod & KMOD_LCTRL) || (event.mod & KMOD_RCTRL))
|
||||
need_redraw = change_scroll_h(-96);
|
||||
else
|
||||
need_redraw = change_scroll_h(-32);
|
||||
break;
|
||||
- case SDLK_RIGHT:
|
||||
+ case INPUT_RIGHT:
|
||||
if((event.mod & KMOD_LCTRL) || (event.mod & KMOD_RCTRL))
|
||||
need_redraw = change_scroll_h(+96);
|
||||
else
|
||||
need_redraw = change_scroll_h(+32);
|
||||
break;
|
||||
- case SDLK_RETURN:
|
||||
+ case INPUT_CONFIRM:
|
||||
if((event.mod & KMOD_LALT) ||
|
||||
(event.mod & KMOD_RALT)) {
|
||||
ezsdl_toggle_fullscreen();
|
||||
@@ -880,21 +881,21 @@ int main(int argc, char **argv) {
|
||||
break;
|
||||
case EV_KEYUP:
|
||||
switch(event.which) {
|
||||
- case SDLK_UP:
|
||||
- case SDLK_DOWN:
|
||||
- case SDLK_LEFT:
|
||||
- case SDLK_RIGHT:
|
||||
- case SDLK_PAGEUP:
|
||||
- case SDLK_PAGEDOWN:
|
||||
+ case INPUT_UP:
|
||||
+ case INPUT_DOWN:
|
||||
+ case INPUT_LEFT:
|
||||
+ case INPUT_RIGHT:
|
||||
+ case INPUT_PGUP:
|
||||
+ case INPUT_PGDOWN:
|
||||
need_redraw = 1;
|
||||
break;
|
||||
- case SDLK_LCTRL:
|
||||
+ case INPUT_LMOD:
|
||||
left_ctrl_pressed = 0;
|
||||
break;
|
||||
- case SDLK_RCTRL:
|
||||
+ case INPUT_RMOD:
|
||||
right_ctrl_pressed = 0;
|
||||
break;
|
||||
- case SDLK_F1:
|
||||
+ case INPUT_HELP:
|
||||
{
|
||||
char buf[32];
|
||||
buf[0] = 0;
|
||||
@@ -903,7 +904,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
break;
|
||||
|
||||
- case SDLK_g:
|
||||
+ case INPUT_PAGEN:
|
||||
{
|
||||
char buf[32];
|
||||
buf[0] = 0;
|
||||
@@ -912,12 +913,12 @@ int main(int argc, char **argv) {
|
||||
else need_redraw = 1;
|
||||
}
|
||||
break;
|
||||
- case SDLK_c:
|
||||
+ case INPUT_CLEAR:
|
||||
ezsdl_clear();
|
||||
ezsdl_refresh();
|
||||
need_redraw = 1;
|
||||
break;
|
||||
- case SDLK_ESCAPE:
|
||||
+ case INPUT_EXIT:
|
||||
goto dun_goofed;
|
||||
default:
|
||||
break;
|
||||
--
|
||||
2.34.1
|
||||
|
147
package/sdlbook/0003-add-MIYOO-changes.patch
Normal file
147
package/sdlbook/0003-add-MIYOO-changes.patch
Normal file
@@ -0,0 +1,147 @@
|
||||
From 1decdb74c622f2c00e9b37bf4165f2a6e5bcdec3 Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Sun, 24 Mar 2024 15:12:08 +0100
|
||||
Subject: [PATCH 3/7] add MIYOO changes
|
||||
|
||||
make CC=${CROSS_COMPILE}gcc CFLAGS="-DMIYOO -Ofast"
|
||||
---
|
||||
inputmap.h | 38 ++++++++++++++++++++++++++++++++++++++
|
||||
sdlbook.c | 34 ++++++++++++++++++++++------------
|
||||
2 files changed, 60 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/inputmap.h b/inputmap.h
|
||||
index 0210a24..a34978f 100644
|
||||
--- a/inputmap.h
|
||||
+++ b/inputmap.h
|
||||
@@ -1,6 +1,43 @@
|
||||
#ifndef INPUTMAP_H
|
||||
#define INPUTMAP_H
|
||||
|
||||
+#ifdef MIYOO
|
||||
+#define INPUT_UP SDLK_UP
|
||||
+#define INPUT_DOWN SDLK_DOWN
|
||||
+#define INPUT_LEFT SDLK_LEFT
|
||||
+#define INPUT_RIGHT SDLK_RIGHT
|
||||
+#define INPUT_LMOD SDLK_PAGEUP
|
||||
+#define INPUT_RMOD SDLK_PAGEDOWN
|
||||
+#define INPUT_PGDOWN SDLK_BACKSPACE
|
||||
+#define INPUT_PGUP SDLK_TAB
|
||||
+#define INPUT_ZOOMIN SDLK_LSHIFT
|
||||
+#define INPUT_ZOOMOUT SDLK_SPACE
|
||||
+#define INPUT_PAGEN SDLK_ESCAPE
|
||||
+#define INPUT_CLEAR SDLK_LCTRL
|
||||
+#define INPUT_CANCEL SDLK_LCTRL
|
||||
+#define INPUT_CONFIRM SDLK_LALT
|
||||
+#define INPUT_EXIT SDLK_RCTRL
|
||||
+#define INPUT_QUIT SDLK_q
|
||||
+#define INPUT_HELP SDLK_RETURN
|
||||
+
|
||||
+#define STR_UP "UP"
|
||||
+#define STR_DOWN "DOWN"
|
||||
+#define STR_LEFT "LEFT"
|
||||
+#define STR_RIGHT "RIGHT"
|
||||
+#define STR_LMOD "L2"
|
||||
+#define STR_RMOD "R2"
|
||||
+#define STR_PGDOWN "R1"
|
||||
+#define STR_PGUP "L1"
|
||||
+#define STR_ZOOMIN "X"
|
||||
+#define STR_ZOOMOUT "Y"
|
||||
+#define STR_PAGEN "SELECT"
|
||||
+#define STR_CLEAR "?"
|
||||
+#define STR_CANCEL "B"
|
||||
+#define STR_CONFIRM "A"
|
||||
+#define STR_EXIT "RESET"
|
||||
+#define STR_QUIT ""
|
||||
+#define STR_HELP "START"
|
||||
+#else
|
||||
#define INPUT_UP SDLK_UP
|
||||
#define INPUT_DOWN SDLK_DOWN
|
||||
#define INPUT_LEFT SDLK_LEFT
|
||||
@@ -36,5 +73,6 @@
|
||||
#define STR_EXIT "ESC"
|
||||
#define STR_QUIT "Q"
|
||||
#define STR_HELP "F1"
|
||||
+#endif
|
||||
|
||||
#endif
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index 79b77f3..584f02d 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -117,9 +117,15 @@ static void read_write_config(int doread) {
|
||||
cfg_close(config);
|
||||
}
|
||||
if(doread) {
|
||||
+#ifdef MIYOO
|
||||
+ if(!config_data.w) config_data.w = 320;
|
||||
+ if(!config_data.h) config_data.h = 240;
|
||||
+ if(!config_data.scale) config_data.scale = 80;
|
||||
+#else
|
||||
if(!config_data.w) config_data.w = 640;
|
||||
if(!config_data.h) config_data.h = 480;
|
||||
if(!config_data.scale) config_data.scale = 100;
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,14 +556,14 @@ static int change_scroll_h(int incr) {
|
||||
}
|
||||
|
||||
#define HELP_TEXT \
|
||||
- "HELP SCREEN - HIT ANY KEY TO EXIT\n" \
|
||||
- STR_UP ", " STR_DOWN " - SCROLL 32 PIX\n" \
|
||||
- STR_LMOD "/" STR_RMOD " + " STR_UP "/" STR_DOWN " - SCROLL 96 PIX\n" \
|
||||
- STR_PGUP "/" STR_PGDOWN " - SCROLL ONE PAGE\n" \
|
||||
- STR_ZOOMIN "/" STR_ZOOMOUT " OR " STR_LMOD "/" STR_RMOD " + WHEEL - ZOOM\n" \
|
||||
- STR_PAGEN " - ENTER PAGE NUMBER\n" \
|
||||
- STR_QUIT "/" STR_EXIT " - QUIT\n" \
|
||||
- STR_HELP " - SHOW HELP SCREEN\n"
|
||||
+ " HELP SCREEN\n (press any key to exit)\n" \
|
||||
+ STR_UP ", " STR_DOWN " - scroll 32px\n" \
|
||||
+ STR_LMOD "/" STR_RMOD " + " STR_UP "/" STR_DOWN " - scroll 96px\n" \
|
||||
+ STR_PGUP "/" STR_PGDOWN " - scroll one page -/+\n" \
|
||||
+ STR_ZOOMIN "/" STR_ZOOMOUT " - zoom in/out\n" \
|
||||
+ STR_PAGEN " - jump to page number\n" \
|
||||
+ STR_QUIT "/" STR_EXIT " - quit\n" \
|
||||
+ STR_HELP " - show this message\n"
|
||||
|
||||
static int get_return_count(const char* text) {
|
||||
int count = 0;
|
||||
@@ -584,9 +590,9 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
{
|
||||
int ret_count = get_return_count(title);
|
||||
if(!ret_count) ret_count = 1;
|
||||
- int desired_height = (ret_count+2) * 10 * 2;
|
||||
+ int desired_height = (ret_count) * 10 * 2 + 10;
|
||||
ezsdl_fill_rect(0,0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height()), RGB(0xff,0x00,0x00), 1);
|
||||
- draw_font_lines(title, &ss_font, 8, 8, 2);
|
||||
+ draw_font_lines(title, &ss_font, 8, 8, 1);
|
||||
ezsdl_update_region(0, 0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height()));
|
||||
char* p = result;
|
||||
*p = 0;
|
||||
@@ -657,8 +663,8 @@ static void input_loop(const char* title, char *result, enum input_flags flags)
|
||||
*p = 0;
|
||||
}
|
||||
drawit:
|
||||
- ezsdl_fill_rect(8, desired_height - 10*2, ezsdl_get_width() -8, MIN(desired_height, ezsdl_get_height()), RGB(0xff,0x00,0x00), 1);
|
||||
- draw_font(result, &ss_font, 8, desired_height - 10*2, 2);
|
||||
+ ezsdl_fill_rect(8, desired_height - 11*2, ezsdl_get_width() -8, MIN(desired_height, ezsdl_get_height()), RGB(0xff,0x00,0x00), 1);
|
||||
+ draw_font(result, &ss_font, 8, desired_height - 11*2, 2);
|
||||
ezsdl_update_region(0, 0, ezsdl_get_width(), MIN(desired_height, ezsdl_get_height()));
|
||||
break;
|
||||
}
|
||||
@@ -770,7 +776,11 @@ int main(int argc, char **argv) {
|
||||
|
||||
init_gfx();
|
||||
|
||||
+#ifdef MIYOO
|
||||
+ SDL_ShowCursor(0);
|
||||
+#else
|
||||
SDL_ShowCursor(1);
|
||||
+#endif
|
||||
#ifndef USE_SDL2
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
#endif
|
||||
--
|
||||
2.34.1
|
||||
|
@@ -0,0 +1,37 @@
|
||||
From b433bbaf2c8f60938f64b9f1584a446102118ba9 Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Fri, 26 Apr 2024 20:55:02 +0200
|
||||
Subject: [PATCH 4/7] show curr and total page count in "Enter page" view
|
||||
|
||||
reduce page_count display by 1, because curr_page init value is 0
|
||||
---
|
||||
sdlbook.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index 584f02d..f11cc30 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -61,7 +61,7 @@ static unsigned *image_data;
|
||||
static void update_title(void) {
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof buf, "SDLBook [%d/%d] (%d%%) %s",
|
||||
- curr_page, page_count, config_data.scale, filename);
|
||||
+ curr_page, page_count-1, config_data.scale, filename);
|
||||
ezsdl_set_title(buf);
|
||||
}
|
||||
|
||||
@@ -918,7 +918,9 @@ int main(int argc, char **argv) {
|
||||
{
|
||||
char buf[32];
|
||||
buf[0] = 0;
|
||||
- input_loop("Enter page No.: (use number/arrow keys)", buf, INPUT_LOOP_NUMERIC);
|
||||
+ char page_number[100];
|
||||
+ sprintf(page_number, "Enter page %i/%i: (use number/arrows)", curr_page, page_count-1);
|
||||
+ input_loop(page_number, buf, INPUT_LOOP_NUMERIC);
|
||||
if(*buf) need_redraw = set_page(atoi(buf));
|
||||
else need_redraw = 1;
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
@@ -0,0 +1,30 @@
|
||||
From fa6e1a82caa29f95761b7c4a902cc56f3d4bcd76 Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Sat, 27 Apr 2024 17:12:45 +0200
|
||||
Subject: [PATCH 5/7] don't change_scroll_v after last page
|
||||
|
||||
Update sdlbook.c
|
||||
|
||||
Update sdlbook.c
|
||||
|
||||
Update sdlbook.c
|
||||
---
|
||||
sdlbook.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index f11cc30..535a194 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -537,6 +537,8 @@ static int change_scroll_v(int incr) {
|
||||
need_redraw = change_page(-1);
|
||||
scroll_line_v = MAX(scroll_line_v + incr + (int)page_dims.h, 0);
|
||||
}
|
||||
+ } else if(scroll_line_v + incr > page_dims.h/2 && curr_page >= page_count-1) {
|
||||
+ scroll_line_v = (int)page_dims.h/2;
|
||||
} else if(scroll_line_v + incr > page_dims.h) {
|
||||
scroll_line_v = scroll_line_v + incr - (int)page_dims.h;
|
||||
need_redraw = change_page(+1);
|
||||
--
|
||||
2.34.1
|
||||
|
@@ -0,0 +1,155 @@
|
||||
From a999470df6328f26b59f88e18396a3e6c8d3466d Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Fri, 26 Apr 2024 21:19:20 +0200
|
||||
Subject: [PATCH 6/7] define RENDER_ONEPAGE to omit following page buffering
|
||||
|
||||
- increases image swapping time with minimal RAM
|
||||
- use get_page_bottom() to differentiate page size height
|
||||
- change to start page with PAGEDOWN/UP keys
|
||||
---
|
||||
sdlbook.c | 64 +++++++++++++++++++++++++++++++++++++++++++++----------
|
||||
1 file changed, 53 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index 535a194..5d939e8 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -151,6 +151,14 @@ static void init_gfx() {
|
||||
if(!spritesheet_init(&ss_font, bmp_font, FONT_W, FONT_H)) dprintf(2, "oops\n");
|
||||
}
|
||||
|
||||
+static int get_page_bottom() {
|
||||
+#ifndef RENDER_ONEPAGE
|
||||
+ return page_dims.h;
|
||||
+#else
|
||||
+ return page_dims.h/2;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
static int get_font_width(char letter) {
|
||||
return ss_font.sprite_w;
|
||||
}
|
||||
@@ -184,7 +192,8 @@ static void draw() {
|
||||
unsigned *ptr;
|
||||
unsigned pitch;
|
||||
int xoff = MAX((int)(ezsdl_get_width() - page_dims.w)/2, 0);
|
||||
- int xmax = page_dims.w, ymax = page_dims.h*2;
|
||||
+ int xmax = page_dims.w;
|
||||
+ int ymax = get_page_bottom()*2;
|
||||
if(scroll_line_v > ymax) return;
|
||||
ymax = MIN(ezsdl_get_height(), ymax-scroll_line_v),
|
||||
xmax = MIN(ezsdl_get_width(), xmax-scroll_line_h);
|
||||
@@ -221,7 +230,7 @@ static void draw_borders() {
|
||||
static void draw_bottom() {
|
||||
int x, y, yline;
|
||||
int xmax, ymax, ymin;
|
||||
- ymin = page_dims.h*2-scroll_line_v;
|
||||
+ ymin = get_page_bottom()*2-scroll_line_v;
|
||||
if(ymin < 0) return;
|
||||
void *pixels;
|
||||
unsigned *ptr;
|
||||
@@ -435,7 +444,10 @@ static void* prep_page(int pageno, ddjvu_rect_t *res_rect, ddjvu_rect_t *desired
|
||||
}
|
||||
|
||||
static void* prep_pages(int *need_redraw) {
|
||||
- ddjvu_rect_t p1rect, p2rect;
|
||||
+ ddjvu_rect_t p1rect;
|
||||
+#ifndef RENDER_ONEPAGE
|
||||
+ ddjvu_rect_t p2rect;
|
||||
+#endif
|
||||
static int last_page = -1, last_scale = -1;
|
||||
if(curr_page == last_page && last_scale == config_data.scale)
|
||||
return image_data;
|
||||
@@ -443,6 +455,7 @@ static void* prep_pages(int *need_redraw) {
|
||||
last_scale = config_data.scale;
|
||||
if(need_redraw) *need_redraw = 1;
|
||||
char *p1data = prep_page(curr_page, &p1rect, 0);
|
||||
+#ifndef RENDER_ONEPAGE
|
||||
char *p2data = prep_page(curr_page+1, &p2rect, 0);
|
||||
if(!p2data) {
|
||||
/* probably last page hit */
|
||||
@@ -457,15 +470,22 @@ static void* prep_pages(int *need_redraw) {
|
||||
}
|
||||
if(!(p1data && p2data)) return NULL;
|
||||
assert(p1rect.w == p2rect.w && p1rect.h == p2rect.h);
|
||||
+ int stored_images = 2;
|
||||
+#else
|
||||
+ if(!(p1data)) return NULL;
|
||||
+ int stored_images = 1;
|
||||
+#endif
|
||||
|
||||
size_t one_pic = p1rect.w*p1rect.h;
|
||||
- unsigned* imgbuf = malloc(4 * one_pic * 2);
|
||||
+ unsigned* imgbuf = malloc(4 * one_pic * stored_images);
|
||||
|
||||
convert_rgb24_to_rgba(p1data, p1rect.w, p1rect.h, imgbuf);
|
||||
- convert_rgb24_to_rgba(p2data, p2rect.w, p2rect.h, imgbuf+one_pic);
|
||||
page_dims = p1rect;
|
||||
free(p1data);
|
||||
+#ifndef RENDER_ONEPAGE
|
||||
+ convert_rgb24_to_rgba(p2data, p2rect.w, p2rect.h, imgbuf+one_pic);
|
||||
free(p2data);
|
||||
+#endif
|
||||
return imgbuf;
|
||||
}
|
||||
|
||||
@@ -531,17 +551,39 @@ static int change_scale(int incr) {
|
||||
|
||||
static int change_scroll_v(int incr) {
|
||||
int need_redraw = 1;
|
||||
+#ifndef RENDER_ONEPAGE
|
||||
+ int page_bottom_prv = scroll_line_v + incr + get_page_bottom();
|
||||
+#else
|
||||
+ int page_bottom_prv = scroll_line_v + get_page_bottom()*2 - ezsdl_get_height();
|
||||
+
|
||||
+ if(ezsdl_get_height() + incr >= page_dims.h || abs(incr) == get_page_bottom()) {
|
||||
+ scroll_line_v = 0;
|
||||
+ change_page(incr > 0 ? +1 : -1);
|
||||
+ return need_redraw;
|
||||
+ }
|
||||
+#endif
|
||||
if(scroll_line_v + incr < 0) {
|
||||
if(curr_page == 0) scroll_line_v = 0;
|
||||
else {
|
||||
need_redraw = change_page(-1);
|
||||
- scroll_line_v = MAX(scroll_line_v + incr + (int)page_dims.h, 0);
|
||||
+ scroll_line_v = MAX(page_bottom_prv, 0);
|
||||
}
|
||||
- } else if(scroll_line_v + incr > page_dims.h/2 && curr_page >= page_count-1) {
|
||||
+#ifndef RENDER_ONEPAGE
|
||||
+ } else if(scroll_line_v + incr > (int)page_dims.h/2 && curr_page >= page_count-1) {
|
||||
scroll_line_v = (int)page_dims.h/2;
|
||||
- } else if(scroll_line_v + incr > page_dims.h) {
|
||||
- scroll_line_v = scroll_line_v + incr - (int)page_dims.h;
|
||||
+ } else if(scroll_line_v + incr > get_page_bottom()) {
|
||||
+ scroll_line_v = scroll_line_v + incr - get_page_bottom();
|
||||
need_redraw = change_page(+1);
|
||||
+#else
|
||||
+ } else if(scroll_line_v + incr > page_dims.h - ezsdl_get_height() && curr_page >= page_count-1) {
|
||||
+ scroll_line_v = MAX((int)page_dims.h - ezsdl_get_height(),0);
|
||||
+ } else if(scroll_line_v + incr > get_page_bottom() && ezsdl_get_height() > get_page_bottom()) {
|
||||
+ scroll_line_v = scroll_line_v + incr - get_page_bottom();
|
||||
+ need_redraw = change_page(+1);
|
||||
+ } else if(scroll_line_v + incr > page_dims.h - ezsdl_get_height() && incr > 0) {
|
||||
+ scroll_line_v = scroll_line_v + incr + ezsdl_get_height() - (int)page_dims.h;
|
||||
+ need_redraw = change_page(+1);
|
||||
+#endif
|
||||
} else
|
||||
scroll_line_v += incr;
|
||||
return need_redraw;
|
||||
@@ -849,10 +891,10 @@ int main(int argc, char **argv) {
|
||||
need_redraw = change_scale(-10);
|
||||
break;
|
||||
case INPUT_PGDOWN:
|
||||
- scroll_dist_v += page_dims.h;
|
||||
+ scroll_dist_v += get_page_bottom();
|
||||
break;
|
||||
case INPUT_PGUP:
|
||||
- scroll_dist_v -= page_dims.h;
|
||||
+ scroll_dist_v -= get_page_bottom();
|
||||
break;
|
||||
case INPUT_UP:
|
||||
if((event.mod & KMOD_LCTRL) || (event.mod & KMOD_RCTRL))
|
||||
--
|
||||
2.34.1
|
||||
|
@@ -0,0 +1,27 @@
|
||||
From e6260642c7a7228ab928a22608cb9914b2748402 Mon Sep 17 00:00:00 2001
|
||||
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
|
||||
Date: Tue, 30 Apr 2024 20:41:24 +0200
|
||||
Subject: [PATCH 7/7] supress min scale by max renderer pages' dimension
|
||||
|
||||
---
|
||||
sdlbook.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/sdlbook.c b/sdlbook.c
|
||||
index 5d939e8..7829239 100644
|
||||
--- a/sdlbook.c
|
||||
+++ b/sdlbook.c
|
||||
@@ -537,7 +537,9 @@ static int change_page(int incr) {
|
||||
|
||||
static int change_scale(int incr) {
|
||||
int need_redraw;
|
||||
- if (config_data.scale + incr <= 999 && config_data.scale + incr > 0)
|
||||
+ if (ezsdl_get_height() > get_page_bottom()*2)
|
||||
+ config_data.scale += incr > 0 ? incr : 0;
|
||||
+ else if (config_data.scale + incr <= 999 && config_data.scale + incr > 0)
|
||||
config_data.scale += incr;
|
||||
else return 0;
|
||||
swap_image(prep_pages(&need_redraw));
|
||||
--
|
||||
2.34.1
|
||||
|
5
package/sdlbook/Config.in
Normal file
5
package/sdlbook/Config.in
Normal file
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_SDLBOOK
|
||||
bool "sdlbook"
|
||||
help
|
||||
Simple djvu/pdf/epub ebook viewer based on djvulibre,
|
||||
libmupdf and SDL 1.2
|
24
package/sdlbook/sdlbook.mk
Normal file
24
package/sdlbook/sdlbook.mk
Normal file
@@ -0,0 +1,24 @@
|
||||
################################################################################
|
||||
#
|
||||
# SDLbook
|
||||
#
|
||||
################################################################################
|
||||
|
||||
SDLBOOK_VERSION = d0c4df8edf8df4f96312641ebf4d25d5b0b042fe
|
||||
SDLBOOK_SITE_METHOD = git
|
||||
SDLBOOK_SITE = https://github.com/rofl0r/SDLBook
|
||||
SDLBOOK_DEPENDENCIES = \
|
||||
sdl \
|
||||
djvu \
|
||||
mupdf \
|
||||
tiff
|
||||
|
||||
define SDLBOOK_BUILD_CMDS
|
||||
$(MAKE) CC="$(TARGET_CC)" CFLAGS="-DMIYOO -Ofast -DRENDER_ONEPAGE" -C $(@D)
|
||||
endef
|
||||
|
||||
define SDLBOOK_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/sdlbook $(TARGET_DIR)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
Reference in New Issue
Block a user