Question

I have a very simple Qt 4.8.4 embedded Linux app that runs on ARM. It basically just has an eventFilter installed at the qApp level. I have a Power Button on my board that emits 'code 116 (Power)' when pressed.

Here is the output from evtest:

# ./evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "twl4030_pwrbutton"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 116 (Power)
Testing ... (interrupt to exit)
Event: time 1370431888.296539, type 1 (Key), code 116 (Power), value 1
Event: time 1370431888.296539, -------------- Report Sync ------------
Event: time 1370431888.453338, type 1 (Key), code 116 (Power), value 0
Event: time 1370431888.453338, -------------- Report Sync ------------
Event: time 1370431890.855651, type 1 (Key), code 116 (Power), value 1
Event: time 1370431890.855682, -------------- Report Sync ------------
Event: time 1370431891.026885, type 1 (Key), code 116 (Power), value 0
Event: time 1370431891.026885, -------------- Report Sync ------------

Each time I press the button I get some output:

# cat platform-omap_i2c.1-platform-twl4030_pwrbutton-event 
�#�Qwat�#�Qwa�#�QY= t�#�QY=

I launch my app with '-qws' and my eventFilter is printing every event my Qt App gets:

// Install the event filter
bool TestApp::eventFilter( QObject *obj, QEvent *ev ) {

    qDebug() << ev->type();

The Event filter gets other touch and keypress events but never the (116) Power. So how do I get the Qt App to receive this event from Linux? Thanks!

UPDATE:

I've also implemented a filter that will intercept and report all events that the Qt QWS server receives. Here is my header file:

#include <QApplication>
#include <QDebug>

/// The QWS embedded server for OS events
#include <QWSServer>

/// For investigation key events
#include <QWSServer>
#include <QWSMouseHandler>
#include <QWSEvent>

class Filter : public QApplication
{
public:

Here is my implementation:

#include "filter.h"

bool Filter::qwsEventFilter(QWSEvent *e)
{

    qDebug() << "NEW TYPE: " << e->type;

}

        Filter(int &argc, char **argv ) : QApplication( argc, argv ) {};

        bool qwsEventFilter(QWSEvent * event);

    };

And here is main.c:

#include <QApplication>
#include "filter.h"

int main(int argc, char *argv[])
{

    Filter a(argc, argv);

    return a.exec();
}

I though that maybe QWS was gobbling up the power press event but after doing this qwsFilter I see that QWS is not receiving the Power Events at all!

Était-ce utile?

La solution

Actually, setting the environment variable to the proper keypad input allows me to capture the power event.

So doing this:

export QWS_KEYBOARD=linuxinput:/dev/input/event2

Rather than this:

export QWS_KEYBOARD=linuxinput:/dev/input/keypad

Allows me to capture and use the power button.

Furthermore you can capture multiple inputs like this:

export QWS_KEYBOARD="linuxinput:/dev/input/keypad linuxinput:/dev/input/event2"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top