11-13-2008, 02:49 PM | #1 |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Button check
Hi,
I wrote a small program to check if a button is pressed: Code:
* ----- Small test program to check which button is pressed --------- * Prints a string (2 characters) to stdout: * FF: No key pressed * 00: Connect (IDS) * 01: Button avove page bar * 02: Top left button * 03: NEWS * 04: BOOKS * 05: DOCS * 06: NOTES * 07: page bar left * 08: page bar right * 09: UP arrow * 0A: DOT (enter) * 0B: DOWN arrow * 0E: Power on button * E0: Error, cannot open device * E1: Error, cannot get button state */ #include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <sys/ioctl.h> #define BUTTON_IOCTL_BASE 'b' #define BUTTON_IOCTL_GET_STATUS _IOR( BUTTON_IOCTL_BASE,7,unsigned int) int main(int argc, char *argv[]) { int i; int status; int dev; if ((dev = open("/dev/buttons", O_RDWR)) < 0) { fprintf(stderr,"ERROR opening failed\n"); status = 0xe0; } else if (ioctl(dev, BUTTON_IOCTL_GET_STATUS, &status)) { fprintf(stderr, "ERROR: BUTTON_IOCTL_GET_STATUS failed\n"); status = 0xe2; } printf("%02X", status & 0xff); return 0; } Code:
arm-linux-gcc checkbutton.c -o checkbutton ANY idea what might be happening? The program always returns 'FF', no key pressed... EDIT: when I do a lsmod just before calling buttoncheck, I see tha the button module is loaded... Last edited by hansel; 11-13-2008 at 03:06 PM. Reason: more info |
11-14-2008, 10:23 AM | #2 |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
Does contentlister trap all button input before this program?
This topic is too far from my current knowledge. |
Advert | |
|
11-14-2008, 12:09 PM | #3 |
Developer
Posts: 345
Karma: 3473
Join Date: Apr 2007
Location: Brooklyn, NY, USA
Device: iRex iLiad v1, Blackberry Tour, Kindle DX, iPad.
|
Why are you only reading the button status once?
Okay, for the record, here is the thread about all things button-related. Someone should really sticky that thread, I keep referring people to it. The short answer is, every time the button status is checked, the buffer is then reset to "ff". The ContentLister checks button status 10 times per second. So if your program runs its one single button check just after the ContentLister, it's possible that it won't see it. It also depends on how you're pressing the button. Are you holding it down? For how long? At what point during boot do you start pressing it? When does your program run (i.e. what does your start.sh script look like)? |
11-14-2008, 03:09 PM | #4 | |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Quote:
I poll before contenLister is even started (at the start of /home/root/start.sh) I want to use it do decide between the normal start-up (powrMgr, contenLister, etc), and my experimental stuff. When I make a mistake, I can always boot the normal way (just don't press the magic button). I could also start sshd by pressing 'BOOKS' while booting I've tried polling 10 times with a small interval, but I get FF ten times... I hold the button at power-on, and only let it go when contentLister is showing... Aparently I miss something, or something is still disabled when I poll... Did you try to call your poll program in start.sh? |
|
11-14-2008, 03:32 PM | #5 |
Developer
Posts: 345
Karma: 3473
Join Date: Apr 2007
Location: Brooklyn, NY, USA
Device: iRex iLiad v1, Blackberry Tour, Kindle DX, iPad.
|
I'm pretty sure I've had my program in start.sh in the past, and it worked fine. Can't really remember, though.
The problem might be that you're holding down the button before the module is loaded? You could also try installing my program and see if that works? |
Advert | |
|
11-14-2008, 04:32 PM | #6 |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
jharker (and All)
I get the same results with your sample program (as expected). May be I'm pressing the key to early... But since I want to detect it very early in the boor process I don't have much choice... I discovered one VERY USEFUL thing. (As I already new) the button info is in the lower two nibbles of the return data, BUT the next nibble tells if a CF card or a SD card is inserted (even the dummy plastic one). My CF is always inserted (that's where my sshd runs)
The interesting part is that this holds at boot time. I can activate my experimental stuff by inserting the dummy plastic SD card PS: If somebody has any ideas why the key detection at boot time doesn't work, I'd be very interested to hear them. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do you check your formatting? | deferredreward | Writers' Corner | 2 | 08-31-2010 04:41 PM |
Anybody get their rebate check? | DrBen | Astak EZReader | 9 | 09-16-2009 04:59 PM |
Check it out | Dragoro | Lounge | 0 | 04-07-2009 02:17 AM |
Check out my books | HistoryWes | Amazon Kindle | 5 | 02-20-2009 07:57 PM |
Reality check | rlauzon | Bookeen | 46 | 03-06-2008 03:40 PM |