前面已经有了在framebuffer下的遥控器支持,现在用相同的办法移植到directfb模式下,附上相应源码。
/*dfbRemotecontrol.h
*******DfbRemoteControl类
*/
#include
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
#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。
djstava
阅读(3010) | 评论(0) | 转发(0) |