Yes. Here it is:
main.cpp:
#include <QtGui/QApplication>
#include <QObject>
#include "widget.h"
#include "qapp.h"
int main(int argc, char *argv[])
{
//QApp *app = qobject_cast<QApp>(qApp);
QApp a(argc, argv);
Widget w;
w.show();
QObject::connect(&a,
SIGNAL(mouseCoord
(int,
int,
int,
int,
int)),
&w,SLOT(mouseCoord(int, int, int, int, int)));
return a.exec();
}
#include <QtGui/QApplication>
#include <QObject>
#include "widget.h"
#include "qapp.h"
int main(int argc, char *argv[])
{
//QApp *app = qobject_cast<QApp>(qApp);
QApp a(argc, argv);
Widget w;
w.show();
QObject::connect(&a,SIGNAL(mouseCoord(int, int, int, int, int)),
&w,SLOT(mouseCoord(int, int, int, int, int)));
return a.exec();
}
To copy to clipboard, switch view to plain text mode
qapp.cpp:
extern "C"{
#include "raw_mouse.h"
}
#include "qapp.h"
#include <QDebug>
#include <QAbstractEventDispatcher>
#define WM_INPUT 0x00FF
QApp::QApp(int & argc, char ** argv) :
{
qDebug() << init_raw_mouse(1, 0, 1);
qDebug() << raw_mouse_count();
}
bool QApp::eventFilter(void *msg)
{
MSG *mess;
mess = (MSG*)msg;
//qDebug() << mess->message;
switch(mess->message){
case WM_INPUT:
{
add_to_raw_mouse_x_and_y((HANDLE)mess->lParam);
for (int i = 0; i < raw_mouse_count(); i++){
emit mouseCoord(get_raw_mouse_x_delta(i), get_raw_mouse_y_delta(i),
is_raw_mouse_button_pressed(i, 0), is_raw_mouse_button_pressed(i, 1), is_raw_mouse_button_pressed(i, 2));
}
}
return true;
}
return false;
}
extern "C"{
#include "raw_mouse.h"
}
#include "qapp.h"
#include <QDebug>
#include <QAbstractEventDispatcher>
#define WM_INPUT 0x00FF
QApp::QApp(int & argc, char ** argv) :
QApplication(argc,argv)
{
qDebug() << init_raw_mouse(1, 0, 1);
qDebug() << raw_mouse_count();
QAbstractEventDispatcher::instance(0)->setEventFilter(eventFilter);
}
bool QApp::eventFilter(void *msg)
{
MSG *mess;
mess = (MSG*)msg;
//qDebug() << mess->message;
switch(mess->message){
case WM_INPUT:
{
add_to_raw_mouse_x_and_y((HANDLE)mess->lParam);
for (int i = 0; i < raw_mouse_count(); i++){
emit mouseCoord(get_raw_mouse_x_delta(i), get_raw_mouse_y_delta(i),
is_raw_mouse_button_pressed(i, 0), is_raw_mouse_button_pressed(i, 1), is_raw_mouse_button_pressed(i, 2));
}
}
return true;
}
return false;
}
To copy to clipboard, switch view to plain text mode
app.h:
#ifndef QAPP_H
#define QAPP_H
#include <QApplication>
{
Q_OBJECT
public:
explicit QApp(int & argc, char ** argv );
//bool winEventFilter(MSG *message, long *result);
static bool eventFilter(void *msg);
private:
signals:
void mouseCoord(int x, int y, int btn1, int btn2, int btn3);
public slots:
};
#endif // QAPP_H
#ifndef QAPP_H
#define QAPP_H
#include <QApplication>
class QApp : public QApplication
{
Q_OBJECT
public:
explicit QApp(int & argc, char ** argv );
//bool winEventFilter(MSG *message, long *result);
static bool eventFilter(void *msg);
private:
signals:
void mouseCoord(int x, int y, int btn1, int btn2, int btn3);
public slots:
};
#endif // QAPP_H
To copy to clipboard, switch view to plain text mode
Bookmarks