QT 键盘插件

发布于 2024-11-09 04:27:19 字数 1016 浏览 0 评论 0原文

我已经在其中一个 MIPS 平台中启用了 QT。 我已经为显示编写了一个图形插件并且工作正常。 现在我正在尝试启用键盘。

我没有再编写一个键盘插件,而是将键盘作为 Grpahics 插件的一部分。 我的键盘代码是这样的:

class MyKeyboardHandler : public QObject, public QWSKeyboardHandler 
{ 
 Q_OBJECT 
 public:  MyKeyboardHandler(); 
 virtual ~MyKeyboardHandler();

private:         QSocketNotifier     *m_notifier;

private slots:       void readKeyboardData(); 
};

通过套接字,我获取键盘数据。 我已经注册了一个信号来readKeyboardData,这样每当套接字中有数据时,readKeyboardData就会被调用。

该类的构造函数是这样的:

....  m_notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);

     connect(m_notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
     //QWSServer::setKeyboardHandler(this);
...

在 readKeyboardData() 中,我调用

processKeycode() 

使用上面的代码,我得到套接字读取调用,并调用 processKeyCode。但唯一的问题是应用程序永远不会获得密钥。 当我启用最后一行(QWSServer::setKeyboardHandler(this))时,套接字读取信号永远不会出现。即 readKeyboardData() 函数永远不会被调用。

如果我做错了什么,请告诉我。 我的主要目的是启用键盘。

I have enabled QT in one of the MIPS platform.
I have written a graphics plugin for the display and is working fine.
Now I am trying to enable Keypad.

Instead of writing one more keyboard plugin, I have made keypad part of the Grpahics plugin.
My keyboard code is some thing like this:

class MyKeyboardHandler : public QObject, public QWSKeyboardHandler 
{ 
 Q_OBJECT 
 public:  MyKeyboardHandler(); 
 virtual ~MyKeyboardHandler();

private:         QSocketNotifier     *m_notifier;

private slots:       void readKeyboardData(); 
};

With the socket, I get the Keyboard data.
I have registered a Signal to readKeyboardData, so that whenever there is data in socket, readKeyboardData is called.

The constructor of the class is some thing like this:

....  m_notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);

     connect(m_notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
     //QWSServer::setKeyboardHandler(this);
...

In readKeyboardData(), I call

processKeycode() 

With the above code, I get the socket read calls, and processKeyCode is called. But the only thing is that application never gets the key.
The moment I enable last line (QWSServer::setKeyboardHandler(this), the socket read signal never come. That is readKeyboardData() function never gets invoked.

Please let me know if I am doing any thing wrong.
My main intention is to enable Keypad.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2024-11-16 04:27:19

我能够调试这个问题。实际上代码可以工作,但由于驱动程序问题,它没有显示在应用程序中。在键盘驱动程序中,驱动程序过去总是只给出 Keyup 而不是 keydown。所以 keydown 从来没有消失过。因此应用程序无法正确接收数据。当我修好驱动程序后,它开始工作 – hari
(将其发布为答案而不是评论)

I was able to debug the issue. Actually the code was working but due to driver issue, it was not showing up at the application. In the keyboard driver, the driver used to always give only Keyup and not keydown. So keydown never used to go. Hence application was not properly receiving the data. After I got driver fixed, it started working – hari
(Posting it as answer instead of comment)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文