huiqiaoqiu / ftk

Automatically exported from code.google.com/p/ftk
Other
0 stars 0 forks source link

tslib miss event #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I test on TQ2440 board, whih Resistive touch screen.

2. TouchScreen show error result.

What is the expected output? What do you see instead?
When I touch the touch screen, only the first event is dispatched ? The 
exact should be:
x    y    pressure
100 100      0
98  100      0
100 100      0
100 101      1

What version of the product are you using? On what operating system?
ftk-0.4 on Linux 2.6.30.4

Please provide any additional information below.
bug fix:
Change the function ftk_source_tslib_dispatch  in the file 
src/backend/fb/ftk_source_tslib.c

static Ret __ftk_source_tslib_dispatch(FtkSource* thiz,
        struct ts_sample *sample)
{
    int ret = 0;
    DECL_PRIV(thiz, priv);

    priv->event.type = FTK_EVT_NOP;
    priv->event.u.mouse.x = sample->x;
    priv->event.u.mouse.y = sample->y;
    ftk_logd("%s: sample->pressure=%d x=%d y=%d\n", 
        __func__, sample->pressure, sample->x, sample->y);
    if(sample->pressure > 0)
    {
        if(priv->pressed)
        {
            priv->event.type =  FTK_EVT_MOUSE_MOVE;
        }
        else
        {
            priv->event.type =  FTK_EVT_MOUSE_DOWN;
            priv->pressed = 1;
        }
    }
    else
    {
        if(priv->pressed)
        {
            priv->event.type =  FTK_EVT_MOUSE_UP;
        }
        priv->pressed = 0;
    }

    if(priv->on_event != NULL && priv->event.type != FTK_EVT_NOP)
    {
        priv->on_event(priv->user_data, &priv->event);
        ftk_logd("%s: type=%d x=%d y=%d\n", __func__, 
            priv->event.type, priv->event.u.mouse.x,
            priv->event.u.mouse.y);
        priv->event.type = FTK_EVT_NOP;
    }

    return RET_OK;
}

static Ret ftk_source_tslib_dispatch(FtkSource* thiz)
{
    int ret = 0;
    DECL_PRIV(thiz, priv);
    struct ts_sample sample = {0};
    return_val_if_fail(priv->ts != NULL, RET_FAIL); 

    while ((ret = ts_read(priv->ts, &sample, 1)) > 0) {
        ret = __ftk_source_tslib_dispatch(thiz, &sample);
        if (ret < 0) {
            break;
        }
    }

    return RET_OK;
}

Original issue reported on code.google.com by LianHaiD...@gmail.com on 10 Apr 2010 at 3:16

GoogleCodeExporter commented 8 years ago
###What is the expected output? What do you see instead?
When I touch the touch screen, only the first event is dispatched ? The 
exact should be:
x    y    pressure
100 100      1
98  100      1
100 100      1
100 101      0

But when I touch, I can't get four events. ONLY one or two events, other events 
will 
be dispatched net touch.

The reson is follow:

when we poll/select/epoll the tsdev's fd, we get some events (eg. four events), 
bug 
we only call ts_read once,  that is, we dose not read all event from tslib.

Original comment by LianHaiD...@gmail.com on 10 Apr 2010 at 3:25