From eaf8a9800e81a446e9badaa32be459d0a54ec9b5 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Fri, 13 May 2016 15:11:30 +0300 Subject: Deploy examples to the standard examples directory Examples were using the default Qt Creator generated deployment include which does not have the correct target paths. Task-number: QTBUG-51918 Change-Id: I6d217c6964c2cdab852ea1067bd0adcb6f34534a Reviewed-by: Oswald Buddenhagen --- .../configureButtons/android/AndroidManifest.xml | 56 -- examples/configureButtons/configureButtons.pro | 19 - examples/configureButtons/deployment.pri | 14 - .../doc/images/configuregamepadbuttons-example.png | Bin 20239 -> 0 bytes .../doc/src/configbuttonsexample.qdoc | 35 -- examples/configureButtons/main.cpp | 49 -- examples/configureButtons/main.qml | 617 --------------------- examples/configureButtons/qml.qrc | 5 - examples/examples.pro | 13 +- .../configureButtons/android/AndroidManifest.xml | 56 ++ .../gamepad/configureButtons/configureButtons.pro | 19 + .../doc/images/configuregamepadbuttons-example.png | Bin 0 -> 20239 bytes .../doc/src/configbuttonsexample.qdoc | 35 ++ examples/gamepad/configureButtons/main.cpp | 49 ++ examples/gamepad/configureButtons/main.qml | 617 +++++++++++++++++++++ examples/gamepad/configureButtons/qml.qrc | 5 + examples/gamepad/gamepad.pro | 13 + .../doc/images/keynavigationgamepad-example.png | Bin 0 -> 3812 bytes .../keyNavigation/doc/src/keynaviexample.qdoc | 35 ++ examples/gamepad/keyNavigation/keyNavigation.pro | 13 + examples/gamepad/keyNavigation/keyNavigation64.png | Bin 0 -> 3400 bytes examples/gamepad/keyNavigation/keyNavigation80.png | Bin 0 -> 4945 bytes examples/gamepad/keyNavigation/main.cpp | 52 ++ examples/gamepad/keyNavigation/qml.qrc | 5 + examples/gamepad/keyNavigation/qml/main.qml | 112 ++++ .../mouseItem/doc/src/mouseitemexample.qdoc | 34 ++ examples/gamepad/mouseItem/main.cpp | 53 ++ examples/gamepad/mouseItem/mouseItem.pro | 13 + examples/gamepad/mouseItem/mouseItem64.png | Bin 0 -> 3400 bytes examples/gamepad/mouseItem/mouseItem80.png | Bin 0 -> 4945 bytes examples/gamepad/mouseItem/qml.qrc | 5 + examples/gamepad/mouseItem/qml/main.qml | 93 ++++ .../doc/images/qtquickgamepad-example.png | Bin 0 -> 50662 bytes .../quickGamepad/doc/src/quickgamepadexample.qdoc | 35 ++ examples/gamepad/quickGamepad/main.cpp | 52 ++ examples/gamepad/quickGamepad/qml.qrc | 24 + examples/gamepad/quickGamepad/qml/ButtonImage.qml | 72 +++ examples/gamepad/quickGamepad/qml/DPad.qml | 101 ++++ .../gamepad/quickGamepad/qml/JoystickViewer.qml | 74 +++ .../gamepad/quickGamepad/qml/LeftThumbstick.qml | 62 +++ .../gamepad/quickGamepad/qml/RightThumbstick.qml | 63 +++ examples/gamepad/quickGamepad/qml/main.qml | 238 ++++++++ .../quickGamepad/qml/xboxControllerBack.png | Bin 0 -> 11012 bytes .../quickGamepad/qml/xboxControllerButtonA.png | Bin 0 -> 13764 bytes .../quickGamepad/qml/xboxControllerButtonB.png | Bin 0 -> 13480 bytes .../quickGamepad/qml/xboxControllerButtonGuide.png | Bin 0 -> 37297 bytes .../quickGamepad/qml/xboxControllerButtonX.png | Bin 0 -> 14017 bytes .../quickGamepad/qml/xboxControllerButtonY.png | Bin 0 -> 13911 bytes .../quickGamepad/qml/xboxControllerDPad.png | Bin 0 -> 33024 bytes .../qml/xboxControllerLeftShoulder.png | Bin 0 -> 22224 bytes .../qml/xboxControllerLeftThumbstick.png | Bin 0 -> 28966 bytes .../quickGamepad/qml/xboxControllerLeftTrigger.png | Bin 0 -> 13918 bytes .../qml/xboxControllerRightShoulder.png | Bin 0 -> 21209 bytes .../qml/xboxControllerRightThumbstick.png | Bin 0 -> 29386 bytes .../qml/xboxControllerRightTrigger.png | Bin 0 -> 14152 bytes .../quickGamepad/qml/xboxControllerStart.png | Bin 0 -> 11271 bytes examples/gamepad/quickGamepad/quickGamepad.pro | 13 + examples/gamepad/quickGamepad/quickGamepad64.png | Bin 0 -> 3400 bytes examples/gamepad/quickGamepad/quickGamepad80.png | Bin 0 -> 4945 bytes .../gamepad/simple/android/AndroidManifest.xml | 56 ++ examples/gamepad/simple/doc/src/simpleexample.qdoc | 34 ++ examples/gamepad/simple/gamepadmonitor.cpp | 106 ++++ examples/gamepad/simple/gamepadmonitor.h | 62 +++ examples/gamepad/simple/main.cpp | 51 ++ examples/gamepad/simple/simple.pro | 17 + examples/keyNavigation/deployment.pri | 19 - .../doc/images/keynavigationgamepad-example.png | Bin 3812 -> 0 bytes examples/keyNavigation/doc/src/keynaviexample.qdoc | 35 -- examples/keyNavigation/keyNavigation.pro | 13 - examples/keyNavigation/keyNavigation64.png | Bin 3400 -> 0 bytes examples/keyNavigation/keyNavigation80.png | Bin 4945 -> 0 bytes examples/keyNavigation/main.cpp | 52 -- examples/keyNavigation/qml.qrc | 5 - examples/keyNavigation/qml/main.qml | 112 ---- examples/mouseItem/deployment.pri | 19 - examples/mouseItem/doc/src/mouseitemexample.qdoc | 34 -- examples/mouseItem/main.cpp | 53 -- examples/mouseItem/mouseItem.pro | 13 - examples/mouseItem/mouseItem64.png | Bin 3400 -> 0 bytes examples/mouseItem/mouseItem80.png | Bin 4945 -> 0 bytes examples/mouseItem/qml.qrc | 5 - examples/mouseItem/qml/main.qml | 93 ---- examples/quickGamepad/deployment.pri | 19 - .../doc/images/qtquickgamepad-example.png | Bin 50662 -> 0 bytes .../quickGamepad/doc/src/quickgamepadexample.qdoc | 35 -- examples/quickGamepad/main.cpp | 52 -- examples/quickGamepad/qml.qrc | 24 - examples/quickGamepad/qml/ButtonImage.qml | 72 --- examples/quickGamepad/qml/DPad.qml | 101 ---- examples/quickGamepad/qml/JoystickViewer.qml | 74 --- examples/quickGamepad/qml/LeftThumbstick.qml | 62 --- examples/quickGamepad/qml/RightThumbstick.qml | 63 --- examples/quickGamepad/qml/main.qml | 238 -------- examples/quickGamepad/qml/xboxControllerBack.png | Bin 11012 -> 0 bytes .../quickGamepad/qml/xboxControllerButtonA.png | Bin 13764 -> 0 bytes .../quickGamepad/qml/xboxControllerButtonB.png | Bin 13480 -> 0 bytes .../quickGamepad/qml/xboxControllerButtonGuide.png | Bin 37297 -> 0 bytes .../quickGamepad/qml/xboxControllerButtonX.png | Bin 14017 -> 0 bytes .../quickGamepad/qml/xboxControllerButtonY.png | Bin 13911 -> 0 bytes examples/quickGamepad/qml/xboxControllerDPad.png | Bin 33024 -> 0 bytes .../qml/xboxControllerLeftShoulder.png | Bin 22224 -> 0 bytes .../qml/xboxControllerLeftThumbstick.png | Bin 28966 -> 0 bytes .../quickGamepad/qml/xboxControllerLeftTrigger.png | Bin 13918 -> 0 bytes .../qml/xboxControllerRightShoulder.png | Bin 21209 -> 0 bytes .../qml/xboxControllerRightThumbstick.png | Bin 29386 -> 0 bytes .../qml/xboxControllerRightTrigger.png | Bin 14152 -> 0 bytes examples/quickGamepad/qml/xboxControllerStart.png | Bin 11271 -> 0 bytes examples/quickGamepad/quickGamepad.pro | 13 - examples/quickGamepad/quickGamepad64.png | Bin 3400 -> 0 bytes examples/quickGamepad/quickGamepad80.png | Bin 4945 -> 0 bytes examples/simple/android/AndroidManifest.xml | 56 -- examples/simple/doc/src/simpleexample.qdoc | 34 -- examples/simple/gamepadmonitor.cpp | 106 ---- examples/simple/gamepadmonitor.h | 62 --- examples/simple/main.cpp | 51 -- examples/simple/simple.pro | 14 - 116 files changed, 2270 insertions(+), 2336 deletions(-) delete mode 100644 examples/configureButtons/android/AndroidManifest.xml delete mode 100644 examples/configureButtons/configureButtons.pro delete mode 100644 examples/configureButtons/deployment.pri delete mode 100644 examples/configureButtons/doc/images/configuregamepadbuttons-example.png delete mode 100644 examples/configureButtons/doc/src/configbuttonsexample.qdoc delete mode 100644 examples/configureButtons/main.cpp delete mode 100644 examples/configureButtons/main.qml delete mode 100644 examples/configureButtons/qml.qrc create mode 100644 examples/gamepad/configureButtons/android/AndroidManifest.xml create mode 100644 examples/gamepad/configureButtons/configureButtons.pro create mode 100644 examples/gamepad/configureButtons/doc/images/configuregamepadbuttons-example.png create mode 100644 examples/gamepad/configureButtons/doc/src/configbuttonsexample.qdoc create mode 100644 examples/gamepad/configureButtons/main.cpp create mode 100644 examples/gamepad/configureButtons/main.qml create mode 100644 examples/gamepad/configureButtons/qml.qrc create mode 100644 examples/gamepad/gamepad.pro create mode 100644 examples/gamepad/keyNavigation/doc/images/keynavigationgamepad-example.png create mode 100644 examples/gamepad/keyNavigation/doc/src/keynaviexample.qdoc create mode 100644 examples/gamepad/keyNavigation/keyNavigation.pro create mode 100644 examples/gamepad/keyNavigation/keyNavigation64.png create mode 100644 examples/gamepad/keyNavigation/keyNavigation80.png create mode 100644 examples/gamepad/keyNavigation/main.cpp create mode 100644 examples/gamepad/keyNavigation/qml.qrc create mode 100644 examples/gamepad/keyNavigation/qml/main.qml create mode 100644 examples/gamepad/mouseItem/doc/src/mouseitemexample.qdoc create mode 100644 examples/gamepad/mouseItem/main.cpp create mode 100644 examples/gamepad/mouseItem/mouseItem.pro create mode 100644 examples/gamepad/mouseItem/mouseItem64.png create mode 100644 examples/gamepad/mouseItem/mouseItem80.png create mode 100644 examples/gamepad/mouseItem/qml.qrc create mode 100644 examples/gamepad/mouseItem/qml/main.qml create mode 100644 examples/gamepad/quickGamepad/doc/images/qtquickgamepad-example.png create mode 100644 examples/gamepad/quickGamepad/doc/src/quickgamepadexample.qdoc create mode 100644 examples/gamepad/quickGamepad/main.cpp create mode 100644 examples/gamepad/quickGamepad/qml.qrc create mode 100644 examples/gamepad/quickGamepad/qml/ButtonImage.qml create mode 100644 examples/gamepad/quickGamepad/qml/DPad.qml create mode 100644 examples/gamepad/quickGamepad/qml/JoystickViewer.qml create mode 100644 examples/gamepad/quickGamepad/qml/LeftThumbstick.qml create mode 100644 examples/gamepad/quickGamepad/qml/RightThumbstick.qml create mode 100644 examples/gamepad/quickGamepad/qml/main.qml create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerBack.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerButtonA.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerButtonB.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerButtonGuide.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerButtonX.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerButtonY.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerDPad.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerLeftShoulder.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerLeftThumbstick.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerLeftTrigger.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerRightShoulder.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerRightThumbstick.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerRightTrigger.png create mode 100644 examples/gamepad/quickGamepad/qml/xboxControllerStart.png create mode 100644 examples/gamepad/quickGamepad/quickGamepad.pro create mode 100644 examples/gamepad/quickGamepad/quickGamepad64.png create mode 100644 examples/gamepad/quickGamepad/quickGamepad80.png create mode 100644 examples/gamepad/simple/android/AndroidManifest.xml create mode 100644 examples/gamepad/simple/doc/src/simpleexample.qdoc create mode 100644 examples/gamepad/simple/gamepadmonitor.cpp create mode 100644 examples/gamepad/simple/gamepadmonitor.h create mode 100644 examples/gamepad/simple/main.cpp create mode 100644 examples/gamepad/simple/simple.pro delete mode 100644 examples/keyNavigation/deployment.pri delete mode 100644 examples/keyNavigation/doc/images/keynavigationgamepad-example.png delete mode 100644 examples/keyNavigation/doc/src/keynaviexample.qdoc delete mode 100644 examples/keyNavigation/keyNavigation.pro delete mode 100644 examples/keyNavigation/keyNavigation64.png delete mode 100644 examples/keyNavigation/keyNavigation80.png delete mode 100644 examples/keyNavigation/main.cpp delete mode 100644 examples/keyNavigation/qml.qrc delete mode 100644 examples/keyNavigation/qml/main.qml delete mode 100644 examples/mouseItem/deployment.pri delete mode 100644 examples/mouseItem/doc/src/mouseitemexample.qdoc delete mode 100644 examples/mouseItem/main.cpp delete mode 100644 examples/mouseItem/mouseItem.pro delete mode 100644 examples/mouseItem/mouseItem64.png delete mode 100644 examples/mouseItem/mouseItem80.png delete mode 100644 examples/mouseItem/qml.qrc delete mode 100644 examples/mouseItem/qml/main.qml delete mode 100644 examples/quickGamepad/deployment.pri delete mode 100644 examples/quickGamepad/doc/images/qtquickgamepad-example.png delete mode 100644 examples/quickGamepad/doc/src/quickgamepadexample.qdoc delete mode 100644 examples/quickGamepad/main.cpp delete mode 100644 examples/quickGamepad/qml.qrc delete mode 100644 examples/quickGamepad/qml/ButtonImage.qml delete mode 100644 examples/quickGamepad/qml/DPad.qml delete mode 100644 examples/quickGamepad/qml/JoystickViewer.qml delete mode 100644 examples/quickGamepad/qml/LeftThumbstick.qml delete mode 100644 examples/quickGamepad/qml/RightThumbstick.qml delete mode 100644 examples/quickGamepad/qml/main.qml delete mode 100644 examples/quickGamepad/qml/xboxControllerBack.png delete mode 100644 examples/quickGamepad/qml/xboxControllerButtonA.png delete mode 100644 examples/quickGamepad/qml/xboxControllerButtonB.png delete mode 100644 examples/quickGamepad/qml/xboxControllerButtonGuide.png delete mode 100644 examples/quickGamepad/qml/xboxControllerButtonX.png delete mode 100644 examples/quickGamepad/qml/xboxControllerButtonY.png delete mode 100644 examples/quickGamepad/qml/xboxControllerDPad.png delete mode 100644 examples/quickGamepad/qml/xboxControllerLeftShoulder.png delete mode 100644 examples/quickGamepad/qml/xboxControllerLeftThumbstick.png delete mode 100644 examples/quickGamepad/qml/xboxControllerLeftTrigger.png delete mode 100644 examples/quickGamepad/qml/xboxControllerRightShoulder.png delete mode 100644 examples/quickGamepad/qml/xboxControllerRightThumbstick.png delete mode 100644 examples/quickGamepad/qml/xboxControllerRightTrigger.png delete mode 100644 examples/quickGamepad/qml/xboxControllerStart.png delete mode 100644 examples/quickGamepad/quickGamepad.pro delete mode 100644 examples/quickGamepad/quickGamepad64.png delete mode 100644 examples/quickGamepad/quickGamepad80.png delete mode 100644 examples/simple/android/AndroidManifest.xml delete mode 100644 examples/simple/doc/src/simpleexample.qdoc delete mode 100644 examples/simple/gamepadmonitor.cpp delete mode 100644 examples/simple/gamepadmonitor.h delete mode 100644 examples/simple/main.cpp delete mode 100644 examples/simple/simple.pro (limited to 'examples') diff --git a/examples/configureButtons/android/AndroidManifest.xml b/examples/configureButtons/android/AndroidManifest.xml deleted file mode 100644 index 60f64fb..0000000 --- a/examples/configureButtons/android/AndroidManifest.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/configureButtons/configureButtons.pro b/examples/configureButtons/configureButtons.pro deleted file mode 100644 index 480f8fb..0000000 --- a/examples/configureButtons/configureButtons.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app - -QT += qml quick gamepad - -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) - -DISTFILES += \ - android/AndroidManifest.xml - -ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android - diff --git a/examples/configureButtons/deployment.pri b/examples/configureButtons/deployment.pri deleted file mode 100644 index c89af25..0000000 --- a/examples/configureButtons/deployment.pri +++ /dev/null @@ -1,14 +0,0 @@ -unix:!android { - isEmpty(target.path) { - qnx { - target.path = /tmp/$${TARGET}/bin - } else { - target.path = /opt/$${TARGET}/bin - } - export(target.path) - } - INSTALLS += target -} - -export(INSTALLS) - diff --git a/examples/configureButtons/doc/images/configuregamepadbuttons-example.png b/examples/configureButtons/doc/images/configuregamepadbuttons-example.png deleted file mode 100644 index 408f7a6..0000000 Binary files a/examples/configureButtons/doc/images/configuregamepadbuttons-example.png and /dev/null differ diff --git a/examples/configureButtons/doc/src/configbuttonsexample.qdoc b/examples/configureButtons/doc/src/configbuttonsexample.qdoc deleted file mode 100644 index c2c0517..0000000 --- a/examples/configureButtons/doc/src/configbuttonsexample.qdoc +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\example configureButtons -\ingroup qtgamepad-examples -\title Qt Gamepad Configure Buttons Example -\brief Enables configuring the gamepad buttons -\image configuregamepadbuttons-example.png -\include examples-run.qdocinc -*/ diff --git a/examples/configureButtons/main.cpp b/examples/configureButtons/main.cpp deleted file mode 100644 index f02932b..0000000 --- a/examples/configureButtons/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BogDan Vatra -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Gamepad module -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - - return app.exec(); -} - diff --git a/examples/configureButtons/main.qml b/examples/configureButtons/main.qml deleted file mode 100644 index c93ddf2..0000000 --- a/examples/configureButtons/main.qml +++ /dev/null @@ -1,617 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BogDan Vatra -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Gamepad module -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 -import QtQuick.Window 2.0 -import QtGamepad 1.0 - - -ApplicationWindow { - visible: true - title: qsTr("Configure gamepad") - - Component.onCompleted: { - if (Qt.platform.os === "android") - visibility = Window.Maximized - } - - property Button checkedButton: null - function pressButton(button) - { - if (checkedButton !== null && button !== checkedButton) - checkedButton.checked = false; - checkedButton = button - } - - Gamepad { - id: gamepad - deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 - onDeviceIdChanged: GamepadManager.setCancelConfigureButton(deviceId, GamepadManager.ButtonStart); - } - - Connections { - target: GamepadManager - onButtonConfigured: pressButton(null) - onAxisConfigured: pressButton(null) - onConfigurationCanceled: pressButton(null) - } - - ColumnLayout { - anchors.fill: parent - - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Connected gamepads") - } - ComboBox { - model: GamepadManager.connectedGamepads - onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]] - } - } - - Text { - Layout.fillWidth: true - text: qsTr("Start button cancel's current configuration") - } - - RowLayout { - Layout.fillWidth: true - Layout.fillHeight: true - GroupBox { - title: qsTr("Configure Gamepad Buttons") - Layout.fillWidth: true - Layout.fillHeight: true - - ColumnLayout { - anchors.fill: parent - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonA") - horizontalAlignment: Text.AlignRight - } - - Text { - text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonA); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonB") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonB); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonX") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonX); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonY") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonY); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonStart") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonStart); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("ButtonSelect") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonSelect); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button L1") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL1); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button R1") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR1); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button L2") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL2); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button R2") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR2); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button L3") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL3); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button R3") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR3); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Up") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonUp); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Down") - horizontalAlignment: Text.AlignRight - } - Text { - text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP") - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonDown ); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Left") - horizontalAlignment: Text.AlignRight - } - Text { - Layout.fillWidth: true - text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonLeft); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Right") - horizontalAlignment: Text.AlignRight - } - Text { - Layout.fillWidth: true - text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonRight); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Center") - horizontalAlignment: Text.AlignRight - } - Text { - Layout.fillWidth: true - text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonCenter); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("Button Guide") - horizontalAlignment: Text.AlignRight - } - Text { - Layout.fillWidth: true - text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP") - horizontalAlignment: Text.AlignHCenter - } - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonGuide); - } - } - } - } - } - GroupBox { - title: qsTr("Gamepad Axies") - Layout.fillWidth: true - Layout.fillHeight: true - - ColumnLayout { - anchors.fill: parent - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisLeftX") - horizontalAlignment: Text.AlignRight - } - - Text { - text: gamepad.axisLeftX - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftX); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisLeftY") - horizontalAlignment: Text.AlignRight - } - - Text { - text: gamepad.axisLeftY - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftY); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisRightX") - horizontalAlignment: Text.AlignRight - } - - Text { - text: gamepad.axisRightX - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightX); - } - } - } - RowLayout { - Layout.fillWidth: true - Text { - text: qsTr("AxisRightY") - horizontalAlignment: Text.AlignRight - } - - Text { - text: gamepad.axisRightY - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - } - - Button { - text: qsTr("Configure") - checkable: true - enabled: !checked - onCheckedChanged: { - pressButton(this); - if (checked) - GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightY); - } - } - } - - Item { - Layout.fillHeight: true - } - } - } - } - } -} diff --git a/examples/configureButtons/qml.qrc b/examples/configureButtons/qml.qrc deleted file mode 100644 index 5f6483a..0000000 --- a/examples/configureButtons/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - main.qml - - diff --git a/examples/examples.pro b/examples/examples.pro index aa36739..72acdb0 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,13 +1,2 @@ TEMPLATE = subdirs - -SUBDIRS += simple - -qtHaveModule(quick) { - SUBDIRS += configureButtons - - qtHaveModule(widgets) { - SUBDIRS += quickGamepad \ - keyNavigation \ - mouseItem - } -} +SUBDIRS += gamepad diff --git a/examples/gamepad/configureButtons/android/AndroidManifest.xml b/examples/gamepad/configureButtons/android/AndroidManifest.xml new file mode 100644 index 0000000..60f64fb --- /dev/null +++ b/examples/gamepad/configureButtons/android/AndroidManifest.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/gamepad/configureButtons/configureButtons.pro b/examples/gamepad/configureButtons/configureButtons.pro new file mode 100644 index 0000000..89d6da0 --- /dev/null +++ b/examples/gamepad/configureButtons/configureButtons.pro @@ -0,0 +1,19 @@ +TEMPLATE = app + +QT += qml quick gamepad + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +target.path = $$[QT_INSTALL_EXAMPLES]/gamepad/configureButtons +INSTALLS += target + +DISTFILES += \ + android/AndroidManifest.xml + +ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android + diff --git a/examples/gamepad/configureButtons/doc/images/configuregamepadbuttons-example.png b/examples/gamepad/configureButtons/doc/images/configuregamepadbuttons-example.png new file mode 100644 index 0000000..408f7a6 Binary files /dev/null and b/examples/gamepad/configureButtons/doc/images/configuregamepadbuttons-example.png differ diff --git a/examples/gamepad/configureButtons/doc/src/configbuttonsexample.qdoc b/examples/gamepad/configureButtons/doc/src/configbuttonsexample.qdoc new file mode 100644 index 0000000..c2c0517 --- /dev/null +++ b/examples/gamepad/configureButtons/doc/src/configbuttonsexample.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\example configureButtons +\ingroup qtgamepad-examples +\title Qt Gamepad Configure Buttons Example +\brief Enables configuring the gamepad buttons +\image configuregamepadbuttons-example.png +\include examples-run.qdocinc +*/ diff --git a/examples/gamepad/configureButtons/main.cpp b/examples/gamepad/configureButtons/main.cpp new file mode 100644 index 0000000..f02932b --- /dev/null +++ b/examples/gamepad/configureButtons/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 BogDan Vatra +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} + diff --git a/examples/gamepad/configureButtons/main.qml b/examples/gamepad/configureButtons/main.qml new file mode 100644 index 0000000..c93ddf2 --- /dev/null +++ b/examples/gamepad/configureButtons/main.qml @@ -0,0 +1,617 @@ +/**************************************************************************** +** +** Copyright (C) 2015 BogDan Vatra +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Gamepad module +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 +import QtQuick.Window 2.0 +import QtGamepad 1.0 + + +ApplicationWindow { + visible: true + title: qsTr("Configure gamepad") + + Component.onCompleted: { + if (Qt.platform.os === "android") + visibility = Window.Maximized + } + + property Button checkedButton: null + function pressButton(button) + { + if (checkedButton !== null && button !== checkedButton) + checkedButton.checked = false; + checkedButton = button + } + + Gamepad { + id: gamepad + deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 + onDeviceIdChanged: GamepadManager.setCancelConfigureButton(deviceId, GamepadManager.ButtonStart); + } + + Connections { + target: GamepadManager + onButtonConfigured: pressButton(null) + onAxisConfigured: pressButton(null) + onConfigurationCanceled: pressButton(null) + } + + ColumnLayout { + anchors.fill: parent + + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Connected gamepads") + } + ComboBox { + model: GamepadManager.connectedGamepads + onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]] + } + } + + Text { + Layout.fillWidth: true + text: qsTr("Start button cancel's current configuration") + } + + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + GroupBox { + title: qsTr("Configure Gamepad Buttons") + Layout.fillWidth: true + Layout.fillHeight: true + + ColumnLayout { + anchors.fill: parent + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("ButtonA") + horizontalAlignment: Text.AlignRight + } + + Text { + text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonA); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("ButtonB") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonB); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("ButtonX") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonX); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("ButtonY") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonY); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("ButtonStart") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonStart); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("ButtonSelect") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonSelect); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button L1") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL1); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button R1") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR1); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button L2") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL2); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button R2") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR2); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button L3") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonL3); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button R3") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonR3); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button Up") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonUp); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button Down") + horizontalAlignment: Text.AlignRight + } + Text { + text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP") + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonDown ); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button Left") + horizontalAlignment: Text.AlignRight + } + Text { + Layout.fillWidth: true + text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonLeft); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button Right") + horizontalAlignment: Text.AlignRight + } + Text { + Layout.fillWidth: true + text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonRight); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button Center") + horizontalAlignment: Text.AlignRight + } + Text { + Layout.fillWidth: true + text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonCenter); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("Button Guide") + horizontalAlignment: Text.AlignRight + } + Text { + Layout.fillWidth: true + text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP") + horizontalAlignment: Text.AlignHCenter + } + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureButton(gamepad.deviceId, GamepadManager.ButtonGuide); + } + } + } + } + } + GroupBox { + title: qsTr("Gamepad Axies") + Layout.fillWidth: true + Layout.fillHeight: true + + ColumnLayout { + anchors.fill: parent + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("AxisLeftX") + horizontalAlignment: Text.AlignRight + } + + Text { + text: gamepad.axisLeftX + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftX); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("AxisLeftY") + horizontalAlignment: Text.AlignRight + } + + Text { + text: gamepad.axisLeftY + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisLeftY); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("AxisRightX") + horizontalAlignment: Text.AlignRight + } + + Text { + text: gamepad.axisRightX + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightX); + } + } + } + RowLayout { + Layout.fillWidth: true + Text { + text: qsTr("AxisRightY") + horizontalAlignment: Text.AlignRight + } + + Text { + text: gamepad.axisRightY + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + + Button { + text: qsTr("Configure") + checkable: true + enabled: !checked + onCheckedChanged: { + pressButton(this); + if (checked) + GamepadManager.configureAxis(gamepad.deviceId, GamepadManager.AxisRightY); + } + } + } + + Item { + Layout.fillHeight: true + } + } + } + } + } +} diff --git a/examples/gamepad/configureButtons/qml.qrc b/examples/gamepad/configureButtons/qml.qrc new file mode 100644 index 0000000..5f6483a --- /dev/null +++ b/examples/gamepad/configureButtons/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + diff --git a/examples/gamepad/gamepad.pro b/examples/gamepad/gamepad.pro new file mode 100644 index 0000000..aa36739 --- /dev/null +++ b/examples/gamepad/gamepad.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs + +SUBDIRS += simple + +qtHaveModule(quick) { + SUBDIRS += configureButtons + + qtHaveModule(widgets) { + SUBDIRS += quickGamepad \ + keyNavigation \ + mouseItem + } +} diff --git a/examples/gamepad/keyNavigation/doc/images/keynavigationgamepad-example.png b/examples/gamepad/keyNavigation/doc/images/keynavigationgamepad-example.png new file mode 100644 index 0000000..fa2fa1c Binary files /dev/null and b/examples/gamepad/keyNavigation/doc/images/keynavigationgamepad-example.png differ diff --git a/examples/gamepad/keyNavigation/doc/src/keynaviexample.qdoc b/examples/gamepad/keyNavigation/doc/src/keynaviexample.qdoc new file mode 100644 index 0000000..4226438 --- /dev/null +++ b/examples/gamepad/keyNavigation/doc/src/keynaviexample.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\example keyNavigation +\ingroup qtgamepad-examples +\title Qt Gamepad Key Navigation Example +\brief Demonstrates how to use navigation keys on the gamepad. +\image keynavigationgamepad-example.png +\include examples-run.qdocinc +*/ diff --git a/examples/gamepad/keyNavigation/keyNavigation.pro b/examples/gamepad/keyNavigation/keyNavigation.pro new file mode 100644 index 0000000..6091e39 --- /dev/null +++ b/examples/gamepad/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 = + +target.path = $$[QT_INSTALL_EXAMPLES]/gamepad/keyNavigation +INSTALLS += target diff --git a/examples/gamepad/keyNavigation/keyNavigation64.png b/examples/gamepad/keyNavigation/keyNavigation64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/gamepad/keyNavigation/keyNavigation64.png differ diff --git a/examples/gamepad/keyNavigation/keyNavigation80.png b/examples/gamepad/keyNavigation/keyNavigation80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/gamepad/keyNavigation/keyNavigation80.png differ diff --git a/examples/gamepad/keyNavigation/main.cpp b/examples/gamepad/keyNavigation/main.cpp new file mode 100644 index 0000000..188b215 --- /dev/null +++ b/examples/gamepad/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 +#include + +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/gamepad/keyNavigation/qml.qrc b/examples/gamepad/keyNavigation/qml.qrc new file mode 100644 index 0000000..69145a8 --- /dev/null +++ b/examples/gamepad/keyNavigation/qml.qrc @@ -0,0 +1,5 @@ + + + qml/main.qml + + diff --git a/examples/gamepad/keyNavigation/qml/main.qml b/examples/gamepad/keyNavigation/qml/main.qml new file mode 100644 index 0000000..d58bfc5 --- /dev/null +++ b/examples/gamepad/keyNavigation/qml/main.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 + deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 + } + + Connections { + target: GamepadManager + onGamepadConnected: gamepad1.deviceId = deviceId + } + + 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/gamepad/mouseItem/doc/src/mouseitemexample.qdoc b/examples/gamepad/mouseItem/doc/src/mouseitemexample.qdoc new file mode 100644 index 0000000..80f8357 --- /dev/null +++ b/examples/gamepad/mouseItem/doc/src/mouseitemexample.qdoc @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\example mouseItem +\ingroup qtgamepad-examples +\title Qt Gamepad Mouse Item Example +\brief Depicts joystick movement using a pointer. +\include examples-run.qdocinc +*/ diff --git a/examples/gamepad/mouseItem/main.cpp b/examples/gamepad/mouseItem/main.cpp new file mode 100644 index 0000000..ab95334 --- /dev/null +++ b/examples/gamepad/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 +#include + +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/gamepad/mouseItem/mouseItem.pro b/examples/gamepad/mouseItem/mouseItem.pro new file mode 100644 index 0000000..05f1c2c --- /dev/null +++ b/examples/gamepad/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 = + +target.path = $$[QT_INSTALL_EXAMPLES]/gamepad/mouseItem +INSTALLS += target diff --git a/examples/gamepad/mouseItem/mouseItem64.png b/examples/gamepad/mouseItem/mouseItem64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/gamepad/mouseItem/mouseItem64.png differ diff --git a/examples/gamepad/mouseItem/mouseItem80.png b/examples/gamepad/mouseItem/mouseItem80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/gamepad/mouseItem/mouseItem80.png differ diff --git a/examples/gamepad/mouseItem/qml.qrc b/examples/gamepad/mouseItem/qml.qrc new file mode 100644 index 0000000..69145a8 --- /dev/null +++ b/examples/gamepad/mouseItem/qml.qrc @@ -0,0 +1,5 @@ + + + qml/main.qml + + diff --git a/examples/gamepad/mouseItem/qml/main.qml b/examples/gamepad/mouseItem/qml/main.qml new file mode 100644 index 0000000..4c05e90 --- /dev/null +++ b/examples/gamepad/mouseItem/qml/main.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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") + + Connections { + target: GamepadManager + onGamepadConnected: gamepad1.deviceId = deviceId + } + + Gamepad { + id: gamepad1 + deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 + + 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/gamepad/quickGamepad/doc/images/qtquickgamepad-example.png b/examples/gamepad/quickGamepad/doc/images/qtquickgamepad-example.png new file mode 100644 index 0000000..9f46e4d Binary files /dev/null and b/examples/gamepad/quickGamepad/doc/images/qtquickgamepad-example.png differ diff --git a/examples/gamepad/quickGamepad/doc/src/quickgamepadexample.qdoc b/examples/gamepad/quickGamepad/doc/src/quickgamepadexample.qdoc new file mode 100644 index 0000000..b96c419 --- /dev/null +++ b/examples/gamepad/quickGamepad/doc/src/quickgamepadexample.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\example quickGamepad +\ingroup qtgamepad-examples +\title Qt Gamepad Qt Quick Example +\brief Demonstrates how to interact with the gamepad using QML. +\image qtquickgamepad-example.png +\include examples-run.qdocinc +*/ diff --git a/examples/gamepad/quickGamepad/main.cpp b/examples/gamepad/quickGamepad/main.cpp new file mode 100644 index 0000000..188b215 --- /dev/null +++ b/examples/gamepad/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 +#include + +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/gamepad/quickGamepad/qml.qrc b/examples/gamepad/quickGamepad/qml.qrc new file mode 100644 index 0000000..d82637e --- /dev/null +++ b/examples/gamepad/quickGamepad/qml.qrc @@ -0,0 +1,24 @@ + + + qml/main.qml + qml/JoystickViewer.qml + qml/xboxControllerButtonA.png + qml/xboxControllerButtonB.png + qml/xboxControllerButtonX.png + qml/xboxControllerButtonY.png + qml/ButtonImage.qml + qml/xboxControllerBack.png + qml/xboxControllerButtonGuide.png + qml/xboxControllerDPad.png + qml/xboxControllerLeftShoulder.png + qml/xboxControllerLeftThumbstick.png + qml/xboxControllerLeftTrigger.png + qml/xboxControllerRightShoulder.png + qml/xboxControllerRightThumbstick.png + qml/xboxControllerRightTrigger.png + qml/xboxControllerStart.png + qml/LeftThumbstick.qml + qml/RightThumbstick.qml + qml/DPad.qml + + diff --git a/examples/gamepad/quickGamepad/qml/ButtonImage.qml b/examples/gamepad/quickGamepad/qml/ButtonImage.qml new file mode 100644 index 0000000..8057542 --- /dev/null +++ b/examples/gamepad/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/gamepad/quickGamepad/qml/DPad.qml b/examples/gamepad/quickGamepad/qml/DPad.qml new file mode 100644 index 0000000..d34c953 --- /dev/null +++ b/examples/gamepad/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/gamepad/quickGamepad/qml/JoystickViewer.qml b/examples/gamepad/quickGamepad/qml/JoystickViewer.qml new file mode 100644 index 0000000..da0168e --- /dev/null +++ b/examples/gamepad/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/gamepad/quickGamepad/qml/LeftThumbstick.qml b/examples/gamepad/quickGamepad/qml/LeftThumbstick.qml new file mode 100644 index 0000000..8ee0db0 --- /dev/null +++ b/examples/gamepad/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/gamepad/quickGamepad/qml/RightThumbstick.qml b/examples/gamepad/quickGamepad/qml/RightThumbstick.qml new file mode 100644 index 0000000..9dfa3de --- /dev/null +++ b/examples/gamepad/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/gamepad/quickGamepad/qml/main.qml b/examples/gamepad/quickGamepad/qml/main.qml new file mode 100644 index 0000000..049e72b --- /dev/null +++ b/examples/gamepad/quickGamepad/qml/main.qml @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** 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 + } + } + + } + + Connections { + target: GamepadManager + onGamepadConnected: gamepad.deviceId = deviceId + } + + Gamepad { + id: gamepad + deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 + } +} diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerBack.png b/examples/gamepad/quickGamepad/qml/xboxControllerBack.png new file mode 100644 index 0000000..d97972c Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerBack.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerButtonA.png b/examples/gamepad/quickGamepad/qml/xboxControllerButtonA.png new file mode 100644 index 0000000..271e8c8 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerButtonA.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerButtonB.png b/examples/gamepad/quickGamepad/qml/xboxControllerButtonB.png new file mode 100644 index 0000000..f1e06b6 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerButtonB.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerButtonGuide.png b/examples/gamepad/quickGamepad/qml/xboxControllerButtonGuide.png new file mode 100644 index 0000000..287d32b Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerButtonGuide.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerButtonX.png b/examples/gamepad/quickGamepad/qml/xboxControllerButtonX.png new file mode 100644 index 0000000..8d29281 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerButtonX.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerButtonY.png b/examples/gamepad/quickGamepad/qml/xboxControllerButtonY.png new file mode 100644 index 0000000..465ac48 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerButtonY.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerDPad.png b/examples/gamepad/quickGamepad/qml/xboxControllerDPad.png new file mode 100644 index 0000000..efaeb16 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerDPad.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerLeftShoulder.png b/examples/gamepad/quickGamepad/qml/xboxControllerLeftShoulder.png new file mode 100644 index 0000000..9b084df Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerLeftShoulder.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerLeftThumbstick.png b/examples/gamepad/quickGamepad/qml/xboxControllerLeftThumbstick.png new file mode 100644 index 0000000..08fbaa2 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerLeftThumbstick.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerLeftTrigger.png b/examples/gamepad/quickGamepad/qml/xboxControllerLeftTrigger.png new file mode 100644 index 0000000..1fd7324 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerLeftTrigger.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerRightShoulder.png b/examples/gamepad/quickGamepad/qml/xboxControllerRightShoulder.png new file mode 100644 index 0000000..a22c8ca Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerRightShoulder.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerRightThumbstick.png b/examples/gamepad/quickGamepad/qml/xboxControllerRightThumbstick.png new file mode 100644 index 0000000..ab95ef5 Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerRightThumbstick.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerRightTrigger.png b/examples/gamepad/quickGamepad/qml/xboxControllerRightTrigger.png new file mode 100644 index 0000000..717f7ab Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerRightTrigger.png differ diff --git a/examples/gamepad/quickGamepad/qml/xboxControllerStart.png b/examples/gamepad/quickGamepad/qml/xboxControllerStart.png new file mode 100644 index 0000000..709459e Binary files /dev/null and b/examples/gamepad/quickGamepad/qml/xboxControllerStart.png differ diff --git a/examples/gamepad/quickGamepad/quickGamepad.pro b/examples/gamepad/quickGamepad/quickGamepad.pro new file mode 100644 index 0000000..a310dc9 --- /dev/null +++ b/examples/gamepad/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 = + +target.path = $$[QT_INSTALL_EXAMPLES]/gamepad/quickGamepad +INSTALLS += target diff --git a/examples/gamepad/quickGamepad/quickGamepad64.png b/examples/gamepad/quickGamepad/quickGamepad64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/gamepad/quickGamepad/quickGamepad64.png differ diff --git a/examples/gamepad/quickGamepad/quickGamepad80.png b/examples/gamepad/quickGamepad/quickGamepad80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/gamepad/quickGamepad/quickGamepad80.png differ diff --git a/examples/gamepad/simple/android/AndroidManifest.xml b/examples/gamepad/simple/android/AndroidManifest.xml new file mode 100644 index 0000000..bdf824d --- /dev/null +++ b/examples/gamepad/simple/android/AndroidManifest.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/gamepad/simple/doc/src/simpleexample.qdoc b/examples/gamepad/simple/doc/src/simpleexample.qdoc new file mode 100644 index 0000000..67bb07b --- /dev/null +++ b/examples/gamepad/simple/doc/src/simpleexample.qdoc @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\example simple +\ingroup qtgamepad-examples +\title Qt Gamepad Simple Example +\brief A simple example demonstrating the APIs in use. +\include examples-run.qdocinc +*/ diff --git a/examples/gamepad/simple/gamepadmonitor.cpp b/examples/gamepad/simple/gamepadmonitor.cpp new file mode 100644 index 0000000..d77b7a7 --- /dev/null +++ b/examples/gamepad/simple/gamepadmonitor.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 + +#include + +GamepadMonitor::GamepadMonitor(QObject *parent) + : QObject(parent) + , m_gamepad(0) +{ + auto gamepads = QGamepadManager::instance()->connectedGamepads(); + if (gamepads.isEmpty()) { + return; + } + + m_gamepad = new QGamepad(*gamepads.begin(), this); + connect(m_gamepad, &QGamepad::axisLeftXChanged, this, [](double value){ + qDebug() << "Left X" << value; + }); + connect(m_gamepad, &QGamepad::axisLeftYChanged, this, [](double value){ + qDebug() << "Left Y" << value; + }); + connect(m_gamepad, &QGamepad::axisRightXChanged, this, [](double value){ + qDebug() << "Right X" << value; + }); + connect(m_gamepad, &QGamepad::axisRightYChanged, this, [](double value){ + qDebug() << "Right Y" << value; + }); + connect(m_gamepad, &QGamepad::buttonAChanged, this, [](bool pressed){ + qDebug() << "Button A" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonBChanged, this, [](bool pressed){ + qDebug() << "Button B" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonXChanged, this, [](bool pressed){ + qDebug() << "Button X" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonYChanged, this, [](bool pressed){ + qDebug() << "Button Y" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonL1Changed, this, [](bool pressed){ + qDebug() << "Button L1" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonR1Changed, this, [](bool pressed){ + qDebug() << "Button R1" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonL2Changed, this, [](double value){ + qDebug() << "Button L2: " << value; + }); + connect(m_gamepad, &QGamepad::buttonR2Changed, this, [](double value){ + qDebug() << "Button R2: " << value; + }); + connect(m_gamepad, &QGamepad::buttonSelectChanged, this, [](bool pressed){ + qDebug() << "Button Select" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonStartChanged, this, [](bool pressed){ + qDebug() << "Button Start" << pressed; + }); + connect(m_gamepad, &QGamepad::buttonGuideChanged, this, [](bool pressed){ + qDebug() << "Button Guide" << pressed; + }); +} + +GamepadMonitor::~GamepadMonitor() +{ + delete m_gamepad; +} diff --git a/examples/gamepad/simple/gamepadmonitor.h b/examples/gamepad/simple/gamepadmonitor.h new file mode 100644 index 0000000..8c3fb4a --- /dev/null +++ b/examples/gamepad/simple/gamepadmonitor.h @@ -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$ +** +****************************************************************************/ + +#ifndef GAMEPADMONITOR_H +#define GAMEPADMONITOR_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QGamepad; +QT_END_NAMESPACE + +class GamepadMonitor : public QObject +{ + Q_OBJECT +public: + explicit GamepadMonitor(QObject *parent = 0); + ~GamepadMonitor(); + +private: + QGamepad *m_gamepad; +}; + +#endif // GAMEPADMONITOR_H diff --git a/examples/gamepad/simple/main.cpp b/examples/gamepad/simple/main.cpp new file mode 100644 index 0000000..3bb4818 --- /dev/null +++ b/examples/gamepad/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 +#include "gamepadmonitor.h" + +int main(int argc, char **argv) +{ + QCoreApplication application(argc, argv); + + GamepadMonitor monitor; + + return application.exec(); +} diff --git a/examples/gamepad/simple/simple.pro b/examples/gamepad/simple/simple.pro new file mode 100644 index 0000000..1fde59e --- /dev/null +++ b/examples/gamepad/simple/simple.pro @@ -0,0 +1,17 @@ +QT += gamepad + +CONFIG += c++11 + +SOURCES = main.cpp \ + gamepadmonitor.cpp + +HEADERS += \ + gamepadmonitor.h + +DISTFILES += \ + android/AndroidManifest.xml + +ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android + +target.path = $$[QT_INSTALL_EXAMPLES]/gamepad/simple +INSTALLS += target diff --git a/examples/keyNavigation/deployment.pri b/examples/keyNavigation/deployment.pri deleted file mode 100644 index 0d58a25..0000000 --- a/examples/keyNavigation/deployment.pri +++ /dev/null @@ -1,19 +0,0 @@ -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/doc/images/keynavigationgamepad-example.png b/examples/keyNavigation/doc/images/keynavigationgamepad-example.png deleted file mode 100644 index fa2fa1c..0000000 Binary files a/examples/keyNavigation/doc/images/keynavigationgamepad-example.png and /dev/null differ diff --git a/examples/keyNavigation/doc/src/keynaviexample.qdoc b/examples/keyNavigation/doc/src/keynaviexample.qdoc deleted file mode 100644 index 4226438..0000000 --- a/examples/keyNavigation/doc/src/keynaviexample.qdoc +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\example keyNavigation -\ingroup qtgamepad-examples -\title Qt Gamepad Key Navigation Example -\brief Demonstrates how to use navigation keys on the gamepad. -\image keynavigationgamepad-example.png -\include examples-run.qdocinc -*/ diff --git a/examples/keyNavigation/keyNavigation.pro b/examples/keyNavigation/keyNavigation.pro deleted file mode 100644 index 1cdc565..0000000 --- a/examples/keyNavigation/keyNavigation.pro +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 707d5c4..0000000 Binary files a/examples/keyNavigation/keyNavigation64.png and /dev/null differ diff --git a/examples/keyNavigation/keyNavigation80.png b/examples/keyNavigation/keyNavigation80.png deleted file mode 100644 index 6ad8096..0000000 Binary files a/examples/keyNavigation/keyNavigation80.png and /dev/null differ diff --git a/examples/keyNavigation/main.cpp b/examples/keyNavigation/main.cpp deleted file mode 100644 index 188b215..0000000 --- a/examples/keyNavigation/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -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 deleted file mode 100644 index 69145a8..0000000 --- a/examples/keyNavigation/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/main.qml - - diff --git a/examples/keyNavigation/qml/main.qml b/examples/keyNavigation/qml/main.qml deleted file mode 100644 index d58bfc5..0000000 --- a/examples/keyNavigation/qml/main.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** 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 - deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 - } - - Connections { - target: GamepadManager - onGamepadConnected: gamepad1.deviceId = deviceId - } - - 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 deleted file mode 100644 index 0d58a25..0000000 --- a/examples/mouseItem/deployment.pri +++ /dev/null @@ -1,19 +0,0 @@ -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/doc/src/mouseitemexample.qdoc b/examples/mouseItem/doc/src/mouseitemexample.qdoc deleted file mode 100644 index 80f8357..0000000 --- a/examples/mouseItem/doc/src/mouseitemexample.qdoc +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\example mouseItem -\ingroup qtgamepad-examples -\title Qt Gamepad Mouse Item Example -\brief Depicts joystick movement using a pointer. -\include examples-run.qdocinc -*/ diff --git a/examples/mouseItem/main.cpp b/examples/mouseItem/main.cpp deleted file mode 100644 index ab95334..0000000 --- a/examples/mouseItem/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -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 deleted file mode 100644 index 1cdc565..0000000 --- a/examples/mouseItem/mouseItem.pro +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 707d5c4..0000000 Binary files a/examples/mouseItem/mouseItem64.png and /dev/null differ diff --git a/examples/mouseItem/mouseItem80.png b/examples/mouseItem/mouseItem80.png deleted file mode 100644 index 6ad8096..0000000 Binary files a/examples/mouseItem/mouseItem80.png and /dev/null differ diff --git a/examples/mouseItem/qml.qrc b/examples/mouseItem/qml.qrc deleted file mode 100644 index 69145a8..0000000 --- a/examples/mouseItem/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/main.qml - - diff --git a/examples/mouseItem/qml/main.qml b/examples/mouseItem/qml/main.qml deleted file mode 100644 index 4c05e90..0000000 --- a/examples/mouseItem/qml/main.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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") - - Connections { - target: GamepadManager - onGamepadConnected: gamepad1.deviceId = deviceId - } - - Gamepad { - id: gamepad1 - deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 - - 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 deleted file mode 100644 index 0d58a25..0000000 --- a/examples/quickGamepad/deployment.pri +++ /dev/null @@ -1,19 +0,0 @@ -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/doc/images/qtquickgamepad-example.png b/examples/quickGamepad/doc/images/qtquickgamepad-example.png deleted file mode 100644 index 9f46e4d..0000000 Binary files a/examples/quickGamepad/doc/images/qtquickgamepad-example.png and /dev/null differ diff --git a/examples/quickGamepad/doc/src/quickgamepadexample.qdoc b/examples/quickGamepad/doc/src/quickgamepadexample.qdoc deleted file mode 100644 index b96c419..0000000 --- a/examples/quickGamepad/doc/src/quickgamepadexample.qdoc +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\example quickGamepad -\ingroup qtgamepad-examples -\title Qt Gamepad Qt Quick Example -\brief Demonstrates how to interact with the gamepad using QML. -\image qtquickgamepad-example.png -\include examples-run.qdocinc -*/ diff --git a/examples/quickGamepad/main.cpp b/examples/quickGamepad/main.cpp deleted file mode 100644 index 188b215..0000000 --- a/examples/quickGamepad/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -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 deleted file mode 100644 index d82637e..0000000 --- a/examples/quickGamepad/qml.qrc +++ /dev/null @@ -1,24 +0,0 @@ - - - qml/main.qml - qml/JoystickViewer.qml - qml/xboxControllerButtonA.png - qml/xboxControllerButtonB.png - qml/xboxControllerButtonX.png - qml/xboxControllerButtonY.png - qml/ButtonImage.qml - qml/xboxControllerBack.png - qml/xboxControllerButtonGuide.png - qml/xboxControllerDPad.png - qml/xboxControllerLeftShoulder.png - qml/xboxControllerLeftThumbstick.png - qml/xboxControllerLeftTrigger.png - qml/xboxControllerRightShoulder.png - qml/xboxControllerRightThumbstick.png - qml/xboxControllerRightTrigger.png - qml/xboxControllerStart.png - qml/LeftThumbstick.qml - qml/RightThumbstick.qml - qml/DPad.qml - - diff --git a/examples/quickGamepad/qml/ButtonImage.qml b/examples/quickGamepad/qml/ButtonImage.qml deleted file mode 100644 index 8057542..0000000 --- a/examples/quickGamepad/qml/ButtonImage.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** 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 deleted file mode 100644 index d34c953..0000000 --- a/examples/quickGamepad/qml/DPad.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** 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 deleted file mode 100644 index da0168e..0000000 --- a/examples/quickGamepad/qml/JoystickViewer.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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 deleted file mode 100644 index 8ee0db0..0000000 --- a/examples/quickGamepad/qml/LeftThumbstick.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** 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 deleted file mode 100644 index 9dfa3de..0000000 --- a/examples/quickGamepad/qml/RightThumbstick.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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 deleted file mode 100644 index 049e72b..0000000 --- a/examples/quickGamepad/qml/main.qml +++ /dev/null @@ -1,238 +0,0 @@ -/**************************************************************************** -** -** 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 - } - } - - } - - Connections { - target: GamepadManager - onGamepadConnected: gamepad.deviceId = deviceId - } - - Gamepad { - id: gamepad - deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 - } -} diff --git a/examples/quickGamepad/qml/xboxControllerBack.png b/examples/quickGamepad/qml/xboxControllerBack.png deleted file mode 100644 index d97972c..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerBack.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerButtonA.png b/examples/quickGamepad/qml/xboxControllerButtonA.png deleted file mode 100644 index 271e8c8..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerButtonA.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerButtonB.png b/examples/quickGamepad/qml/xboxControllerButtonB.png deleted file mode 100644 index f1e06b6..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerButtonB.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerButtonGuide.png b/examples/quickGamepad/qml/xboxControllerButtonGuide.png deleted file mode 100644 index 287d32b..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerButtonGuide.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerButtonX.png b/examples/quickGamepad/qml/xboxControllerButtonX.png deleted file mode 100644 index 8d29281..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerButtonX.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerButtonY.png b/examples/quickGamepad/qml/xboxControllerButtonY.png deleted file mode 100644 index 465ac48..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerButtonY.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerDPad.png b/examples/quickGamepad/qml/xboxControllerDPad.png deleted file mode 100644 index efaeb16..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerDPad.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerLeftShoulder.png b/examples/quickGamepad/qml/xboxControllerLeftShoulder.png deleted file mode 100644 index 9b084df..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerLeftShoulder.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerLeftThumbstick.png b/examples/quickGamepad/qml/xboxControllerLeftThumbstick.png deleted file mode 100644 index 08fbaa2..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerLeftThumbstick.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerLeftTrigger.png b/examples/quickGamepad/qml/xboxControllerLeftTrigger.png deleted file mode 100644 index 1fd7324..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerLeftTrigger.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerRightShoulder.png b/examples/quickGamepad/qml/xboxControllerRightShoulder.png deleted file mode 100644 index a22c8ca..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerRightShoulder.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerRightThumbstick.png b/examples/quickGamepad/qml/xboxControllerRightThumbstick.png deleted file mode 100644 index ab95ef5..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerRightThumbstick.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerRightTrigger.png b/examples/quickGamepad/qml/xboxControllerRightTrigger.png deleted file mode 100644 index 717f7ab..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerRightTrigger.png and /dev/null differ diff --git a/examples/quickGamepad/qml/xboxControllerStart.png b/examples/quickGamepad/qml/xboxControllerStart.png deleted file mode 100644 index 709459e..0000000 Binary files a/examples/quickGamepad/qml/xboxControllerStart.png and /dev/null differ diff --git a/examples/quickGamepad/quickGamepad.pro b/examples/quickGamepad/quickGamepad.pro deleted file mode 100644 index 1cdc565..0000000 --- a/examples/quickGamepad/quickGamepad.pro +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 707d5c4..0000000 Binary files a/examples/quickGamepad/quickGamepad64.png and /dev/null differ diff --git a/examples/quickGamepad/quickGamepad80.png b/examples/quickGamepad/quickGamepad80.png deleted file mode 100644 index 6ad8096..0000000 Binary files a/examples/quickGamepad/quickGamepad80.png and /dev/null differ diff --git a/examples/simple/android/AndroidManifest.xml b/examples/simple/android/AndroidManifest.xml deleted file mode 100644 index bdf824d..0000000 --- a/examples/simple/android/AndroidManifest.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/simple/doc/src/simpleexample.qdoc b/examples/simple/doc/src/simpleexample.qdoc deleted file mode 100644 index 67bb07b..0000000 --- a/examples/simple/doc/src/simpleexample.qdoc +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\example simple -\ingroup qtgamepad-examples -\title Qt Gamepad Simple Example -\brief A simple example demonstrating the APIs in use. -\include examples-run.qdocinc -*/ diff --git a/examples/simple/gamepadmonitor.cpp b/examples/simple/gamepadmonitor.cpp deleted file mode 100644 index d77b7a7..0000000 --- a/examples/simple/gamepadmonitor.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** 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 - -#include - -GamepadMonitor::GamepadMonitor(QObject *parent) - : QObject(parent) - , m_gamepad(0) -{ - auto gamepads = QGamepadManager::instance()->connectedGamepads(); - if (gamepads.isEmpty()) { - return; - } - - m_gamepad = new QGamepad(*gamepads.begin(), this); - connect(m_gamepad, &QGamepad::axisLeftXChanged, this, [](double value){ - qDebug() << "Left X" << value; - }); - connect(m_gamepad, &QGamepad::axisLeftYChanged, this, [](double value){ - qDebug() << "Left Y" << value; - }); - connect(m_gamepad, &QGamepad::axisRightXChanged, this, [](double value){ - qDebug() << "Right X" << value; - }); - connect(m_gamepad, &QGamepad::axisRightYChanged, this, [](double value){ - qDebug() << "Right Y" << value; - }); - connect(m_gamepad, &QGamepad::buttonAChanged, this, [](bool pressed){ - qDebug() << "Button A" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonBChanged, this, [](bool pressed){ - qDebug() << "Button B" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonXChanged, this, [](bool pressed){ - qDebug() << "Button X" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonYChanged, this, [](bool pressed){ - qDebug() << "Button Y" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonL1Changed, this, [](bool pressed){ - qDebug() << "Button L1" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonR1Changed, this, [](bool pressed){ - qDebug() << "Button R1" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonL2Changed, this, [](double value){ - qDebug() << "Button L2: " << value; - }); - connect(m_gamepad, &QGamepad::buttonR2Changed, this, [](double value){ - qDebug() << "Button R2: " << value; - }); - connect(m_gamepad, &QGamepad::buttonSelectChanged, this, [](bool pressed){ - qDebug() << "Button Select" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonStartChanged, this, [](bool pressed){ - qDebug() << "Button Start" << pressed; - }); - connect(m_gamepad, &QGamepad::buttonGuideChanged, this, [](bool pressed){ - qDebug() << "Button Guide" << pressed; - }); -} - -GamepadMonitor::~GamepadMonitor() -{ - delete m_gamepad; -} diff --git a/examples/simple/gamepadmonitor.h b/examples/simple/gamepadmonitor.h deleted file mode 100644 index 8c3fb4a..0000000 --- a/examples/simple/gamepadmonitor.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -QT_BEGIN_NAMESPACE -class QGamepad; -QT_END_NAMESPACE - -class GamepadMonitor : public QObject -{ - Q_OBJECT -public: - explicit GamepadMonitor(QObject *parent = 0); - ~GamepadMonitor(); - -private: - QGamepad *m_gamepad; -}; - -#endif // GAMEPADMONITOR_H diff --git a/examples/simple/main.cpp b/examples/simple/main.cpp deleted file mode 100644 index 3bb4818..0000000 --- a/examples/simple/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** 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 -#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 deleted file mode 100644 index 5db564f..0000000 --- a/examples/simple/simple.pro +++ /dev/null @@ -1,14 +0,0 @@ -QT += gamepad - -CONFIG += c++11 - -SOURCES = main.cpp \ - gamepadmonitor.cpp - -HEADERS += \ - gamepadmonitor.h - -DISTFILES += \ - android/AndroidManifest.xml - -ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android -- cgit v1.2.3