mirror of https://github.com/qt/qtgamepad.git
Cleanup Examples
Change-Id: I36de0a3ba85b6b89547792badaa06c50f0e4ccc3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
7aceda1389
commit
9c7ed97cf9
|
|
@ -14,6 +14,7 @@ examples/tutorials/*/*/*
|
|||
!examples/tutorials/*
|
||||
!examples/tutorials/*/*
|
||||
!examples/ja_JP/*/*
|
||||
!examples/*/*/qml/*
|
||||
demos/*/*
|
||||
!demos/spectrum/*
|
||||
demos/spectrum/bin
|
||||
|
|
|
|||
|
|
@ -35,10 +35,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Layouts 1.2
|
||||
import QtQuick.Window 2.0
|
||||
import QtGamepad 1.0
|
||||
|
|
@ -47,6 +44,8 @@ import QtGamepad 1.0
|
|||
ApplicationWindow {
|
||||
visible: true
|
||||
title: qsTr("Configure gamepad")
|
||||
width: 400
|
||||
height: 600
|
||||
|
||||
Component.onCompleted: {
|
||||
if (Qt.platform.os === "android")
|
||||
|
|
@ -74,46 +73,75 @@ ApplicationWindow {
|
|||
onConfigurationCanceled: pressButton(null)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: headerRectangle
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
height: headerLayout.implicitHeight + 16
|
||||
color: "white"
|
||||
z: 1
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
id: headerLayout
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.margins: 8
|
||||
|
||||
Label {
|
||||
text: qsTr("Gamepad configuration Utility")
|
||||
font.pointSize: 16
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Connected gamepads")
|
||||
}
|
||||
ComboBox {
|
||||
Layout.fillWidth: true
|
||||
model: GamepadManager.connectedGamepads
|
||||
onCurrentIndexChanged: gamepad.deviceId[GamepadManager.connectedGamepads[currentIndex]]
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
Label {
|
||||
text: qsTr("Start button cancel's current configuration")
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Flickable {
|
||||
id: scrollArea
|
||||
anchors.top: headerRectangle.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 8
|
||||
contentHeight: contentLayout.implicitHeight
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
ColumnLayout {
|
||||
id: contentLayout
|
||||
width: parent.width
|
||||
ColumnLayout {
|
||||
GroupBox {
|
||||
title: qsTr("Configure Gamepad Buttons")
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("ButtonA")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonA ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
@ -129,14 +157,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("ButtonB")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonB ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -151,14 +179,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("ButtonX")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonX ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -173,14 +201,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("ButtonY")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonY ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -195,14 +223,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("ButtonStart")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonStart ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -217,14 +245,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("ButtonSelect")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonSelect ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -239,14 +267,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button L1")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonL1 ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -261,14 +289,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button R1")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonR1 ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -283,14 +311,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button L2")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonL2 ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -305,14 +333,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button R2")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonR2 ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -327,14 +355,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button L3")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonL3 ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -349,14 +377,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button R3")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonR3 ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -371,14 +399,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button Up")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonUp ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -393,14 +421,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button Down")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.buttonDown ? qsTr("DOWN") : qsTr("UP")
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -415,14 +443,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button Left")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: gamepad.buttonLeft ? qsTr("DOWN") : qsTr("UP")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -437,14 +465,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button Right")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: gamepad.buttonRight ? qsTr("DOWN") : qsTr("UP")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -459,14 +487,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button Center")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: gamepad.buttonCenter ? qsTr("DOWN") : qsTr("UP")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -481,14 +509,14 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("Button Guide")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Text {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: gamepad.buttonGuide ? qsTr("DOWN") : qsTr("UP")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Configure")
|
||||
|
|
@ -506,21 +534,20 @@ ApplicationWindow {
|
|||
GroupBox {
|
||||
title: qsTr("Gamepad Axies")
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("AxisLeftX")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.axisLeftX
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
@ -536,15 +563,15 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("AxisLeftY")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.axisLeftY
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
@ -560,15 +587,15 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("AxisRightX")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.axisRightX
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
@ -584,15 +611,15 @@ ApplicationWindow {
|
|||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
Label {
|
||||
text: qsTr("AxisRightY")
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Text {
|
||||
Label {
|
||||
text: gamepad.axisRightY
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
@ -615,3 +642,4 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ TEMPLATE = subdirs
|
|||
SUBDIRS += simple
|
||||
|
||||
qtHaveModule(quick) {
|
||||
SUBDIRS += configureButtons
|
||||
SUBDIRS += \
|
||||
mouseItem \
|
||||
keyNavigation
|
||||
|
||||
qtHaveModule(widgets) {
|
||||
SUBDIRS += quickGamepad \
|
||||
keyNavigation \
|
||||
mouseItem
|
||||
qtHaveModule(quickcontrols2) {
|
||||
SUBDIRS += \
|
||||
configureButtons \
|
||||
quickGamepad
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
TEMPLATE = app
|
||||
|
||||
QT += qml quick widgets
|
||||
QT += qml quick
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@
|
|||
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
import QtQuick.Window 2.0
|
||||
import QtGamepad 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@
|
|||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
TEMPLATE = app
|
||||
|
||||
QT += qml quick widgets
|
||||
QT += qml quick
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
|
|
|
|||
|
|
@ -38,16 +38,27 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
import QtQuick.Window 2.0
|
||||
import QtGamepad 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Hello World")
|
||||
title: qsTr("Gamepad Mouse Item")
|
||||
|
||||
Text {
|
||||
id: instructionLabel
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("Simulate mouse input using a Gamepad")
|
||||
}
|
||||
Text {
|
||||
id: outputLabel
|
||||
anchors.horizontalCenter: instructionLabel.horizontalCenter
|
||||
anchors.top: instructionLabel.bottom
|
||||
text: ""
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: GamepadManager
|
||||
|
|
@ -61,9 +72,10 @@ ApplicationWindow {
|
|||
onButtonAChanged: {
|
||||
if (value == true) {
|
||||
gamepadMouse.mouseButtonPressed(Qt.LeftButton);
|
||||
console.log("fake clicked qt: " + gamepadMouse.mousePosition.x + "," + gamepadMouse.mousePosition.y);
|
||||
outputLabel.text = "Mouse click at: " + gamepadMouse.mousePosition.x + "," + gamepadMouse.mousePosition.y;
|
||||
} else {
|
||||
gamepadMouse.mouseButtonReleased(Qt.LeftButton);
|
||||
outputLabel.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,18 +88,36 @@ ApplicationWindow {
|
|||
|
||||
Rectangle {
|
||||
id: cursor
|
||||
width: 4
|
||||
height: 4
|
||||
width: 9
|
||||
height: 9
|
||||
radius: 4.5
|
||||
x: gamepadMouse.mousePosition.x
|
||||
y: gamepadMouse.mousePosition.y
|
||||
color: "red"
|
||||
color: "transparent"
|
||||
border.color: "red"
|
||||
Rectangle {
|
||||
x: cursor.width * 0.5 - 0.5
|
||||
y: 1
|
||||
width: 1
|
||||
height: cursor.height - 2
|
||||
color: "black"
|
||||
}
|
||||
Rectangle {
|
||||
x: 1
|
||||
y: cursor.height * 0.5 - 0.5
|
||||
height: 1
|
||||
width: cursor.width - 2
|
||||
color: "black"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("clicked qt: " + mouse.x + "," + mouse.y);
|
||||
console.log("clicked at: " + mouse.x + "," + mouse.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,99 +39,49 @@
|
|||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.0
|
||||
import QtGamepad 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
Window {
|
||||
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
|
||||
id: background
|
||||
anchors.fill: parent
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 8
|
||||
RowLayout {
|
||||
id: topRow
|
||||
width: parent.width
|
||||
ColumnLayout {
|
||||
id: buttonL2Item
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
ButtonImage {
|
||||
id: leftTrigger
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
source: "xboxControllerLeftTrigger.png"
|
||||
active: gamepad.buttonL2 != 0
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: buttonL2Value
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: leftTrigger.right
|
||||
orientation: 0
|
||||
width: leftTrigger.width
|
||||
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
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
Layout.fillWidth: true
|
||||
height: guideButton.height
|
||||
width: guideButton.width + 16 + backButton.width + startButton.width
|
||||
ButtonImage {
|
||||
|
|
@ -159,41 +109,73 @@ ApplicationWindow {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DPad {
|
||||
id: dPad
|
||||
gamepad: gamepad
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 8
|
||||
ColumnLayout {
|
||||
id: buttonR2Item
|
||||
Layout.alignment: Qt.AlignRight
|
||||
ButtonImage {
|
||||
id: rightTrigger
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
source: "xboxControllerRightTrigger.png"
|
||||
active: gamepad.buttonR2 != 0
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 8
|
||||
spacing: 16
|
||||
ProgressBar {
|
||||
id: buttonR2Value
|
||||
width: rightTrigger.width
|
||||
value: gamepad.buttonR2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: middleRow
|
||||
ButtonImage {
|
||||
id: buttonL1
|
||||
source: "xboxControllerLeftShoulder.png"
|
||||
active: gamepad.buttonL1
|
||||
}
|
||||
Item {
|
||||
id: spacer1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ButtonImage {
|
||||
id: buttonR1
|
||||
source: "xboxControllerRightShoulder.png"
|
||||
active: gamepad.buttonR1
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: bottomRow
|
||||
width: parent.width
|
||||
DPad {
|
||||
id: dPad
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
gamepad: gamepad
|
||||
}
|
||||
|
||||
LeftThumbstick {
|
||||
id: leftThumbstick
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
gamepad: gamepad
|
||||
}
|
||||
|
||||
Item {
|
||||
id: spacer2
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
RightThumbstick {
|
||||
id: rightThumbstick
|
||||
Layout.alignment: Qt.AlignRight
|
||||
gamepad: gamepad
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
width: 200
|
||||
height: 200
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 8
|
||||
Layout.alignment: Qt.AlignRight
|
||||
ButtonImage {
|
||||
id: buttonA
|
||||
anchors.bottom: parent.bottom
|
||||
|
|
@ -223,7 +205,8 @@ ApplicationWindow {
|
|||
active: gamepad.buttonY
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
|
|||
Loading…
Reference in New Issue