QTWebKit::DirectFB模式遥控器支持

    技术2022-05-20  62

    前面已经有了在framebuffer下的遥控器支持,现在用相同的办法移植到directfb模式/*dfbRemotecontrol.h*******DfbRemoteControl类*/#include <QObject>class QTimer;class DfbRemoteControl : public QObject {    Q_OBJECTpublic:    DfbRemoteControl();signals:    void DfbRemoteToKeyboardSignal(unsigned long keyCode);private slots:    void onTimer();private:    QTimer *readTimer;};#endif/*dfbRemotecontrol.cpp*/#include <QTimer>#include "dfbRemotecontrol.h"DfbRemoteControl::DfbRemoteControl(){    readTimer = new QTimer(this);    connect(readTimer, SIGNAL(timeout()), this, SLOT(onTimer()));    readTimer->start(30);}void DfbRemoteControl::onTimer(){    int ret;    unsigned long keyCode;      ret = getKeycode();    if (ret == 0)/*ok*/    {        qDebug("emit keyCode=%X/n", keyCode);        emit DfbRemoteToKeyboardSignal(keyCode);    }    else    {    }    readTimer->start(10);}将这两个文件加入放到src/plugins/gfxdrivers/directfb目录下,并在src/gui/embedded/directfb.pri中加入:  HEADERS += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/dfbRemotecontrol.h  SOURCES += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/dfbRemotecontrol.cpp在qdirectfbkeyboard.cpp中的class QDirectFBKeyboardHandlerPrivate中加入public方法int dfbRemote2key(char *keycode, unsigned long remoteCode);加入slot方法void dfbRecvRemoteEvent(unsigned long remoteCode);连接信号和槽:if(dfbRemotecontrol == NULL){         dfbRemotecontrol = new DfbRemoteControl();}         connect(dfbRemotecontrol, SIGNAL(DfbRemoteToKeyboardSignal(unsigned long)),this,SLOT(dfbRecvRemoteEvent(unsigned long)));方法int QDirectFBKeyboardHandlerPrivate::dfbRemote2key(char *keycode, unsigned long remoteCode)取得遥控器所对应的键盘的值而真正进行键值处理的函数为handler->processKeycode。


    最新回复(0)