diff options
author | Andy Nichols <andy.nichols@digia.com> | 2015-05-11 16:36:50 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@digia.com> | 2015-05-11 16:48:38 +0200 |
commit | 298e4e678b2fa6dc62f5a90e0b27caa954aaed66 (patch) | |
tree | 9cceb057bca8d16946b2c3df788dce81ccf97159 /examples |
Initial public release of Qt Gamepad module
Qt Gamepad is a Qt 5 module that adds support for using Gamepad devices
(like the XBox 360 controller) inside of Qt applications.
Change-Id: I5dff629dcfdcc5625a90274017b8e97f45e8fd30
Diffstat (limited to 'examples')
45 files changed, 1300 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro new file mode 100644 index 0000000..4461e4d --- /dev/null +++ b/examples/examples.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs + +SUBDIRS += simple \ + mouseItem + +qtHaveModule(quick) { + SUBDIRS += quickGamepad \ + keyNavigation +} diff --git a/examples/keyNavigation/deployment.pri b/examples/keyNavigation/deployment.pri new file mode 100644 index 0000000..839b3b5 --- /dev/null +++ b/examples/keyNavigation/deployment.pri @@ -0,0 +1,23 @@ +android-no-sdk { + target.path = /data/user/qt + export(target.path) + INSTALLS += target +} else:android { + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + export(target.path) + INSTALLS += target +} else:unix { + isEmpty(target.path) { + target.path = /opt/$${TARGET}/bin + export(target.path) + } + INSTALLS += target +} + +export(INSTALLS) diff --git a/examples/keyNavigation/keyNavigation.pro b/examples/keyNavigation/keyNavigation.pro new file mode 100644 index 0000000..1cdc565 --- /dev/null +++ b/examples/keyNavigation/keyNavigation.pro @@ -0,0 +1,13 @@ +TEMPLATE = app + +QT += qml quick widgets + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Default rules for deployment. +include(deployment.pri) diff --git a/examples/keyNavigation/keyNavigation64.png b/examples/keyNavigation/keyNavigation64.png Binary files differnew file mode 100644 index 0000000..707d5c4 --- /dev/null +++ b/examples/keyNavigation/keyNavigation64.png diff --git a/examples/keyNavigation/keyNavigation80.png b/examples/keyNavigation/keyNavigation80.png Binary files differnew file mode 100644 index 0000000..6ad8096 --- /dev/null +++ b/examples/keyNavigation/keyNavigation80.png diff --git a/examples/keyNavigation/main.cpp b/examples/keyNavigation/main.cpp new file mode 100644 index 0000000..188b215 --- /dev/null +++ b/examples/keyNavigation/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); + + return app.exec(); +} diff --git a/examples/keyNavigation/qml.qrc b/examples/keyNavigation/qml.qrc new file mode 100644 index 0000000..69145a8 --- /dev/null +++ b/examples/keyNavigation/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/examples/keyNavigation/qml/main.qml b/examples/keyNavigation/qml/main.qml new file mode 100644 index 0000000..2c4106c --- /dev/null +++ b/examples/keyNavigation/qml/main.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtGamepad 1.0 + +ApplicationWindow { + visible: true + width: 640 + height: 480 + title: qsTr("Gamepad Key Navigation") + + Gamepad { + id: gamepad1 + index: 0 + } + + GamepadKeyNavigation { + id: gamepadKeyNavigation + gamepad: gamepad1 + active: true + buttonYKey: Qt.Key_Y + } + + Text { + text: qsTr("Test key events from Gamepad") + anchors.centerIn: parent + focus: true + Keys.onPressed: { + if (event.key === Qt.Key_Up) { + text = "Key Up Pressed"; + } else if (event.key === Qt.Key_Down) { + text = "Key Down Pressed"; + } else if (event.key === Qt.Key_Right) { + text = "Key Right Pressed"; + } else if (event.key === Qt.Key_Left) { + text = "Key Left Pressed"; + } else if (event.key === Qt.Key_Return) { + text = "Key Return Pressed"; + } else if (event.key === Qt.Key_Back) { + text = "Key Back Pressed"; + } else if (event.key === Qt.Key_Forward) { + text = "Key Forward Pressed"; + } else if (event.key === Qt.Key_Y) { + text = "Key Y Pressed"; + } + } + Keys.onReleased: { + if (event.key === Qt.Key_Up) { + text = "Key Up Released"; + } else if (event.key === Qt.Key_Down) { + text = "Key Down Released"; + } else if (event.key === Qt.Key_Right) { + text = "Key Right Released"; + } else if (event.key === Qt.Key_Left) { + text = "Key Left Released"; + } else if (event.key === Qt.Key_Return) { + text = "Key Return Released"; + } else if (event.key === Qt.Key_Back) { + text = "Key Back Released"; + } else if (event.key === Qt.Key_Forward) { + text = "Key Forward Released"; + } else if (event.key === Qt.Key_Y) { + text = "Key Y Released"; + } + } + } +} diff --git a/examples/mouseItem/deployment.pri b/examples/mouseItem/deployment.pri new file mode 100644 index 0000000..839b3b5 --- /dev/null +++ b/examples/mouseItem/deployment.pri @@ -0,0 +1,23 @@ +android-no-sdk { + target.path = /data/user/qt + export(target.path) + INSTALLS += target +} else:android { + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + export(target.path) + INSTALLS += target +} else:unix { + isEmpty(target.path) { + target.path = /opt/$${TARGET}/bin + export(target.path) + } + INSTALLS += target +} + +export(INSTALLS) diff --git a/examples/mouseItem/main.cpp b/examples/mouseItem/main.cpp new file mode 100644 index 0000000..ab95334 --- /dev/null +++ b/examples/mouseItem/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); + + return app.exec(); +} diff --git a/examples/mouseItem/mouseItem.pro b/examples/mouseItem/mouseItem.pro new file mode 100644 index 0000000..1cdc565 --- /dev/null +++ b/examples/mouseItem/mouseItem.pro @@ -0,0 +1,13 @@ +TEMPLATE = app + +QT += qml quick widgets + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Default rules for deployment. +include(deployment.pri) diff --git a/examples/mouseItem/mouseItem64.png b/examples/mouseItem/mouseItem64.png Binary files differnew file mode 100644 index 0000000..707d5c4 --- /dev/null +++ b/examples/mouseItem/mouseItem64.png diff --git a/examples/mouseItem/mouseItem80.png b/examples/mouseItem/mouseItem80.png Binary files differnew file mode 100644 index 0000000..6ad8096 --- /dev/null +++ b/examples/mouseItem/mouseItem80.png diff --git a/examples/mouseItem/qml.qrc b/examples/mouseItem/qml.qrc new file mode 100644 index 0000000..69145a8 --- /dev/null +++ b/examples/mouseItem/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/examples/mouseItem/qml/main.qml b/examples/mouseItem/qml/main.qml new file mode 100644 index 0000000..4ab1f8a --- /dev/null +++ b/examples/mouseItem/qml/main.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtGamepad 1.0 + +ApplicationWindow { + visible: true + width: 640 + height: 480 + title: qsTr("Hello World") + + Gamepad { + id: gamepad1 + index: 0 + + onButtonAChanged: { + if (value == true) { + gamepadMouse.mouseButtonPressed(Qt.LeftButton); + console.log("fake clicked qt: " + gamepadMouse.mousePosition.x + "," + gamepadMouse.mousePosition.y); + } else { + gamepadMouse.mouseButtonReleased(Qt.LeftButton); + } + } + } + + GamepadMouseItem { + id: gamepadMouse + anchors.fill: parent + gamepad: gamepad1 + active: true + + Rectangle { + id: cursor + width: 4 + height: 4 + x: gamepadMouse.mousePosition.x + y: gamepadMouse.mousePosition.y + color: "red" + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + console.log("clicked qt: " + mouse.x + "," + mouse.y); + } + } +} diff --git a/examples/quickGamepad/deployment.pri b/examples/quickGamepad/deployment.pri new file mode 100644 index 0000000..839b3b5 --- /dev/null +++ b/examples/quickGamepad/deployment.pri @@ -0,0 +1,23 @@ +android-no-sdk { + target.path = /data/user/qt + export(target.path) + INSTALLS += target +} else:android { + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + export(target.path) + INSTALLS += target +} else:unix { + isEmpty(target.path) { + target.path = /opt/$${TARGET}/bin + export(target.path) + } + INSTALLS += target +} + +export(INSTALLS) diff --git a/examples/quickGamepad/main.cpp b/examples/quickGamepad/main.cpp new file mode 100644 index 0000000..188b215 --- /dev/null +++ b/examples/quickGamepad/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); + + return app.exec(); +} diff --git a/examples/quickGamepad/qml.qrc b/examples/quickGamepad/qml.qrc new file mode 100644 index 0000000..d82637e --- /dev/null +++ b/examples/quickGamepad/qml.qrc @@ -0,0 +1,24 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + <file>qml/JoystickViewer.qml</file> + <file>qml/xboxControllerButtonA.png</file> + <file>qml/xboxControllerButtonB.png</file> + <file>qml/xboxControllerButtonX.png</file> + <file>qml/xboxControllerButtonY.png</file> + <file>qml/ButtonImage.qml</file> + <file>qml/xboxControllerBack.png</file> + <file>qml/xboxControllerButtonGuide.png</file> + <file>qml/xboxControllerDPad.png</file> + <file>qml/xboxControllerLeftShoulder.png</file> + <file>qml/xboxControllerLeftThumbstick.png</file> + <file>qml/xboxControllerLeftTrigger.png</file> + <file>qml/xboxControllerRightShoulder.png</file> + <file>qml/xboxControllerRightThumbstick.png</file> + <file>qml/xboxControllerRightTrigger.png</file> + <file>qml/xboxControllerStart.png</file> + <file>qml/LeftThumbstick.qml</file> + <file>qml/RightThumbstick.qml</file> + <file>qml/DPad.qml</file> + </qresource> +</RCC> diff --git a/examples/quickGamepad/qml/ButtonImage.qml b/examples/quickGamepad/qml/ButtonImage.qml new file mode 100644 index 0000000..8057542 --- /dev/null +++ b/examples/quickGamepad/qml/ButtonImage.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +Item { + width: buttonImage.sourceSize.width + height: buttonImage.sourceSize.height + + property alias source: buttonImage.source + property bool active: false + + Image { + id: buttonImage + smooth: true +// visible: !active + } + + Rectangle { + anchors.fill: buttonImage + color: "#14abff" + opacity: 0.6 + radius: 8 + visible: active + } + + // BrightnessContrast { + // anchors.fill: buttonImage + // source: buttonImage + // brightness: 0.5 + // contrast: 0.5 + // visible: active + // } +} diff --git a/examples/quickGamepad/qml/DPad.qml b/examples/quickGamepad/qml/DPad.qml new file mode 100644 index 0000000..d34c953 --- /dev/null +++ b/examples/quickGamepad/qml/DPad.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtGamepad 1.0 +import QtGraphicalEffects 1.0 + +Item { + property Gamepad gamepad + + width: dpadImage.sourceSize.width + height: dpadImage.sourceSize.height + Image { + id: dpadImage + anchors.fill: parent + source: "xboxControllerDPad.png" + } + + Rectangle { + id: upArea + visible: gamepad.buttonUp + color: "#3814abff" + radius: 5 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width * 0.3 + height: parent.height * 0.3 + anchors.topMargin: parent.height * 0.05 + } + Rectangle { + id: downArea + visible: gamepad.buttonDown + color: "#3814abff" + radius: 5 + width: parent.width * 0.3 + height: parent.height * 0.3 + anchors.bottom: parent.bottom + anchors.bottomMargin: parent.height * 0.05 + anchors.horizontalCenter: parent.horizontalCenter + } + Rectangle { + id: leftArea + visible: gamepad.buttonLeft + color: "#3814abff" + radius: 5 + width: parent.width * 0.3 + height: parent.height * 0.3 + anchors.left: parent.left + anchors.leftMargin: parent.width * 0.05 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: rightArea + visible: gamepad.buttonRight + color: "#3814abff" + radius: 5 + width: parent.width * 0.3 + height: parent.height * 0.3 + anchors.right: parent.right + anchors.rightMargin: parent.width * 0.05 + anchors.verticalCenter: parent.verticalCenter + } +} diff --git a/examples/quickGamepad/qml/JoystickViewer.qml b/examples/quickGamepad/qml/JoystickViewer.qml new file mode 100644 index 0000000..da0168e --- /dev/null +++ b/examples/quickGamepad/qml/JoystickViewer.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 100 + height: 100 + + property real xAxisValue: 0 + property real yAxisValue: 0 + + onXAxisValueChanged: { + joystickCanvas.requestPaint(); + } + onYAxisValueChanged: { + joystickCanvas.requestPaint() + } + + Canvas { + id: joystickCanvas + anchors.fill: parent + + onPaint: { + var context = joystickCanvas.getContext("2d") + context.clearRect(0, 0, width, height); + var targetX = (xAxisValue + 1) / 2 * width; + var targetY = (yAxisValue + 1) / 2 * height; + context.fillStyle = "red"; + context.beginPath(); + context.arc(targetX, targetY, 5, 0, 2 * Math.PI, false); + context.closePath(); + context.fill(); + } + } + +} diff --git a/examples/quickGamepad/qml/LeftThumbstick.qml b/examples/quickGamepad/qml/LeftThumbstick.qml new file mode 100644 index 0000000..8ee0db0 --- /dev/null +++ b/examples/quickGamepad/qml/LeftThumbstick.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtGamepad 1.0 + +ButtonImage { + + property Gamepad gamepad + + id: leftStickButton + source: "xboxControllerLeftThumbstick.png" + active: gamepad.buttonL3 + + JoystickViewer { + id: leftJoystick + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: parent.width * (3 / 153) + width: parent.width * (140 / 153) + xAxisValue: gamepad.axisLeftX + yAxisValue: gamepad.axisLeftY + height: width + } +} diff --git a/examples/quickGamepad/qml/RightThumbstick.qml b/examples/quickGamepad/qml/RightThumbstick.qml new file mode 100644 index 0000000..9dfa3de --- /dev/null +++ b/examples/quickGamepad/qml/RightThumbstick.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtGamepad 1.0 + +ButtonImage { + + property Gamepad gamepad + + id: rightStickButton + source: "xboxControllerRightThumbstick.png" + active: gamepad.buttonR3 + + JoystickViewer { + id: rightJoystick + anchors.top: parent.top + anchors.right: parent.right + anchors.margins: parent.width * (3 / 153) + width: parent.width * (140 / 153) + xAxisValue: gamepad.axisRightX + yAxisValue: gamepad.axisRightY + height: width + } +} + diff --git a/examples/quickGamepad/qml/main.qml b/examples/quickGamepad/qml/main.qml new file mode 100644 index 0000000..10b6674 --- /dev/null +++ b/examples/quickGamepad/qml/main.qml @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtGamepad 1.0 + +ApplicationWindow { + id: applicationWindow1 + visible: true + width: 800 + height: 600 + title: qsTr("QtGamepad Example") + + Rectangle { + id: background + color: "#363330" + anchors.fill: parent + + Item { + id: buttonL2Item + height: leftTrigger.height + width: leftTrigger.width + buttonL2Value.width + anchors.left: parent.left + anchors.leftMargin: 8 + anchors.top: parent.top + anchors.topMargin: 8 + + ButtonImage { + id: leftTrigger + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: parent.bottom + source: "xboxControllerLeftTrigger.png" + active: gamepad.buttonL2 != 0 + } + + ProgressBar { + id: buttonL2Value + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: leftTrigger.right + orientation: 0 + value: gamepad.buttonL2 + } + } + ButtonImage { + id: buttonL1 + anchors.left: buttonL2Item.left + anchors.top: buttonL2Item.bottom + anchors.topMargin: 8 + source: "xboxControllerLeftShoulder.png" + active: gamepad.buttonL1 + } + + + Item { + id: buttonR2Item + height: rightTrigger.height + width: rightTrigger.width + buttonR2Value.width + anchors.right: parent.right + anchors.rightMargin: 8 + anchors.top: parent.top + anchors.topMargin: 8 + + ButtonImage { + id: rightTrigger + anchors.top: parent.top + anchors.right: parent.right + anchors.bottom: parent.bottom + source: "xboxControllerRightTrigger.png" + active: gamepad.buttonR2 != 0 + } + + ProgressBar { + id: buttonR2Value + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: rightTrigger.left + orientation: 0 + value: gamepad.buttonR2 + } + } + ButtonImage { + id: buttonR1 + anchors.right: buttonR2Item.right + anchors.top: buttonR2Item.bottom + anchors.topMargin: 8 + source: "xboxControllerRightShoulder.png" + active: gamepad.buttonR1 + } + + Item { + id: centerButtons + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 8 + height: guideButton.height + width: guideButton.width + 16 + backButton.width + startButton.width + ButtonImage { + id: backButton + anchors.verticalCenter: parent.verticalCenter + anchors.right: guideButton.left + anchors.rightMargin: 8 + source: "xboxControllerBack.png" + active: gamepad.buttonSelect + } + ButtonImage { + id: guideButton + anchors.centerIn: parent + source: "xboxControllerButtonGuide.png" + active: gamepad.buttonGuide + } + ButtonImage { + anchors.verticalCenter: parent.verticalCenter + anchors.left: guideButton.right + anchors.leftMargin: 8 + id: startButton + source: "xboxControllerStart.png" + active: gamepad.buttonStart + } + } + + + + + DPad { + id: dPad + gamepad: gamepad + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 8 + } + + Row { + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.margins: 8 + spacing: 16 + + LeftThumbstick { + id: leftThumbstick + gamepad: gamepad + } + + RightThumbstick { + id: rightThumbstick + gamepad: gamepad + } + } + + + Item { + width: 200 + height: 200 + anchors.right: parent.right + anchors.rightMargin: 8 + anchors.bottom: parent.bottom + anchors.bottomMargin: 8 + ButtonImage { + id: buttonA + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + source: "xboxControllerButtonA.png"; + active: gamepad.buttonA + } + ButtonImage { + id: buttonB + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + source: "xboxControllerButtonB.png"; + active: gamepad.buttonB + } + ButtonImage { + id: buttonX + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + source: "xboxControllerButtonX.png"; + active: gamepad.buttonX + } + ButtonImage { + id: buttonY + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + source: "xboxControllerButtonY.png"; + active: gamepad.buttonY + } + } + + } + + + + Gamepad { + id: gamepad + } + +} diff --git a/examples/quickGamepad/qml/xboxControllerBack.png b/examples/quickGamepad/qml/xboxControllerBack.png Binary files differnew file mode 100644 index 0000000..d97972c --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerBack.png diff --git a/examples/quickGamepad/qml/xboxControllerButtonA.png b/examples/quickGamepad/qml/xboxControllerButtonA.png Binary files differnew file mode 100644 index 0000000..271e8c8 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerButtonA.png diff --git a/examples/quickGamepad/qml/xboxControllerButtonB.png b/examples/quickGamepad/qml/xboxControllerButtonB.png Binary files differnew file mode 100644 index 0000000..f1e06b6 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerButtonB.png diff --git a/examples/quickGamepad/qml/xboxControllerButtonGuide.png b/examples/quickGamepad/qml/xboxControllerButtonGuide.png Binary files differnew file mode 100644 index 0000000..287d32b --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerButtonGuide.png diff --git a/examples/quickGamepad/qml/xboxControllerButtonX.png b/examples/quickGamepad/qml/xboxControllerButtonX.png Binary files differnew file mode 100644 index 0000000..8d29281 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerButtonX.png diff --git a/examples/quickGamepad/qml/xboxControllerButtonY.png b/examples/quickGamepad/qml/xboxControllerButtonY.png Binary files differnew file mode 100644 index 0000000..465ac48 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerButtonY.png diff --git a/examples/quickGamepad/qml/xboxControllerDPad.png b/examples/quickGamepad/qml/xboxControllerDPad.png Binary files differnew file mode 100644 index 0000000..efaeb16 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerDPad.png diff --git a/examples/quickGamepad/qml/xboxControllerLeftShoulder.png b/examples/quickGamepad/qml/xboxControllerLeftShoulder.png Binary files differnew file mode 100644 index 0000000..9b084df --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerLeftShoulder.png diff --git a/examples/quickGamepad/qml/xboxControllerLeftThumbstick.png b/examples/quickGamepad/qml/xboxControllerLeftThumbstick.png Binary files differnew file mode 100644 index 0000000..08fbaa2 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerLeftThumbstick.png diff --git a/examples/quickGamepad/qml/xboxControllerLeftTrigger.png b/examples/quickGamepad/qml/xboxControllerLeftTrigger.png Binary files differnew file mode 100644 index 0000000..1fd7324 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerLeftTrigger.png diff --git a/examples/quickGamepad/qml/xboxControllerRightShoulder.png b/examples/quickGamepad/qml/xboxControllerRightShoulder.png Binary files differnew file mode 100644 index 0000000..a22c8ca --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerRightShoulder.png diff --git a/examples/quickGamepad/qml/xboxControllerRightThumbstick.png b/examples/quickGamepad/qml/xboxControllerRightThumbstick.png Binary files differnew file mode 100644 index 0000000..ab95ef5 --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerRightThumbstick.png diff --git a/examples/quickGamepad/qml/xboxControllerRightTrigger.png b/examples/quickGamepad/qml/xboxControllerRightTrigger.png Binary files differnew file mode 100644 index 0000000..717f7ab --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerRightTrigger.png diff --git a/examples/quickGamepad/qml/xboxControllerStart.png b/examples/quickGamepad/qml/xboxControllerStart.png Binary files differnew file mode 100644 index 0000000..709459e --- /dev/null +++ b/examples/quickGamepad/qml/xboxControllerStart.png diff --git a/examples/quickGamepad/quickGamepad.pro b/examples/quickGamepad/quickGamepad.pro new file mode 100644 index 0000000..1cdc565 --- /dev/null +++ b/examples/quickGamepad/quickGamepad.pro @@ -0,0 +1,13 @@ +TEMPLATE = app + +QT += qml quick widgets + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Default rules for deployment. +include(deployment.pri) diff --git a/examples/quickGamepad/quickGamepad64.png b/examples/quickGamepad/quickGamepad64.png Binary files differnew file mode 100644 index 0000000..707d5c4 --- /dev/null +++ b/examples/quickGamepad/quickGamepad64.png diff --git a/examples/quickGamepad/quickGamepad80.png b/examples/quickGamepad/quickGamepad80.png Binary files differnew file mode 100644 index 0000000..6ad8096 --- /dev/null +++ b/examples/quickGamepad/quickGamepad80.png diff --git a/examples/simple/gamepadmonitor.cpp b/examples/simple/gamepadmonitor.cpp new file mode 100644 index 0000000..4883da3 --- /dev/null +++ b/examples/simple/gamepadmonitor.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "gamepadmonitor.h" +#include <QtGamepad/QGamepad> + +#include <QDebug> + +GamepadMonitor::GamepadMonitor(QObject *parent) + : QObject(parent) + , m_gamepad(0) +{ + m_gamepad = new QGamepad(0, this); + connect(m_gamepad, SIGNAL(buttonL2Changed(double)), this, SLOT(printStatusL2())); + connect(m_gamepad, SIGNAL(buttonR2Changed(double)), this, SLOT(printStatusR2())); +} + +GamepadMonitor::~GamepadMonitor() +{ + delete m_gamepad; +} + +void GamepadMonitor::printStatusL2() +{ + qDebug() << "L2: " << m_gamepad->buttonL2(); +} + +void GamepadMonitor::printStatusR2() +{ + qDebug() << "R2: " << m_gamepad->buttonR2(); +} diff --git a/examples/simple/gamepadmonitor.h b/examples/simple/gamepadmonitor.h new file mode 100644 index 0000000..103d8b4 --- /dev/null +++ b/examples/simple/gamepadmonitor.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GAMEPADMONITOR_H +#define GAMEPADMONITOR_H + +#include <QtCore/QObject> +#include <QtCore/QTimer> + +class QGamepad; + +class GamepadMonitor : public QObject +{ + Q_OBJECT +public: + explicit GamepadMonitor(QObject *parent = 0); + ~GamepadMonitor(); + +public slots: + void printStatusL2(); + void printStatusR2(); + +private: + QGamepad *m_gamepad; +}; + +#endif // GAMEPADMONITOR_H diff --git a/examples/simple/main.cpp b/examples/simple/main.cpp new file mode 100644 index 0000000..3bb4818 --- /dev/null +++ b/examples/simple/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QCoreApplication> +#include "gamepadmonitor.h" + +int main(int argc, char **argv) +{ + QCoreApplication application(argc, argv); + + GamepadMonitor monitor; + + return application.exec(); +} diff --git a/examples/simple/simple.pro b/examples/simple/simple.pro new file mode 100644 index 0000000..a9b341f --- /dev/null +++ b/examples/simple/simple.pro @@ -0,0 +1,7 @@ +QT += gamepad + +SOURCES = main.cpp \ + gamepadmonitor.cpp + +HEADERS += \ + gamepadmonitor.h |