Actually, I've studied this question in great detail. It's much more complicated than you might think. I started a
thread about it over at the iRex forum, but I never posted detailed information about it. For the interested, here's a summary.
The iLiad buttons can be grouped into two categories. Yes, the power switch is considered a "button".
- normal buttons : flipbar, up arrow, down arrow, dot key, and the escape button (upper left corner).
- special buttons : 'books', 'news', 'notes', 'docs', IDS connect, the power switch, and the menu button (directly above the flipbar).
First of all, the buttons on the iLiad do
not work in the usual way. The usual way is for the button driver to masquerade as a "keyboard" which is read directly by the X server, which then passes key signals to the appropriate application.
Instead, the ContentLister program runs in the background all the time and constantly queries the hardware buttons at /dev/buttons directly using ioctls. When a button is pressed, the ContentLister decides whether it was a "long press" or a "short press" and what to do with it. If it's a "normal" button, the ContentLister sends a key press event to the X server. (Matthijs informed me that XSendEvent is used for this, thanks, Matthijs!) If it's a "special" button, the ContentLister never passes it to the X server at all. More on this later.
You can easily use any of the "normal" buttons you want, simply by getting them through the X server. Here's how the "normal" buttons are represented as key presses in X via GDK:
Code:
Button Press Keypress Equivalent
============ ===================
Up Arrow GDK_Up
Dot (Enter) GDK_Return
Down Arrow GDK_Down
Long Up Arrow GDK_F4
Long Dot (Enter) GDK_F6
Long Down Arrow GDK_F3
Page Forward GDK_Page_Down
Page Back GDK_Page_Up
Long Page Forward GDK_F1
Long Page Back GDK_F2
Escape GDK_F5
As I said above, if you press one of "special" buttons, it's completely different. The ContentLister takes care of the button press functionality by itself and doesn't pass anything to the X server. For example, if you press the 'books' key, the ContentLister will close whatever program is open, then display the "books" directory on your memory card.
So, there's no way to read any of the "special" buttons without writing your own program to query the button driver directly, the same way the ContentLister does.
Now, you
can have a second program query the button driver simultaneously with the ContentLister. I've written such a program and it works beautifully. However, there's a small problem: if a button press is short enough (less than 1/10 second), it's possible for your program to catch the button push and the ContentLister to miss it (or vice versa). This is because querying the button data resets it, so if you push quick enough, one program will read the button data, and by the time the other program queries the driver, you've released the button and there's no data to get.
If anyone's interested in the gritty details of the button driver, ioctls, button handling, etc., I'd be happy to provide them. I have a short program that queries the iLiad buttons directly, as well as a reference of the hex code that each button returns. If you're interested, let me know!
Hope this helps!