Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt embedded, multitouch and tslib with multitouch support
QtWS25 Last Chance

Qt embedded, multitouch and tslib with multitouch support

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 2 Posters 6.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    webquinty
    wrote on 24 Oct 2014, 19:48 last edited by
    #1

    Hello,

    I am interesting in qt embedded with gestures.
    At this moment, I use qt 4.8.4 with tslib using a multitouch screen configurate as single touch an it works fine.

    Now I replace my old tslib library with a new one that it has a multitouch support.
    Using ts_test with debug, library detect all points with your ID and position.

    But now, I dont known how use this in Qt.
    All touch examples only use one finger. If I use two fingers, only one touch is active.

    Has anybody any experience using multitouch with Qt embedded??

    Bestregards

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Oct 2014, 21:28 last edited by
      #2

      Hi,

      Did you took a look at the "Touch Input Examples" in Qt's documentation ? The Touch Knobs Example might be a starting point

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        webquinty
        wrote on 25 Oct 2014, 09:34 last edited by
        #3

        Thank you.

        And yes, before post I have read all examples about touch.

        @
        QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);

            if (touchEvent->touchPoints().count() == 2) {
                const QTouchEvent::TouchPoint &touchPoint1 = touchEvent->touchPoints().first();
                const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last();
        
                QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos());
                QLineF line2(touchPoint1.scenePos(), touchPoint2.scenePos());
        
                rotate(line2.angleTo(line1));
            }
        

        @

        This example need two points to work and I dont know how to send to Qt touch points from TSLIB.

        Perhaps, TSLIB is not de correct plugin and I need to use other different, like LinuxInput or LinuxTP.

        In my embedded system using evtest tell me that my device support the follow ev.codes:
        MT_SLOT
        MT_POSITION_X
        MT_POSITION_Y
        MT_TRANCKING_ID

        Any advice or suggest?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 25 Oct 2014, 21:28 last edited by
          #4

          AFAIK tslib is the right plugin to use. However, did you set the Qt::WA_AcceptTouchEvents flag on your widgets ?

          You have a more thorough explication about that in the QTouchEvent documentation

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • W Offline
            W Offline
            webquinty
            wrote on 27 Oct 2014, 14:55 last edited by
            #5

            And sorry but after read code I think that tslib is not the correct way.
            This is a portion of code of qmousetslib_qws.cpp

            @bool QWSTslibMouseHandlerPrivate::get_sample(struct ts_sample *sample)
            {
            if (!calibrated)
            return (ts_read_raw(dev, sample, 1) == 1);

            return (ts_read(dev, sample, 1) == 1);
            

            }

            int StackCnt;
            void QWSTslibMouseHandlerPrivate::readMouseData()
            {
            if (!qt_screen)
            return;

            for(;;) {
                struct ts_sample sample = lastSample;
                bool pressed = wasPressed;
            
                // Fast return if there's no events.
                if (!get_sample(&sample))
                    return;
            
                pressed = (sample.pressure > 0);
            
                // Only return last sample unless there's a press/release event.
                while (pressed == wasPressed) {
                    if (!get_sample(&sample))
                        break;
                    pressed = (sample.pressure > 0);
                }
            
                // work around missing coordinates on mouse release in raw mode
                if (!calibrated && !pressed && sample.x == 0 && sample.y == 0) {
                    sample.x = lastSample.x;
                    sample.y = lastSample.y;
                }
            
                int dx = sample.x - lastSample.x;
                int dy = sample.y - lastSample.y;
            
                // Remove small movements in oppsite direction
                if (dx * lastdx < 0 && qAbs(dx) < jitter_limit) {
                    sample.x = lastSample.x;
                    dx = 0;
                }
                if (dy * lastdy < 0 && qAbs(dy) < jitter_limit) {
                    sample.y = lastSample.y;
                    dy = 0;
                }
            
                if (wasPressed == pressed && dx == 0 && dy == 0)
                    return;
            

            #ifdef TSLIBMOUSEHANDLER_DEBUG
            qDebug() << "last" << QPoint(lastSample.x, lastSample.y)
            << "curr" << QPoint(sample.x, sample.y)
            << "dx,dy" << QPoint(dx, dy)
            << "ddx,ddy" << QPoint(dxlastdx, dylastdy)
            << "pressed" << wasPressed << pressed;
            #endif

                lastSample = sample;
                wasPressed = pressed;
                if (dx != 0)
                    lastdx = dx;
                if (dy != 0)
                    lastdy = dy;
            
                const QPoint p(sample.x, sample.y);
                if (calibrated) {
                    // tslib should do all the translation and filtering, so we send a
                    // "raw" mouse event
                    handler->QWSMouseHandler::mouseChanged(p, pressed);
                } else {
                    handler->sendFiltered(p, pressed);
                }
            }
            

            }@

            I could read only one sample and it can not handle slots and trancking_id, then, in my opinion, it is impossible to handle a multitouch events with this code.

            If I want to touch two buttons, I think I need to handle MT_SLOT and MT_TRACKING_ID to determinate how many fingers are pressed touch screen.

            Are you sure that is it possible to have more than one finger and pressed two buttons at the same time??

            Best regards.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 27 Oct 2014, 23:01 last edited by
              #6

              Sorry, my bad, I've forgot that it required a little bit of work.

              See this "thread":http://qt-project.org/forums/viewthread/5052 and this "article":http://www.ptrackapp.com/apclassys-notes/embedded-linux-multitouch/ for more information about how to do it

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • W Offline
                W Offline
                webquinty
                wrote on 30 Oct 2014, 20:15 last edited by
                #7

                Bufffff,

                thank you very much but a lot of work.
                Finally, i am going to create my own mouse handler plugin.

                I only have a bit problem.
                I dont known how to send a touchevevnt from plugin. Do you known?

                Best regards.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 30 Oct 2014, 21:24 last edited by
                  #8

                  AFAIK, you would need to call qt_translateRawTouchEvent at some point

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • W Offline
                    W Offline
                    webquinty
                    wrote on 31 Oct 2014, 09:30 last edited by
                    #9

                    [quote author="SGaist" date="1414704241"]AFAIK, you would need to call qt_translateRawTouchEvent at some point[/quote]

                    Hello,

                    Ok, but I have still a bit problem.

                    @qt_translateRawTouchEvent(QWidget *window,
                    QTouchEvent::DeviceType deviceType,
                    const QListQTouchEvent::TouchPoint &touchPoints);@

                    This function need pointer to widget, but in my new mouse plugin I dont known the pointer to widget.

                    Is it possible to setup widget as NULL and qt_translateRawTouchEvent send touch events to upper layer???

                    Best regards.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 1 Nov 2014, 00:19 last edited by
                      #10

                      I'd try with QApplication::widgetAt

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      2/10

                      24 Oct 2014, 21:28

                      topic:navigator.unread, 8
                      • Login

                      • Login or register to search.
                      2 out of 10
                      • First post
                        2/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved