您的位置:首页 > 编程语言 > Qt开发

QT/WebKit::DirectFB模式遥控器支持

2011-06-01 00:05 459 查看
前面已经有了在framebuffer下的遥控器支持,现在用相同的办法移植到directfb模式
/*dfbRemotecontrol.h
*******DfbRemoteControl类
*/
#include <QObject>
class QTimer;
class DfbRemoteControl : public QObject
{
Q_OBJECT
public:
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。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: