please anyone here help me to solve this problem.

I am working on linux 2.4.19 (arm based) + qt-embedded-free-3.3.8b.
and now I am writing a custom keyboard handler which subclass from QWSKeyBoardHandler.

Qt Code:
  1. class MyKbdHandler: public QObject, public QWSKeyBoardHandler {
  2. Q_OBJECT
  3. public:
  4. MyKbdHandler();
  5. ~MyKbdHandler();
  6.  
  7. private slots:
  8. void readKbdData();
  9.  
  10. private:
  11. QSocketNotifier *m_kbdNotifier;
  12. int m_kbdFd;
  13. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. MyKbdHandler::MyKbdHandler()
  2. : QObject(), QWSKeyBoardHandler()
  3. {
  4. m_kbdNotifier = NULL;
  5. m_kbdFd = ::open("/dev/input", O_RDONLY|O_NONBLOCK);
  6. if (m_kbdFd < 0) {
  7. qDebug("Can not open input device!\n");
  8. return;
  9. }
  10.  
  11. m_kbdNotifier = new QSocketNotifier(m_kbdFd, QSocketNotifier::Read, this);
  12. connect(m_kbdNotifier, SIGNAL(activated(int)), this, SLOT(readKbdData()));
  13. }
  14.  
  15. MyKbdHandler::~MyKbdHandler()
  16. {
  17. if (m_kbdFd >= 0) {
  18. ::close(m_kbdFd);
  19. m_kbdFd = -1;
  20. }
  21.  
  22. if (m_kbdNotifier != NULL) {
  23. delete m_kbdNotifier;
  24. m_kbdNotifier = NULL;
  25. }
  26. }
  27.  
  28. MyKbdHandler::readKbdData()
  29. {
  30.  
  31. char buf[1024] = { 0 };
  32. int n = ::read(m_kbdFd, buf, sizeof(buf));
  33. qDebug("MyKbdHandler::readKbdData = %d\n", n);
  34.  
  35. // do key code mapping and call processKeyEvent here ...
  36.  
  37. }
To copy to clipboard, switch view to plain text mode 

after reading all of the available data(the read call already return 0), the activated() signal emit over and over again, and readKbdData() also get invoked. the cpu reached to 98%.!

any idea ?