I could probably have done something like that george++, but then I would have to re-implement / wrap a lot of already existing code in AGK.
So I figured it out (if anyone need this at some point):
We need a new
QAbstractNativeEventFilter:
class MyEventFilter : public QAbstractNativeEventFilter
{
public:
MyEventFilter(QWidget* _widget) { agkWidget = _widget; }
QWidget* agkWidget = NULL;
bool nativeEventFilter(const QByteArray &eventType, void *message, long* res) override
{
if(agkWidget->underMouse()){
if (eventType == "windows_generic_MSG") {
res = (long*)WndProc(((MSG*)message)->hwnd, ((MSG*)message)->message, ((MSG*)message)->wParam, ((MSG*)message)->lParam);
}
}
return false;
}
};
The
WndProc function called from nativeEventFilter() is the AppGameKit function taking care of all key/mouse input. Its in the Core.cpp file of the AppGameKit template project.
So just make this function available for event filter.
Then in the main.cpp:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
AGK_QT w;
w.show();
a.installNativeEventFilter(new MyEventFilter(w.getAgkWidget()));
return a.exec();
}
Another thing I struggled with was that my AppGameKit loop was iterating without iterating the Qt loop. So in the AGK's Core.cpp, in the main function, qApp->processEvents() need to be called AFTER App.Loop().