Exemple #1
0
static bool button_try_post(int button, int data)
{
#ifdef HAVE_TOUCHSCREEN
    /* one can swipe over the scren very quickly,
     * for this to work we want to forget about old presses and
     * only respect the very latest ones */
    const bool force_post = true;
#else
    /* Only post events if the queue is empty,
     * to avoid afterscroll effects.
     * i.e. don't post new buttons if previous ones haven't been
     * processed yet - but always post releases */
    const bool force_post = button & BUTTON_REL;
#endif

    bool ret = queue_empty(&button_queue);
    if (!ret && force_post)
    {
        queue_remove_from_head(&button_queue, button);
        ret = true;
    }

    if (ret)
        queue_post(&button_queue, button, data);

    /* on touchscreen we posted unconditionally */
    return ret;
}
Exemple #2
0
/* This callback can be used for many different functions if needed -
   just check to which object tmo points */
static int btn_detect_callback(struct timeout *tmo)
{
    /* Try to post only transistions */
    const long id = tmo->data ? SYS_PHONE_PLUGGED : SYS_PHONE_UNPLUGGED;
    queue_remove_from_head(&button_queue, id);
    queue_post(&button_queue, id, 0);
    return 0;
}
Exemple #3
0
/* external interface */
void buttonlight_on(void)
{
    queue_remove_from_head(&backlight_queue, BUTTON_LIGHT_ON);
    queue_post(&backlight_queue, BUTTON_LIGHT_ON, 0);
}