aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorJohan Solbakken <johan.hvaler@gmail.com>2023-08-15 12:25:56 +0200
committerAndy Nichols <nezticle@gmail.com>2024-06-09 19:22:21 +0200
commit39bbb8049f5d56eaf611e6dfa9db64cd70616137 (patch)
treebc50e1e24d983f6c369a82e3a7012dc6dcefe1b4 /src/imports
parent1712e01fb1564705338532ae14a77acda8acd5cb (diff)
Expand scope of QtGamepad to QtUniversalInputHEADdev
This patch transforms the QtGamepad module from Qt 5 into a new module that expands the scope to include all forms of exotic input. The majority of the previous QtGamepad functionality and APIs are preserved, but now there is also a more general API for getting the state of input devices like joysticks, flight yokes, and any other devices that define themselves in terms of buttons and axes. In addition to being able to receive input, it is also now possible to output feedback in devices that support it. Experimental input mapping functionality has been added to facilitate mapping an arbitrary input to a predefined action. Change-Id: Ic35b73282944cfd4eea9defbcf82c4abc55d7237 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/gamepad/gamepad.pro17
-rw-r--r--src/imports/gamepad/plugins.qmltypes539
-rw-r--r--src/imports/gamepad/qgamepadmouseitem.cpp225
-rw-r--r--src/imports/gamepad/qgamepadmouseitem.h117
-rw-r--r--src/imports/gamepad/qmldir4
-rw-r--r--src/imports/gamepad/qtgamepad.cpp85
-rw-r--r--src/imports/imports.pro2
7 files changed, 0 insertions, 989 deletions
diff --git a/src/imports/gamepad/gamepad.pro b/src/imports/gamepad/gamepad.pro
deleted file mode 100644
index e518f10..0000000
--- a/src/imports/gamepad/gamepad.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CXX_MODULE = gamepad
-TARGET = declarative_gamepad
-TARGETPATH = QtGamepad
-IMPORT_VERSION = 1.$$QT_MINOR_VERSION
-
-QT += qml quick gamepad
-
-load(qml_plugin)
-
-OTHER_FILES += qmldir
-
-SOURCES += \
- qtgamepad.cpp \
- qgamepadmouseitem.cpp
-
-HEADERS += \
- qgamepadmouseitem.h
diff --git a/src/imports/gamepad/plugins.qmltypes b/src/imports/gamepad/plugins.qmltypes
deleted file mode 100644
index ef1fa4b..0000000
--- a/src/imports/gamepad/plugins.qmltypes
+++ /dev/null
@@ -1,539 +0,0 @@
-import QtQuick.tooling 1.2
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-//
-// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtGamepad 1.15'
-
-Module {
- dependencies: ["QtQuick 2.0"]
- Component {
- name: "QGamepad"
- prototype: "QObject"
- exports: ["QtGamepad/Gamepad 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "deviceId"; type: "int" }
- Property { name: "connected"; type: "bool"; isReadonly: true }
- Property { name: "name"; type: "string"; isReadonly: true }
- Property { name: "axisLeftX"; type: "double"; isReadonly: true }
- Property { name: "axisLeftY"; type: "double"; isReadonly: true }
- Property { name: "axisRightX"; type: "double"; isReadonly: true }
- Property { name: "axisRightY"; type: "double"; isReadonly: true }
- Property { name: "buttonA"; type: "bool"; isReadonly: true }
- Property { name: "buttonB"; type: "bool"; isReadonly: true }
- Property { name: "buttonX"; type: "bool"; isReadonly: true }
- Property { name: "buttonY"; type: "bool"; isReadonly: true }
- Property { name: "buttonL1"; type: "bool"; isReadonly: true }
- Property { name: "buttonR1"; type: "bool"; isReadonly: true }
- Property { name: "buttonL2"; type: "double"; isReadonly: true }
- Property { name: "buttonR2"; type: "double"; isReadonly: true }
- Property { name: "buttonSelect"; type: "bool"; isReadonly: true }
- Property { name: "buttonStart"; type: "bool"; isReadonly: true }
- Property { name: "buttonL3"; type: "bool"; isReadonly: true }
- Property { name: "buttonR3"; type: "bool"; isReadonly: true }
- Property { name: "buttonUp"; type: "bool"; isReadonly: true }
- Property { name: "buttonDown"; type: "bool"; isReadonly: true }
- Property { name: "buttonLeft"; type: "bool"; isReadonly: true }
- Property { name: "buttonRight"; type: "bool"; isReadonly: true }
- Property { name: "buttonCenter"; type: "bool"; isReadonly: true }
- Property { name: "buttonGuide"; type: "bool"; isReadonly: true }
- Signal {
- name: "deviceIdChanged"
- Parameter { name: "value"; type: "int" }
- }
- Signal {
- name: "connectedChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "nameChanged"
- Parameter { name: "value"; type: "string" }
- }
- Signal {
- name: "axisLeftXChanged"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "axisLeftYChanged"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "axisRightXChanged"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "axisRightYChanged"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "buttonAChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonBChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonXChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonYChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonL1Changed"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonR1Changed"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonL2Changed"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "buttonR2Changed"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "buttonSelectChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonStartChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonL3Changed"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonR3Changed"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonUpChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonDownChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonLeftChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonRightChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonCenterChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Signal {
- name: "buttonGuideChanged"
- Parameter { name: "value"; type: "bool" }
- }
- Method {
- name: "setDeviceId"
- Parameter { name: "number"; type: "int" }
- }
- }
- Component {
- name: "QGamepadKeyNavigation"
- prototype: "QObject"
- exports: ["QtGamepad/GamepadKeyNavigation 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "active"; type: "bool" }
- Property { name: "gamepad"; type: "QGamepad"; isPointer: true }
- Property { name: "upKey"; type: "Qt::Key" }
- Property { name: "downKey"; type: "Qt::Key" }
- Property { name: "leftKey"; type: "Qt::Key" }
- Property { name: "rightKey"; type: "Qt::Key" }
- Property { name: "buttonAKey"; type: "Qt::Key" }
- Property { name: "buttonBKey"; type: "Qt::Key" }
- Property { name: "buttonXKey"; type: "Qt::Key" }
- Property { name: "buttonYKey"; type: "Qt::Key" }
- Property { name: "buttonSelectKey"; type: "Qt::Key" }
- Property { name: "buttonStartKey"; type: "Qt::Key" }
- Property { name: "buttonGuideKey"; type: "Qt::Key" }
- Property { name: "buttonL1Key"; type: "Qt::Key" }
- Property { name: "buttonR1Key"; type: "Qt::Key" }
- Property { name: "buttonL2Key"; type: "Qt::Key" }
- Property { name: "buttonR2Key"; type: "Qt::Key" }
- Property { name: "buttonL3Key"; type: "Qt::Key" }
- Property { name: "buttonR3Key"; type: "Qt::Key" }
- Signal {
- name: "activeChanged"
- Parameter { name: "isActive"; type: "bool" }
- }
- Signal {
- name: "gamepadChanged"
- Parameter { name: "gamepad"; type: "QGamepad"; isPointer: true }
- }
- Signal {
- name: "upKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "downKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "leftKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "rightKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonAKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonBKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonXKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonYKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonSelectKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonStartKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonGuideKeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonL1KeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonR1KeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonL2KeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonR2KeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonL3KeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Signal {
- name: "buttonR3KeyChanged"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setActive"
- Parameter { name: "isActive"; type: "bool" }
- }
- Method {
- name: "setGamepad"
- Parameter { name: "gamepad"; type: "QGamepad"; isPointer: true }
- }
- Method {
- name: "setUpKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setDownKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setLeftKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setRightKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonAKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonBKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonXKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonYKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonSelectKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonStartKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonGuideKey"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonL1Key"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonR1Key"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonL2Key"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonR2Key"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonL3Key"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- Method {
- name: "setButtonR3Key"
- Parameter { name: "key"; type: "Qt::Key" }
- }
- }
- Component {
- name: "QGamepadManager"
- prototype: "QObject"
- exports: ["QtGamepad/GamepadManager 1.0"]
- isCreatable: false
- isSingleton: true
- exportMetaObjectRevisions: [0]
- Enum {
- name: "GamepadButton"
- values: {
- "ButtonInvalid": -1,
- "ButtonA": 0,
- "ButtonB": 1,
- "ButtonX": 2,
- "ButtonY": 3,
- "ButtonL1": 4,
- "ButtonR1": 5,
- "ButtonL2": 6,
- "ButtonR2": 7,
- "ButtonSelect": 8,
- "ButtonStart": 9,
- "ButtonL3": 10,
- "ButtonR3": 11,
- "ButtonUp": 12,
- "ButtonDown": 13,
- "ButtonRight": 14,
- "ButtonLeft": 15,
- "ButtonCenter": 16,
- "ButtonGuide": 17
- }
- }
- Enum {
- name: "GamepadButtons"
- values: {
- "ButtonInvalid": -1,
- "ButtonA": 0,
- "ButtonB": 1,
- "ButtonX": 2,
- "ButtonY": 3,
- "ButtonL1": 4,
- "ButtonR1": 5,
- "ButtonL2": 6,
- "ButtonR2": 7,
- "ButtonSelect": 8,
- "ButtonStart": 9,
- "ButtonL3": 10,
- "ButtonR3": 11,
- "ButtonUp": 12,
- "ButtonDown": 13,
- "ButtonRight": 14,
- "ButtonLeft": 15,
- "ButtonCenter": 16,
- "ButtonGuide": 17
- }
- }
- Enum {
- name: "GamepadAxis"
- values: {
- "AxisInvalid": -1,
- "AxisLeftX": 0,
- "AxisLeftY": 1,
- "AxisRightX": 2,
- "AxisRightY": 3
- }
- }
- Enum {
- name: "GamepadAxes"
- values: {
- "AxisInvalid": -1,
- "AxisLeftX": 0,
- "AxisLeftY": 1,
- "AxisRightX": 2,
- "AxisRightY": 3
- }
- }
- Property { name: "connectedGamepads"; type: "QList<int>"; isReadonly: true }
- Signal {
- name: "gamepadConnected"
- Parameter { name: "deviceId"; type: "int" }
- }
- Signal {
- name: "gamepadNameChanged"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "name"; type: "string" }
- }
- Signal {
- name: "gamepadDisconnected"
- Parameter { name: "deviceId"; type: "int" }
- }
- Signal {
- name: "gamepadAxisEvent"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "axis"; type: "QGamepadManager::GamepadAxis" }
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "gamepadButtonPressEvent"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "button"; type: "QGamepadManager::GamepadButton" }
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "gamepadButtonReleaseEvent"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "button"; type: "QGamepadManager::GamepadButton" }
- }
- Signal {
- name: "buttonConfigured"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "button"; type: "QGamepadManager::GamepadButton" }
- }
- Signal {
- name: "axisConfigured"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "axis"; type: "QGamepadManager::GamepadAxis" }
- }
- Signal {
- name: "configurationCanceled"
- Parameter { name: "deviceId"; type: "int" }
- }
- Method {
- name: "isConfigurationNeeded"
- type: "bool"
- Parameter { name: "deviceId"; type: "int" }
- }
- Method {
- name: "configureButton"
- type: "bool"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "button"; type: "GamepadButton" }
- }
- Method {
- name: "configureAxis"
- type: "bool"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "axis"; type: "GamepadAxis" }
- }
- Method {
- name: "setCancelConfigureButton"
- type: "bool"
- Parameter { name: "deviceId"; type: "int" }
- Parameter { name: "button"; type: "GamepadButton" }
- }
- Method {
- name: "resetConfiguration"
- Parameter { name: "deviceId"; type: "int" }
- }
- Method {
- name: "setSettingsFile"
- Parameter { name: "file"; type: "string" }
- }
- }
- Component {
- name: "QGamepadMouseItem"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["QtGamepad/GamepadMouseItem 1.0"]
- exportMetaObjectRevisions: [0]
- Enum {
- name: "GamepadJoystick"
- values: {
- "LeftStick": 0,
- "RightStick": 1,
- "Both": 2
- }
- }
- Property { name: "active"; type: "bool" }
- Property { name: "gamepad"; type: "QGamepad"; isPointer: true }
- Property { name: "joystick"; type: "GamepadJoystick" }
- Property { name: "deadZoneSize"; type: "double" }
- Property { name: "mousePosition"; type: "QPointF"; isReadonly: true }
- Signal {
- name: "activeChanged"
- Parameter { name: "isActive"; type: "bool" }
- }
- Signal {
- name: "gamepadChanged"
- Parameter { name: "gamepad"; type: "QGamepad"; isPointer: true }
- }
- Signal {
- name: "joystickChanged"
- Parameter { name: "joystick"; type: "GamepadJoystick" }
- }
- Signal {
- name: "deadZoneSizeChanged"
- Parameter { name: "size"; type: "double" }
- }
- Signal {
- name: "mousePositionChanged"
- Parameter { name: "position"; type: "QPointF" }
- }
- Method {
- name: "setActive"
- Parameter { name: "arg"; type: "bool" }
- }
- Method {
- name: "setGamepad"
- Parameter { name: "gamepad"; type: "QGamepad"; isPointer: true }
- }
- Method {
- name: "setJoystick"
- Parameter { name: "joystick"; type: "GamepadJoystick" }
- }
- Method {
- name: "setDeadZoneSize"
- Parameter { name: "size"; type: "double" }
- }
- Method {
- name: "mouseButtonPressed"
- Parameter { name: "button"; type: "int" }
- }
- Method {
- name: "mouseButtonReleased"
- Parameter { name: "button"; type: "int" }
- }
- }
-}
diff --git a/src/imports/gamepad/qgamepadmouseitem.cpp b/src/imports/gamepad/qgamepadmouseitem.cpp
deleted file mode 100644
index 8baa159..0000000
--- a/src/imports/gamepad/qgamepadmouseitem.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** 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 "qgamepadmouseitem.h"
-#include <cmath>
-
-#include <QtGamepad/QGamepad>
-#include <QtGui/QWindow>
-#include <QtQuick/QQuickWindow>
-#include <QtGui/QGuiApplication>
-
-QT_BEGIN_NAMESPACE
-
-QGamepadMouseItem::QGamepadMouseItem(QQuickItem *parent)
- : QQuickItem(parent)
- , m_active(false)
- , m_gamepad(nullptr)
- , m_joystick(QGamepadMouseItem::LeftStick)
- , m_deadZoneSize(0.1)
-{
- m_updateTimer.setInterval(16);
- connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateMousePostion()));
-}
-
-bool QGamepadMouseItem::active() const
-{
- return m_active;
-}
-
-QGamepad *QGamepadMouseItem::gamepad() const
-{
- return m_gamepad;
-}
-
-QGamepadMouseItem::GamepadJoystick QGamepadMouseItem::joystick() const
-{
- return m_joystick;
-}
-
-double QGamepadMouseItem::deadZoneSize() const
-{
- return m_deadZoneSize;
-}
-
-QPointF QGamepadMouseItem::mousePosition() const
-{
- return m_mousePosition;
-}
-
-void QGamepadMouseItem::setActive(bool arg)
-{
- if (m_active != arg) {
- m_active = arg;
- if (m_active) {
- m_deltaTimer.start();
- m_updateTimer.start();
- } else {
- m_updateTimer.stop();
- m_deltaTimer.invalidate();
- }
- emit activeChanged(arg);
- }
-}
-
-void QGamepadMouseItem::setGamepad(QGamepad *gamepad)
-{
- if (m_gamepad != gamepad) {
- m_gamepad = gamepad;
- emit gamepadChanged(gamepad);
- }
-}
-
-void QGamepadMouseItem::setJoystick(QGamepadMouseItem::GamepadJoystick joystick)
-{
- if (m_joystick != joystick) {
- m_joystick = joystick;
- emit joystickChanged(joystick);
- }
-}
-
-void QGamepadMouseItem::setDeadZoneSize(double size)
-{
- if (m_deadZoneSize != size) {
- m_deadZoneSize = size;
- emit deadZoneSizeChanged(size);
- }
-}
-
-void QGamepadMouseItem::mouseButtonPressed(int button)
-{
- processMouseButtonEvent(true, (Qt::MouseButton)button);
-}
-
-void QGamepadMouseItem::mouseButtonReleased(int button)
-{
- processMouseButtonEvent(false, (Qt::MouseButton)button);
-}
-
-void QGamepadMouseItem::updateMousePostion()
-{
- // Get the delta from the last call
- qint64 delta = m_deltaTimer.restart();
-
- // Don't bother when there is not gamepad to read from
- if (!m_gamepad || !m_gamepad->isConnected())
- return;
-
- double xVelocity = 0.0;
- double yVelocity = 0.0;
-
- if (m_joystick == QGamepadMouseItem::LeftStick) {
- xVelocity = m_gamepad->axisLeftX();
- yVelocity = m_gamepad->axisLeftY();
- } else if (m_joystick == QGamepadMouseItem::RightStick) {
- xVelocity = m_gamepad->axisRightX();
- yVelocity = m_gamepad->axisRightY();
- } else { // The greatest of both
- if (std::abs(m_gamepad->axisLeftX()) > std::abs(m_gamepad->axisRightX()))
- xVelocity = m_gamepad->axisLeftX();
- else
- xVelocity = m_gamepad->axisRightX();
- if (std::abs(m_gamepad->axisLeftY()) > std::abs(m_gamepad->axisRightY()))
- yVelocity = m_gamepad->axisLeftY();
- else
- yVelocity = m_gamepad->axisRightY();
- }
-
- // Check for deadzone limits]
- if (std::abs(xVelocity) < m_deadZoneSize)
- xVelocity = 0.0;
- if (std::abs(yVelocity) < m_deadZoneSize)
- yVelocity = 0.0;
- if (xVelocity == 0.0 && yVelocity == 0.0)
- return;
-
- double newXPosition = m_mousePosition.x() + xVelocity * delta;
- double newYPosition = m_mousePosition.y() + yVelocity * delta;
- // Check bounds
- if (newXPosition < 0)
- newXPosition = 0;
- else if (newXPosition > width())
- newXPosition = width();
-
- if (newYPosition < 0)
- newYPosition = 0;
- else if (newYPosition > height())
- newYPosition = height();
-
- m_mousePosition = QPointF(newXPosition, newYPosition);
- emit mousePositionChanged(m_mousePosition);
-}
-
-void QGamepadMouseItem::processMouseMoveEvent(QPointF position)
-{
- QMouseEvent *mouseEvent = new QMouseEvent(QEvent::MouseMove, mapToScene(position), Qt::NoButton, m_mouseButtons, Qt::NoModifier);
- sendGeneratedMouseEvent(mouseEvent);
-}
-
-void QGamepadMouseItem::processMouseButtonEvent(bool isPressed, Qt::MouseButton button)
-{
- QMouseEvent *event;
- if (isPressed) {
- m_mouseButtons |= button;
- event = new QMouseEvent(QEvent::MouseButtonPress, mapToScene(m_mousePosition), button, m_mouseButtons, Qt::NoModifier);
- } else {
- m_mouseButtons ^= button;
- event = new QMouseEvent(QEvent::MouseButtonRelease, mapToScene(m_mousePosition), button, m_mouseButtons, Qt::NoModifier);
- }
-
- sendGeneratedMouseEvent(event);
-}
-
-void QGamepadMouseItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- QQuickItem::geometryChanged(newGeometry, oldGeometry);
-
- m_mousePosition = newGeometry.center();
-}
-
-void QGamepadMouseItem::sendGeneratedMouseEvent(QMouseEvent *event)
-{
- if (!m_active || !this->window()) {
- delete event;
- return;
- }
-
- QWindow *window = qobject_cast<QWindow*>(this->window());
- if (window)
- QGuiApplication::sendEvent(window, event);
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/gamepad/qgamepadmouseitem.h b/src/imports/gamepad/qgamepadmouseitem.h
deleted file mode 100644
index d1c507e..0000000
--- a/src/imports/gamepad/qgamepadmouseitem.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** 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$
-**
-****************************************************************************/
-
-#ifndef QGAMEPADMOUSEITEM_H
-#define QGAMEPADMOUSEITEM_H
-
-#include <QtQuick/QQuickItem>
-#include <QtCore/QTimer>
-#include <QtCore/QElapsedTimer>
-#include <QtGamepad/qgamepad.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGamepadManager;
-class QGamepadMouseItem : public QQuickItem
-{
- Q_OBJECT
- Q_ENUMS(GamepadJoystick)
- Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(QGamepad* gamepad READ gamepad WRITE setGamepad NOTIFY gamepadChanged)
- Q_PROPERTY(GamepadJoystick joystick READ joystick WRITE setJoystick NOTIFY joystickChanged)
- Q_PROPERTY(double deadZoneSize READ deadZoneSize WRITE setDeadZoneSize NOTIFY deadZoneSizeChanged)
- Q_PROPERTY(QPointF mousePosition READ mousePosition NOTIFY mousePositionChanged)
-
-public:
- enum GamepadJoystick {
- LeftStick,
- RightStick,
- Both
- };
-
- explicit QGamepadMouseItem(QQuickItem *parent = nullptr);
-
- bool active() const;
- QGamepad* gamepad() const;
- GamepadJoystick joystick() const;
- double deadZoneSize() const;
- QPointF mousePosition() const;
-
-signals:
-
- void activeChanged(bool isActive);
- void gamepadChanged(QGamepad* gamepad);
- void joystickChanged(GamepadJoystick joystick);
- void deadZoneSizeChanged(double size);
- void mousePositionChanged(QPointF position);
-
-public slots:
-
- void setActive(bool arg);
- void setGamepad(QGamepad* gamepad);
- void setJoystick(GamepadJoystick joystick);
- void setDeadZoneSize(double size);
-
- void mouseButtonPressed(int button);
- void mouseButtonReleased(int button);
-
-private slots:
- void updateMousePostion();
- void processMouseMoveEvent(QPointF position);
- void processMouseButtonEvent(bool isPressed, Qt::MouseButton button = Qt::LeftButton);
-
-protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
-
-private:
- void sendGeneratedMouseEvent(QMouseEvent *event);
-
- QPointF m_mousePosition;
- QTimer m_updateTimer;
- QElapsedTimer m_deltaTimer;
- Qt::MouseButtons m_mouseButtons;
-
- bool m_active;
- QGamepad* m_gamepad;
- GamepadJoystick m_joystick;
- double m_deadZoneSize;
-
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QGAMEPADMOUSEITEM_H
diff --git a/src/imports/gamepad/qmldir b/src/imports/gamepad/qmldir
deleted file mode 100644
index fa9e6e4..0000000
--- a/src/imports/gamepad/qmldir
+++ /dev/null
@@ -1,4 +0,0 @@
-module QtGamepad
-plugin declarative_gamepad
-typeinfo plugins.qmltypes
-classname QGamepadModule
diff --git a/src/imports/gamepad/qtgamepad.cpp b/src/imports/gamepad/qtgamepad.cpp
deleted file mode 100644
index 347e38a..0000000
--- a/src/imports/gamepad/qtgamepad.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** 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 <QtQml/qqmlengine.h>
-#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/qqml.h>
-
-#include <QtGamepad/QGamepad>
-#include <QtGamepad/QGamepadKeyNavigation>
-
-#include "qgamepadmouseitem.h"
-
-QT_BEGIN_NAMESPACE
-
-static QObject *gamepadmanager_singletontype_provider(QQmlEngine * /* engine */, QJSEngine * /* scriptEngine */)
-{
- QGamepadManager *manager = QGamepadManager::instance();
- QQmlEngine::setObjectOwnership(manager, QQmlEngine::CppOwnership);
- return manager;
-}
-
-class QGamepadModule : public QQmlExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
-public:
- QGamepadModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { }
- void registerTypes(const char *uri) override
- {
- Q_ASSERT(QLatin1String(uri) == QLatin1String("QtGamepad"));
-
- // @uri QtGamepad
-
- qmlRegisterSingletonType<QGamepadManager>(uri, 1, 0, "GamepadManager", &gamepadmanager_singletontype_provider);
- qmlRegisterType<QGamepad>(uri, 1, 0, "Gamepad");
- qmlRegisterType<QGamepadKeyNavigation>(uri, 1, 0, "GamepadKeyNavigation");
- qmlRegisterType<QGamepadMouseItem>(uri, 1, 0, "GamepadMouseItem");
-
- // Register the latest Qt version as QML type version
- qmlRegisterModule(uri, 1, QT_VERSION_MINOR);
- }
-
- void initializeEngine(QQmlEngine *engine, const char *uri) override
- {
- Q_UNUSED(uri);
- Q_UNUSED(engine);
- }
-};
-
-QT_END_NAMESPACE
-
-#include "qtgamepad.moc"
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
deleted file mode 100644
index 72acdb0..0000000
--- a/src/imports/imports.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += gamepad