Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-25-2009, 08:39 PM   #1
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Some doubts: showing keyboard and ContentLister

Hi,

some questions for the ones who have dived into iLiad sources:

- how to make keyboard show/hide from a program?
Found [1], but I can't see anything useful from there, only:
Code:
 toolbar_setIconState(iconID_keyboard, iconState_selected);
and from there an IPC send... but what's on the other end listening and launching matchbox-keyboard?

[1] http://iliad.hpelbers.org/irexdox/co...2bc0cd0ff67e31


- executing ipdf from ContentLister vs. from CLI
If I run ipdf file.pdf from a ssh shell, up button don't quit the program. Same happens for FBReader.
Could you point me to the part of the sources where ContentLister changes this behaviour?

It looks like pm_TerminateUserApp() in programManager.c kills the viewer [1]

UPDATE: ContentLister gets the "quit" key and then kills the app with kill(pid).
To emulate what ContentLister does when running a new program [2] we should execute pm_RunViewer or store uaID (viewer id) by ourselves (g_uaOnTop and g_lastStartedUa stacks).

pm_SendKey function is quite interesting too [3].

[1] http://iliad.hpelbers.org/irexdox/co...17410649ff165a
[2] http://iliad.hpelbers.org/irexdox/co...04c2f19d198317
[3] http://iliad.hpelbers.org/irexdox/co...2bc0cd0ff67e31


Thanks in advance,
Iņigo
Iņigo is offline   Reply With Quote
Old 11-26-2009, 09:15 PM   #2
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Attached you can find a simple lua demo of a matchbox-keyboard embeded into a gtk program, and whose keystrokes are forwarded to a gtk.TextView widget.
It's a mere translation of the C example included with matchbox-keyboard v0.1 sources.

It works on my desktop, but sadly enough, the matchbox-keyboard included in my Iliad doesn't accept the "-xid" argument, and looking at the sources it has no support to be embedded.

So I'm coming back to the first question, how does Iliad manage to open the keyboard and handle the keystrokes?
Attached Files
File Type: gz test_kbd.lua.gz (662 Bytes, 127 views)
Iņigo is offline   Reply With Quote
Old 11-27-2009, 05:28 AM   #3
pwarren
Connoisseur
pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.
 
Posts: 95
Karma: 186186
Join Date: May 2009
Location: Canberra, Australia
Device: Irex Iliad (Dead), EcoReader (Smashed screen), Kobo Touch
from what I recall, you need to include the iliad eripc headers, create the ipc channel, then use that channel to show/hide the keyboard. This is C code, could probably work similarly in C++

Code:
// include eripc
#include <liberipc/eripc.h>
#include <liberipc/eripcviewer.h>
#include <liberipc/eripctoolbar.h>

// ipc channel variable
erClientChannel_t ertoolbarChannel;

// ipc channel creation
erIpcStartClient(ER_TOOLBAR_CHANNEL, &ertoolbarChannel);

// get the toolbar channel set up as for the PDF viewer application
tbSelectIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);
tbClearIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);

// enable on screen keyboard
tbAppendPlatformIcon(ertoolbarChannel,ER_PDF_VIEWER_UA_ID,iconID_keyboard,-1);

// turn off trashcan as an extra.
tbAppendPlatformIcon(ertoolbarChannel,ER_PDF_VIEWER_UA_ID,iconID_trashcan,-1);
tbSetStatePlatformIcon(ertoolbarChannel,ER_PDF_VIEWER_UA_ID,iconID_trashcan, iconState_grey);
Hope that helps a bit
pwarren is offline   Reply With Quote
Old 11-27-2009, 06:21 AM   #4
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by pwarren View Post
from what I recall, you need to include the iliad eripc headers, create the ipc channel, then use that channel to show/hide the keyboard. This is C code, could probably work similarly in C++

Code:
// include eripc
#include <liberipc/eripc.h>
#include <liberipc/eripcviewer.h>
#include <liberipc/eripctoolbar.h>

// ipc channel variable
erClientChannel_t ertoolbarChannel;

// ipc channel creation
erIpcStartClient(ER_TOOLBAR_CHANNEL, &ertoolbarChannel);

// get the toolbar channel set up as for the PDF viewer application
tbSelectIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);
tbClearIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);

// enable on screen keyboard
tbAppendPlatformIcon(ertoolbarChannel,ER_PDF_VIEWER_UA_ID,iconID_keyboard,-1);

// turn off trashcan as an extra.
tbAppendPlatformIcon(ertoolbarChannel,ER_PDF_VIEWER_UA_ID,iconID_trashcan,-1);
tbSetStatePlatformIcon(ertoolbarChannel,ER_PDF_VIEWER_UA_ID,iconID_trashcan, iconState_grey);
Hope that helps a bit
Hello pwarren,

first thanks for your comments.

I understand that this is the way to send the action "show the keyboard" but I guess it should be the other side of the channel, the code which performs the launch of the keyboard. I'm interested in that other end of the channel.
Who is listening on that other side? which daemon or process?

Or am I missing anything?
Iņigo is offline   Reply With Quote
Old 11-27-2009, 07:09 AM   #5
pwarren
Connoisseur
pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.pwarren can program the VCR without an owner's manual.
 
Posts: 95
Karma: 186186
Join Date: May 2009
Location: Canberra, Australia
Device: Irex Iliad (Dead), EcoReader (Smashed screen), Kobo Touch
Oh, I see, you're after the process that's listening for those IPC calls, and then launches the matchbox keyboard software? I'm clueless about that end of things
pwarren is offline   Reply With Quote
Old 11-28-2009, 01:09 PM   #6
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Quote:
Originally Posted by Iņigo View Post
- executing ipdf from ContentLister vs. from CLI
If I run ipdf file.pdf from a ssh shell, up button don't quit the program. Same happens for FBReader.
Could you point me to the part of the sources where ContentLister changes this behaviour?
As to the different behavior between ipdf and FBReader when calling from shell, I have one point to share (maybe you already know it):
Look at "registry.xml", you will find that FBReader is using channel 14 (for shell script) and ipdf is using channel 2. When you execute ipdf from shell, ipdf will use channel 2 but CLI will wait on channel 14 (maybe vice versa). That's why UP button won't be functional in this case.
ericshliao is offline   Reply With Quote
Old 11-29-2009, 07:24 PM   #7
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by ericshliao View Post
As to the different behavior between ipdf and FBReader when calling from shell, I have one point to share (maybe you already know it):
Look at "registry.xml", you will find that FBReader is using channel 14 (for shell script) and ipdf is using channel 2.
Very interesting, haven't noticed it.

Quote:
When you execute ipdf from shell, ipdf will use channel 2 but CLI will wait on channel 14 (maybe vice versa). That's why UP button won't be functional in this case.
hmmm...
Neither ipdf or FBreader listen to UP key when running from the CLI, so it must depends on how the apps are started.
Anyway, first question remains... who is listening on the other side of the IPC mechanism? how keyboard is shown?
Iņigo is offline   Reply With Quote
Old 11-30-2009, 04:50 AM   #8
Max
Connoisseur
Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.
 
Max's Avatar
 
Posts: 79
Karma: 380
Join Date: Mar 2008
Location: Girona, Spain
Device: iLiad, DR1000s
Post

In the ipdf app. the events in the toolbar buttons are send to the ipcCbk function. You set the call back function with:

Code:
       erIpcChannel = channel;           
       int fd = erIpcGetServerFd(channel); 
         
       gdk_input_add (fd, 
                              GDK_INPUT_READ, 
                              (GdkInputFunction) ipcCbk, 
                              (gpointer) this);
when you set a icon the last parameter is a code send to de ipcCbk when you click on the icon. then you can set a icon like:

Code:
tbAppendPlatformIcon(  ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_pan, ccVwrToolbar);
and in the ipcCbk do:

Code:
void IliadToolbar::ipcCbk(gpointer client_data, gint *fd, GdkInputCondition id) 
{ 
         
         IliadToolbar *toolBar = (IliadToolbar *) client_data; 
         char szBuffer[IPC_BUF_MAX]; 
         int nBuf = IPC_BUF_MAX; 
         erIpcCmd_t command; 
         erServerChannel_t channel = toolBar->erIpcChannel; 
         erIpcGetMessage(channel, szBuffer, &nBuf); 
         if (vwrParseCommand(szBuffer, &command) >= 0) 
         { 
                 switch (command.cc) 
                 { 
                         case ccVwrToolbar:
In when ccVwrToolbar is recibed ipdf check the icon name to decide the action to take.

As how you show/hide the keyboar you can see the settings app code in:

http://iliad.hpelbers.org/irexdox/se...735f93a6ced14a

the method show_keyboard.
Max is offline   Reply With Quote
Old 11-30-2009, 03:28 PM   #9
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Quote:
Originally Posted by Iņigo View Post
Neither ipdf or FBreader listen to UP key when running from the CLI, so it must depends on how the apps are started.
IIRC, the UP key is defined as GDK_F5. That mean, CLI will send a GDK_F5 button event to some applicatoin when the key is pushed. To make FBReader react to the key, you have to modify "keymap.xml". I assign GDK_F5 to "QUIT", so that FBReader will quit when I push the UP key. This step is to be done manually by each user. Normally, ipdf should react to the UP key when starting from CLI. Your description is quite strange. I suppose the UP key is on the top-left corner of iLiad, not the up-arrow key.

Last edited by ericshliao; 11-30-2009 at 03:32 PM.
ericshliao is offline   Reply With Quote
Old 12-01-2009, 08:07 PM   #10
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Lightbulb Solved keyboard question

Hello Max,

Quote:
Originally Posted by Max View Post
In the ipdf app. the events in the toolbar buttons are send to the ipcCbk function. You set the call back function with:

Code:
       erIpcChannel = channel;           
       int fd = erIpcGetServerFd(channel); 
         
       gdk_input_add (fd, 
                              GDK_INPUT_READ, 
                              (GdkInputFunction) ipcCbk, 
                              (gpointer) this);
when you set a icon the last parameter is a code send to de ipcCbk when you click on the icon. then you can set a icon like:

Code:
tbAppendPlatformIcon(  ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_pan, ccVwrToolbar);
and in the ipcCbk do:

Code:
void IliadToolbar::ipcCbk(gpointer client_data, gint *fd, GdkInputCondition id) 
{ 
         
         IliadToolbar *toolBar = (IliadToolbar *) client_data; 
         char szBuffer[IPC_BUF_MAX]; 
         int nBuf = IPC_BUF_MAX; 
         erIpcCmd_t command; 
         erServerChannel_t channel = toolBar->erIpcChannel; 
         erIpcGetMessage(channel, szBuffer, &nBuf); 
         if (vwrParseCommand(szBuffer, &command) >= 0) 
         { 
                 switch (command.cc) 
                 { 
                         case ccVwrToolbar:
In when ccVwrToolbar is recibed ipdf check the icon name to decide the action to take.

As how you show/hide the keyboar you can see the settings app code in:

http://iliad.hpelbers.org/irexdox/se...735f93a6ced14a

the method show_keyboard.
scotty1024 mrxvt code [1] proposed the same code, a program can use:
Code:
// Enable then pop up keyboard
tbAppendPlatformIcon(  ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, -1);
tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, iconState_selected);
to show the keyboard, but studying those functions, we can see that tbSetStatePlatformIcon calls erIpcStartClient function (in eripc.c), which opens a socket to send the message/action.
Who is listening on the other part of the socket?

For instance, we can turn off the led from a program with (also from [1]):
Code:
// Turn off busy LED if we were invoked via [SHELL]
erIpcStartClient(ER_BUSYD_CHANNEL, &erbusyChannel);
busySetBusy(erbusyChannel, ccBusyState_Off);
which sends an IPC command through a socket. The daemon listening this socket and who in fact turn off the led is erbusyd, using an ioctl call (look at erbusyd.c).


UPDATE: ok, mistery solved: looks like it must be mb-applet-icon-container.c (lines 303 and 1479). Matchbox handles it.

It's very easy to make this work, to show the keyboard from inside an application and make the keystrokes to be redirected to our widgets.
You can see a proof of concept attached.
To run it:
$ lua test_kbd.lua | /path/to/xx -p


Thanks for all the ideas and enjoy the simplicity ;-)
Iņigo

PS: btw Hansel, I think you could substitute your custom keyboard in Minipad with something like this.

[1] http://www.mobileread.com/forums/sho...63&postcount=4
Attached Thumbnails
Click image for larger version

Name:	kbd-test.png
Views:	151
Size:	41.6 KB
ID:	40568  
Attached Files
File Type: gz test_kbd.lua.gz (529 Bytes, 120 views)
Iņigo is offline   Reply With Quote
Old 12-01-2009, 08:09 PM   #11
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 712
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by ericshliao View Post
IIRC, the UP key is defined as GDK_F5. That mean, CLI will send a GDK_F5 button event to some applicatoin when the key is pushed. To make FBReader react to the key, you have to modify "keymap.xml". I assign GDK_F5 to "QUIT", so that FBReader will quit when I push the UP key. This step is to be done manually by each user. Normally, ipdf should react to the UP key when starting from CLI. Your description is quite strange. I suppose the UP key is on the top-left corner of iLiad, not the up-arrow key.
I'm exhausted now after all the thinking regarding keyboard... I'll take a look at this tomorrow.
(and yes, I referred to top-left corner UP/quit button).

Thanks, Iņigo
Iņigo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A couple of doubts. johnpdoe Amazon Kindle 15 07-25-2010 08:32 AM
PRS-600 Some doubts with the battery of 600 shineofleo Sony Reader 16 10-17-2009 01:52 PM
Two doubts from a potential 505 buyer ccpraveen Sony Reader 7 07-26-2009 10:31 AM
Doubts about usability satanicoPlan iRex 1 12-05-2007 09:42 AM
FBReader Newbie doubts. Gubbi Reading and Management 6 02-22-2006 07:33 AM


All times are GMT -4. The time now is 02:53 PM.


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