1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore/QCoreApplication>
#include <QtUniversalInput/QUniversalInput>
#include <QtCore/QDebug>
#include <QVector2D>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
auto input = QUniversalInput::instance();
QObject::connect(input, &QUniversalInput::joyConnectionChanged, [](int joyId, bool connected) {
qDebug() << "joyConnectionChanged!";
qDebug() << "joy" << joyId << "connected:" << connected;
});
QObject::connect(input, &QUniversalInput::joyButtonEvent, [&input](int device, JoyButton button, bool pressed) {
qDebug() << "Device: " << device << "button: " << int(button) << ( pressed ? "pressed" : "released") << "\n";
input->addForce(0, QVector2D(1, 1), 1.0f);
});
QObject::connect(input, &QUniversalInput::joyAxisEvent, [](int device, JoyAxis axis, float value) {
qDebug() << "Device: " << device << "axis: " << int(axis) << "value: " << value << "\n";
});
qDebug() << "hello, this is a console joystick monitor";
return app.exec();
}
|