This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Remote Functionlaity in QT

Hi all,

                     Using this link (http://processors.wiki.ti.com/index.php/Building_Qt) i have successfully bulid the QT and also i can able to build the apps as well as navigating the application using the keyboard and mouse but i cant able to use the remote functionlaity in QT . Is there any documentation is avaliable to enable the remote in QT? or please provide any hint.

Thanks in Advance.

Regards,

A. Peter Jerald.

  • Hi, is this on Linux or Wince, DVSDK version? Which device is this on?

  • If you are trying to use the IR remote with Qt then please note that Qt does not have ,by default, support for IR Remote in its framework. To use the Remote, you will need to write the code in your Qt App to handle the IR remote events.

     

    Thanks.

    Best Regards,

    Varun Shah

  • If you are running Linux, you can take a look at the code which supports the remote in the DVSDK demos and the Ir module in DMAI.  You can create an "IR manager" in your QT application that uses the functionality of the Ir module (probably simpler to just copy Ir.c and Ir.h and remove all references to "Dmai" instead of linking with DMAI libraries in this case, as the Ir module is fairly standalone).  The Ir thread can call the Ir manager class and do something along this line:

    /******************************************************************************
     * IrThread::IrThread
     ******************************************************************************/
    IrThread::IrThread(IrManager * hIrMan)
    {
        m_hIrMan = hIrMan;
        m_quit = FALSE;
    }

    /******************************************************************************
     * IrThread::~IrThread
     ******************************************************************************/
    IrThread::~IrThread()
    {
        m_quit = TRUE;
        while (m_quit) {};
    }

    /******************************************************************************
     * IrThread::run
     ******************************************************************************/   
    void IrThread::run()
    {
        Qt::Key key;

        while (!m_quit) {
            /* If an IR key had been pressed, service it */
            if (m_hIrMan->getKey(&key)) {
                /* Send QKeyEvent to QApplication */

               // insert your code here to signal the application of this key event

            }
           
            usleep(REMOTECONTROLLATENCY);
        }
        m_quit = FALSE;
    }


    /******************************************************************************
     * IrManager::getKey
     * Get a key from IR port
     ******************************************************************************/
    bool IrManager::getKey(Qt::Key * qtKey)
    {
        Ir_Key key;

        if (Ir_getKey(m_hIr, &key) < 0) {
            printf("Failed to get IR value.\n");
        }

        /* If an IR key had been pressed, service it */
        if (key != 0) {
            return convertToQTKey(key, qtKey);
        }   
        else {
            return (FALSE);
        }
    }

    /******************************************************************************
     * convertToQTKey
     * Convert/map IR key code to QT keyboard key
     ******************************************************************************/
    static bool convertToQTKey(Ir_Key key, Qt::Key * qtKey)
    {
        printf("key pressed: %x\n", key);

        switch(key) {
            case Ir_Key_POWER:
                *qtKey = Qt::Key_Escape;
                break;
            case Ir_Key_MENUDONE:
                *qtKey = Qt::Key_Backspace;
                break;
            case Ir_Key_OK:
                *qtKey = Qt::Key_Return;
                break;
            default:
                return FALSE;
        }

        return TRUE;
    }

    Hope this helps,

    Vincent

  • Hi All,

     

    Thanks a lot for the help..              

    I want to know some more things regarding this IR functions. The code you have given above is in line with Ir.c so I think I have to save this Irthread.c and then call this C file in the IR Manager class on Qt.

    Can you please assist me to invoke the external files in Qt?

    Please help me in this regard.

     

    Thanks in advance.

    Regards,

    A.Peter Jerald

     

  • This will help. http://doc.qt.nokia.com/4.6/qfile.html

    Thanks.

    Best Regards,
    Varun Shah