tags:

views:

17

answers:

0

Hello,

I'm working on an embedded software in QT that uses LIRC to handle RC (Remote Control) key presses.

I managed to map all the RC keys so directFB is getting keypresses like these:

00000000000011b7 00 MENU
00000000000011a7 00 EXIT
0000000000001193 00 RED

I've created a QT class that uses sockets to grab LIRC keys and generate KeyPressEvents through QApplication::postEvent for all the other QT widgets and alike. It works fine for "regular" keys, but it is not working for keys that emulate the ESC, F1, F2 and other "special" keys.

I could make it work using signals and slots (check it bellow), however, it's a harsh since I need to connect and disconnect the signals for active Windows (Widgets) all the time. I refuse to believe there is no better solution for that.

Does anyone know how to generate events for those special keys?

Following a code snippet of the LIRC socket handler method:

QKeyEvent *event = NULL;
int emitKey = 0;

if (strstr(code, "MENU"))
{
    cout << "MENU";
    event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Menu, Qt::NoModifier, "Menu", 0);
    emitKey = Qt::Key_Menu;
}
else if (strstr(code, "EXIT"))
{
    cout << "EXIT";
    event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier, "Exit", 0);
    emitKey = Qt::Key_Escape;
}
else if (strstr(code, "RED"))
{
    cout << "RED";
    event = new QKeyEvent(QEvent::KeyPress, Qt::Key_F1, Qt::NoModifier, "Red", 0);
    emitKey = Qt::Key_F1;
}

// All other keys, including ...

if (event)
{
    cout << ": POSTED!" << endl;
    event->ignore();
    QApplication::postEvent(this, event);
    emit k_output(emitKey);
}

The Menu key event is reaching the active window's keyEvent method. The others (EXIT, RED) is not...

Thanks very much for your help.