Long button presses in user apps?

Posted by: canuckInOR

Long button presses in user apps? - 09/08/2002 00:34

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,
Posted by: tonyc

Re: Long button presses in user apps? - 09/08/2002 06:06

The right way to do it would seem to be to use the EMPEG_HIJACK_POLLBUTTONS ioctl.
Posted by: canuckInOR

Re: Long button presses in user apps? - 09/08/2002 19:30

So in otherwords, yes, I have to keep track of the jiffies between button press and button release myself...
Posted by: canuckInOR

Re: Long button presses in user apps? - 11/08/2002 00:09

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,