Hijack does something along these lines, which may be subtly different than the single-timer approach:

1. Timestamp the event (RDTSC or the like) when the button PRESS event is received.
2. If the particular button/context is only valid as a "SHORT press", then send the event immediately to upper layers, and discard the subsequent button RELEASE when it arrives later on.
3. If the RELEASE (or another PRESS of any button) arrives before the LONG press interval expires, then send the button press along as a SHORT press to the upper layers, and discard the RELEASE.
4. When the required interval for a LONG press expires, initiate processing of the button event to the upper layers, and discard the subsequent button RELEASE when it arrives later on.
5. If a REPEAT operation (generate repetitions while pressed) is required, then periodically (at the required repeat interval) resend PRESS events to the upper layers, until such time as a RELEASE is received, or (failsafe) another PRESS is received (for any button).

Cheers


Edited by mlord (10/12/2003 16:00)