mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
fix: allow start Gamepad only Android (#2198)
This commit is contained in:
@@ -39,11 +39,6 @@ endif()
|
|||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS ${PACKAGES})
|
find_package(Qt6 REQUIRED COMPONENTS ${PACKAGES})
|
||||||
|
|
||||||
# Android: Qt private modules (like CorePrivate) are needed by qtgamepad
|
|
||||||
if(ANDROID)
|
|
||||||
find_package(Qt6CorePrivate CONFIG REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(LIBS ${LIBS}
|
set(LIBS ${LIBS}
|
||||||
Qt6::Core Qt6::Gui
|
Qt6::Core Qt6::Gui
|
||||||
Qt6::Network Qt6::Xml Qt6::RemoteObjects
|
Qt6::Network Qt6::Xml Qt6::RemoteObjects
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ add_subdirectory(${CLIENT_ROOT_DIR}/3rd/qtkeychain)
|
|||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
# Use qtgamepad from amnezia-vpn/qtgamepad repository
|
# Use qtgamepad from amnezia-vpn/qtgamepad repository
|
||||||
|
# Only if Qt6CorePrivate is available (required by qtgamepad)
|
||||||
|
find_package(Qt6CorePrivate CONFIG QUIET)
|
||||||
|
if(Qt6CorePrivate_FOUND)
|
||||||
add_subdirectory(${CLIENT_ROOT_DIR}/3rd/qtgamepad)
|
add_subdirectory(${CLIENT_ROOT_DIR}/3rd/qtgamepad)
|
||||||
# Link both the C++ module and QML plugin
|
# Link both the C++ module and QML plugin
|
||||||
if(TARGET GamepadLegacy)
|
if(TARGET GamepadLegacy)
|
||||||
@@ -94,6 +97,10 @@ if(ANDROID)
|
|||||||
if(TARGET GamepadLegacyQuickPrivate)
|
if(TARGET GamepadLegacyQuickPrivate)
|
||||||
target_link_libraries(${PROJECT} PRIVATE GamepadLegacyQuickPrivate)
|
target_link_libraries(${PROJECT} PRIVATE GamepadLegacyQuickPrivate)
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "Gamepad support enabled for Android")
|
||||||
|
else()
|
||||||
|
message(STATUS "Qt6CorePrivate not found. Gamepad support disabled for Android.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBS ${LIBS} qt6keychain)
|
set(LIBS ${LIBS} qt6keychain)
|
||||||
|
|||||||
@@ -129,6 +129,7 @@
|
|||||||
<file>ui/qml/Components/AdLabel.qml</file>
|
<file>ui/qml/Components/AdLabel.qml</file>
|
||||||
<file>ui/qml/Components/ConnectButton.qml</file>
|
<file>ui/qml/Components/ConnectButton.qml</file>
|
||||||
<file>ui/qml/Components/ConnectionTypeSelectionDrawer.qml</file>
|
<file>ui/qml/Components/ConnectionTypeSelectionDrawer.qml</file>
|
||||||
|
<file>ui/qml/Components/GamepadLoader.qml</file>
|
||||||
<file>ui/qml/Components/HomeContainersListView.qml</file>
|
<file>ui/qml/Components/HomeContainersListView.qml</file>
|
||||||
<file>ui/qml/Components/HomeSplitTunnelingDrawer.qml</file>
|
<file>ui/qml/Components/HomeSplitTunnelingDrawer.qml</file>
|
||||||
<file>ui/qml/Components/InstalledAppsDrawer.qml</file>
|
<file>ui/qml/Components/InstalledAppsDrawer.qml</file>
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtGamepadLegacy
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property alias gamepad: gamepad
|
||||||
|
property alias gamepadKeyNav: gamepadKeyNav
|
||||||
|
|
||||||
|
Gamepad {
|
||||||
|
id: gamepad
|
||||||
|
deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1
|
||||||
|
|
||||||
|
onButtonStartChanged: {
|
||||||
|
if (buttonStart) {
|
||||||
|
ServersModel.setProcessedServerIndex(ServersModel.defaultIndex)
|
||||||
|
ConnectionController.connectButtonClicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GamepadKeyNavigation {
|
||||||
|
id: gamepadKeyNav
|
||||||
|
gamepad: gamepad
|
||||||
|
active: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: GamepadManager
|
||||||
|
function onConnectedGamepadsChanged() {
|
||||||
|
if (GamepadManager.connectedGamepads.length > 0) {
|
||||||
|
gamepad.deviceId = GamepadManager.connectedGamepads[0]
|
||||||
|
} else {
|
||||||
|
gamepad.deviceId = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-35
@@ -6,7 +6,6 @@ import QtQuick.Dialogs
|
|||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
import Style 1.0
|
import Style 1.0
|
||||||
import QtGamepadLegacy
|
|
||||||
|
|
||||||
import "Config"
|
import "Config"
|
||||||
import "Controls2"
|
import "Controls2"
|
||||||
@@ -84,42 +83,9 @@ Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
active: Qt.platform.os === "android"
|
active: Qt.platform.os === "android"
|
||||||
sourceComponent: Component {
|
source: Qt.platform.os === "android" ? "Components/GamepadLoader.qml" : ""
|
||||||
Item {
|
|
||||||
Gamepad {
|
|
||||||
id: gamepad
|
|
||||||
deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1
|
|
||||||
|
|
||||||
onButtonStartChanged: {
|
|
||||||
if (buttonStart) {
|
|
||||||
ServersModel.setProcessedServerIndex(ServersModel.defaultIndex)
|
|
||||||
ConnectionController.connectButtonClicked()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GamepadKeyNavigation {
|
|
||||||
id: gamepadKeyNav
|
|
||||||
gamepad: gamepad
|
|
||||||
active: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: GamepadManager
|
|
||||||
function onConnectedGamepadsChanged() {
|
|
||||||
if (GamepadManager.connectedGamepads.length > 0) {
|
|
||||||
gamepad.deviceId = GamepadManager.connectedGamepads[0]
|
|
||||||
} else {
|
|
||||||
gamepad.deviceId = -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
Reference in New Issue
Block a user