Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#109854 - 09/08/2002 00:34 Long button presses in user apps?
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Hi,

What's the easiest way to hijack a long button press? Browsing through other code, it looks like I need to keep track of jiffies, and if the delta between a press and release is over a particular number, then it's a long button press. I just want to confirm this is the way to go, and that there isn't anything in hijack that to denote a long press when getting the data from the ioctl() call.

Thanks,

Top
#109855 - 09/08/2002 06:06 Re: Long button presses in user apps? [Re: canuckInOR]
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
The right way to do it would seem to be to use the EMPEG_HIJACK_POLLBUTTONS ioctl.
_________________________
- Tony C
my empeg stuff

Top
#109856 - 09/08/2002 19:30 Re: Long button presses in user apps? [Re: tonyc]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
So in otherwords, yes, I have to keep track of the jiffies between button press and button release myself...

Top
#109857 - 11/08/2002 00:09 Re: Long button presses in user apps? [Re: canuckInOR]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Hmm... right then. I do need to keep track of jiffies myself, but I don't think using EMPEG_HIJACK_POLLBUTTONS is the way to go at all. If I use that, then I have to throw in a while(no buttons pressed) loop, which causes the display to flash like crazy. I'm going to go out on a limb here, and suggest that EMPEG_HIJACK_POLLBUTTONS is probably only for those instances where you want to do some processing, but not at the expense of user input.

A better solution (at least, one that doesn't cause the screen to flash) is to still use EMPEG_HIJACK_WAITBUTTONS. If you want to hijack a long press, you need to hijack both _PRESSED and _RELEASED events for the particular button, but only have the _RELEASED event do what you want. When you get a _PRESSED event, then do a second ioctl(fd, EMPEG_HIJACK_WAITBUTTONS, &b) to pick up the release event, and check the delta between the two events to determine long vs. short press.

Cheers,

Top