Multitouch driver for Qt Embedded



  • Hi! Does anyone has ever been able to make multitouch work in Qt Embedded?
    I tried using tslib, but I can only get single touch support.
    I'm trying to understand what it is necessary to do to read the input device to get the events, but I can't understand how to do it. Do you have any idea of where I should go to get some information about this task?
    Thanks!



  • Here is one way:

    Create mouse handler plugin

    Copy library to mousedrivers directory

    Set the environment variable like this @ export QWS_MOUSE_PROTO=LinuxMultiTouch:/dev/input/event0 @

    Run your multi touch enabled application

    I use a type A multi point device, see "multi-touch-protocol":http://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt

    Modify qmouselinuxtp_qws.cpp to read @/dev/input/event0@ and process the ABS_MT_TRACKING_ID,
    ABS_MT_POSITION_X, ABS_MT_POSITION_Y, and SYN_REPORT codes into tracks. A track has state (idle or not idle), x, and y values.

    ABS_MT_TRACKING_ID tells you a track is NOT_IDLE. This number is the track ID until the next ABS_MT_TRACKING_ID event changes the track info. Handle 32 tracks to start with and add more if needed.

    ABS_MT_POSITION_X and ABS_MT_POSITION_Y tell you the x and y position for the current track ID (last ABS_MT_TRACKING_ID value).

    SYN_REPORT, says its time to take action on what you collected.

    For each track ID and based on the new track state (IDLE or NOT IDLE) and last track state you should do one of the following:

    create a new touch point and associate it with the track ID

    update touch point associated with track ID

    release touch point associated with track ID

    Then copy the new track state to the old, erase the new, and start again.

    Use a second object TouchEventSender that allows the QMouseHandler to add, update, and release touch points, as well as send the final touch event. Its based on "EventSenderQt":http://gitorious.org/webkit/webkit/blobs/b53cac0efab7a5b62fe470d927d6f5699ec501e0/Tools/DumpRenderTree/qt/EventSenderQt.cpp

    Make certain to call setState, setPos, setNormalizedPos, and setScreenPos when creating a TouchPoint as the translation code will make use of them. Don't reuse touch point IDs (always incrementing counter).

    Eventually all this boils down to this one line of code in event sender.
    @qt_translateRawTouchEvent(NULL, QTouchEvent::TouchPad, m_currentTouches.values() );@

    Hope this was helpful,
    atl



  • This is an extraordinary answer! Thank you very much.
    Sorry if I'm late answering, but I've had to pause this job. Now I've been able to write a single touch driver by following your advices.
    By reading at the example you reported I understand that touches are handled differently from single touch, right? I mean that linuxtp sends mouse events, while the EventSender uses QApplication::sendEvent.

    My question is related to the fact that QAppplication::sendEvent requires to know exactly the receiver of the event. How can I know at the driver level who should the receiver of the event be?

    Thank you again for your indications! I hope I will be able to create a plugin for multi-touch as well.



  • So, would this be considered the correct implementation?

    To summarize, you would generate a standard mouse event for each received point (or perhaps just the first point in the list of points), but you would also manage the TouchEvent data in the mouse handler as well?

    It seems like you would want to have a separate TouchEvent plugin rather than hack the QMouseHandler, but I guess that's not possible at this time?

    Also, if we we're actually making this plugin, we would need one that supports both type A and type B devices...or more probably two separate plugins for each, right?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.