Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > PocketBook > PocketBook Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 11-05-2020, 04:37 AM   #1
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 50
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
How to use OpenConfigEditor on new firmware?

I'm currently developing a port of the SGT puzzle collection (see the other thread here in the Developer's Corner).

I found OpenConfigEditor in inkview.h, and this looks like it would make it very easy to implement individual changing of game parameters. I also found examples in various projects at GitHub.

Unfortunately I just cannot get it to work. I am basically using code like this in a test application:

Code:
char *difficulties[] = { "Easy", "Normal", "Tricky", "Hard", NULL };
iconfig *myconfig = NULL;
iconfigedit myconfigedit[] = {
{ CFG_CHOICE, NULL, "Difficulty", "Game difficulty", "param.diff", "Easy", difficulties, NULL, NULL},
{ 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};

void config_ok() {}
void config_change_handler(char* name) {}

myconfig = OpenConfig(STATEPATH "/configtest.cfg", myconfigedit);
OpenConfigEditor("Game parameters", myconfig, myconfigedit, config_ok, config_change_handler);
Code compiles without warnings, but the app crashes (I assume segfault) at OpenConfigEditor.

Platform Touch HD 3, newest firmware (6.1.900)

I know that the format of iconfigedit changed, above code should be according to the new format.

Furthermore, for testing what is going wrong I added a Message(...) directly after OpenConfigEditor(...), then the behaviour got even stranger. Then it indeed showed a screen containing one entry "Difficulty Easy", below was the string "Game difficulty" in a weird huge font, and the reader froze. No reaction anymore, needed a hard reset.

OpenConfigEditor is definitely the culprit, when I comment out this line the app continues, so OpenConfig executes successfully.

I also tried various combinations of setting some of the callback functions to NULL, also played around with entries in myconfigedit, all in vain.

Any hint what I am doing wrong?
GerReader is offline   Reply With Quote
Old 11-05-2020, 12:23 PM   #2
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,989
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
I think you have to have a valid icon for each menu item (the second member of the iconfigedit struct). Look around for images.c files that contain ibitmap structures of icons to use in your project. The size of the icon determines the physical layout of the displayed configuration editor.
rkomar is offline   Reply With Quote
Advert
Old 11-05-2020, 04:14 PM   #3
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 50
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
Quote:
Originally Posted by rkomar View Post
I think you have to have a valid icon for each menu item (the second member of the iconfigedit struct). Look around for images.c files that contain ibitmap structures of icons to use in your project. The size of the icon determines the physical layout of the displayed configuration editor.
Thanks for the hint, but unfortunately I had no success trying this. The app still crashes when trying to open the ConfigEditor.

I changed myconfigedit to this:

Code:
iconfigedit myconfigedit[] = {
{ CFG_CHOICE, &icon_menu, "Difficulty", "Game difficulty", "difficulty", "Easy", difficulties, NULL, NULL},
{ 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
icon_menu is a 96x96 bitmap which I already have included for a menu icon in my test app, so this bitmap is definitely available, I include my bitmaps like this in a .h file:

Code:
extern ibitmap icon_home, icon_home_tap, icon_menu, icon_menu_tap, menu_settings;
and I compile the bitmaps with pbres into a separate icons.c file which I compile and link to the app.

Furthermore, I found a relatively recent project at GitHub, where an iconfigedit array structure is also built without an icon for the entries:

https://github.com/Programmist11180/...c/settings.cpp

so I don't think that the missing icon is the problem here
GerReader is offline   Reply With Quote
Old 11-05-2020, 11:08 PM   #4
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,989
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
I have this working in my own code. The only obvious difference (besides the icon) is that I provide the iv_confighandler hproc function to OpenConfigEditor() but not the iv_itemchangehandler cproc function. I also use CONFIGPATH instead of STATEPATH in the call to OpenConfig, but I'm not sure if that would fix the crash.
rkomar is offline   Reply With Quote
Old 11-06-2020, 04:45 AM   #5
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 50
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
Quote:
Originally Posted by rkomar View Post
The only obvious difference (besides the icon) is that I provide the iv_confighandler hproc function to OpenConfigEditor() but not the iv_itemchangehandler cproc function. I also use CONFIGPATH instead of STATEPATH in the call to OpenConfig, but I'm not sure if that would fix the crash.
I see. Unfortunately these are also things that I tried, replaced the callback functions in every possible iteration with NULL, and also tried CONFIGPATH, but nothing works.

At this point I am considering that something else might be broken, as it looks like the code itself is correct. I don't think that the problem is in the rest of the app code. I try to open the ConfigEditor from a MenuHandler callback, when I replace OpenConfigEditor there with a simple Message(), all works flawlessly.

May I ask what exact SDK you are using, and on what reader with what firmware version?

I am using https://github.com/blchinezu/pocketbook-sdk/ , which seems to be a little bit old (last updated some years ago), is there a newer SDK? At this point I'm suspecting that I'm compiling with an outdated SDK.

My platform is a Touch HD 3, with the newest patched firmware 6.1.900. I don't think that something was changed in the latest system updates.

As you mentioned that you have working code, do you happen to have a GitHub repo or other repository where I could try compiling example code which is known to be working?
GerReader is offline   Reply With Quote
Advert
Old 11-06-2020, 10:19 AM   #6
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,989
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
I have four devices, each with a different firmware version. OpenConfigEditor works on all of them. My latest device (Color) runs the app I build with SDK_481 (same as in blchinezu's SDK).

I believe that the firmware version on the Color is similar to the one on the Touch HD3, so I think your app should work when built against the SDK you have. However, there is a new SDK for the latest devices (SDK_6.3.0). Perhaps you could clone it from GitHub and try it out.

My Color device has gdb, and it seems to work in a pbterm session. If you don't have a working version of gdb on your device, then you might try the one I uploaded to this forum many years ago. https://www.mobileread.com/forums/sh...27&postcount=2. It might help you debug your problem.

Finally, I provide source code of my app at http://komary.net/pbimageviewer/. There are instructions for building with cmake against blchinezu's SDK, so you should be able to build it yourself. Note that the code covers many firmware versions, so it can get pretty complicated in places. It may not be great for learning from, but it should test whether the OpenConfigEditor call works.
rkomar is offline   Reply With Quote
Old 11-06-2020, 12:47 PM   #7
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 50
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
Quote:
Originally Posted by rkomar View Post
Finally, I provide source code of my app at http://komary.net/pbimageviewer/. There are instructions for building with cmake against blchinezu's SDK, so you should be able to build it yourself. Note that the code covers many firmware versions, so it can get pretty complicated in places. It may not be great for learning from, but it should test whether the OpenConfigEditor call works.
Thanks for the code. I managed to compile it, and I tested both my local compiled binary, and the pre-compiled -fw5 binary that was on your repository.

Both behave the same, and rather strangely on my device. I see a directory chooser in a very small font, and two very very small buttons in this chooser in the lower right corner. I can click into the directories on my device, but when I tap on one of the two buttons (they are so small that it is difficult to read them, one seems to read 'ok', the other 'choose this folder') or tap on the outside of the directory chooser, the app immediately exits (crashes?) to the device home screen.

I think now it is time to use gdb, then test all the different SDKs out there, and when this is futile, a factory reset. And then, when nothing else works, implement a config editor by myself.
GerReader is offline   Reply With Quote
Old 11-06-2020, 01:12 PM   #8
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,989
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
The directory chooser is almost useless on new devices. Copy over a zip file with some images in it, and add the full path to it as an argument to pbimageviewer.app. That will get around the awful directory chooser.
rkomar is offline   Reply With Quote
Old 11-06-2020, 02:51 PM   #9
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 50
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
Quote:
Originally Posted by rkomar View Post
Copy over a zip file with some images in it, and add the full path to it as an argument to pbimageviewer.app. That will get around the awful directory chooser.
That worked

And it is indeed showing a config editor. Clicking on an image -> menu appears -> there on Settings. I get a two-page config editor.

Okay, that means that a) it is not my device and b) it is not the SDK (I compiled with my current SDK). Debugging time now. Must be some very sneaky bug in my code. Still very strange that the app crashes exactly at the moment where it is opening the config editor, and works otherwise.

Perhaps also caused by the compile flags I use.
GerReader is offline   Reply With Quote
Old 11-06-2020, 03:22 PM   #10
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,989
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
You can try using the icons I have in my project. They are 55x55 in size, and work fine. Maybe they fixed it in the new firmware versions, but old versions would base the physical size of the menu item on the size of the icon, and then compute which font size to use based on that. Icons that were too small or too large would not be able to find a suitable font size to use with it, and that caused problems.

Also, make sure that you are using BUILD_FW5 as your target architecture. Others will probably build against the old version of the iconfigedit structure.

Last edited by rkomar; 11-06-2020 at 03:27 PM.
rkomar is offline   Reply With Quote
Old 11-14-2020, 11:50 AM   #11
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,989
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
It looks like you got your problem fixed. Is it worth describing what was wrong in case others have the same problem?
rkomar is offline   Reply With Quote
Old 11-14-2020, 12:12 PM   #12
GerReader
Connoisseur
GerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of itGerReader has read War And Peace ... all of it
 
Posts: 50
Karma: 66200
Join Date: Oct 2020
Location: Germany, Rhein-Main
Device: PocketBook Touch HD 3
Quote:
Originally Posted by rkomar View Post
It looks like you got your problem fixed. Is it worth describing what was wrong in case others have the same problem?
Unfortunately, I didn't get it fixed. Still no clue whats going on

As I wanted to have the app working, I simply coded a configuration screen from scratch. Wasn't exactly difficult, just quite tedious. This also had the advantage that I had the flexibility to have it exactly working like I wanted.

But I am still on it, as this surely isn't the only PocketBook app I am planning to write, and I really want to get the built-in config screen running. I promise to post here once I figured it out.
GerReader is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Firmware Update Instructions and the latest Firmware Versions mitchwah Ectaco jetBook 113 10-24-2023 09:02 PM
Firmware Update Kindle firmware 5.12.1 eilon Amazon Kindle 102 09-26-2019 08:38 PM
Firmware glitch - typing text slow on some firmware+device combinations mdp Onyx Boox 11 11-11-2017 12:48 AM
Firmware 2.0.3 Pocketbook IQ - another firmware is release for IQ tvpupsik PocketBook 26 12-13-2010 03:03 PM
SMARTQ7: firmware 5 VS .92 firmware 5.1? wwang Alternative Devices 2 12-17-2009 12:41 PM


All times are GMT -4. The time now is 07:01 PM.


MobileRead.com is a privately owned, operated and funded community.