mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
fix: restore dpad functionality ATV (#2335)
This commit is contained in:
@@ -74,9 +74,6 @@ private const val CREATE_FILE_ACTION_CODE = 2
|
||||
private const val OPEN_FILE_ACTION_CODE = 3
|
||||
private const val CHECK_NOTIFICATION_PERMISSION_ACTION_CODE = 4
|
||||
|
||||
private const val GAMEPAD_ENABLED = false
|
||||
private const val DPAD_SYNTHETIC_ENABLED = GAMEPAD_ENABLED
|
||||
|
||||
private const val PREFS_NOTIFICATION_PERMISSION_ASKED = "NOTIFICATION_PERMISSION_ASKED"
|
||||
private const val OPEN_FILE_AFTER_RESUME_DELAY_MS = 400L
|
||||
private const val KEY_PENDING_OPEN_FILE_URI = "pending_open_file_uri"
|
||||
@@ -316,17 +313,14 @@ class AmneziaActivity : QtActivity() {
|
||||
KeyEvent.KEYCODE_BUTTON_Y,
|
||||
KeyEvent.KEYCODE_BUTTON_START,
|
||||
KeyEvent.KEYCODE_BUTTON_SELECT -> {
|
||||
if (GAMEPAD_ENABLED) {
|
||||
nativeGamepadKeyEvent(0, keyCode, pressed)
|
||||
return true
|
||||
}
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_CENTER,
|
||||
KeyEvent.KEYCODE_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||
if (DPAD_SYNTHETIC_ENABLED) {
|
||||
val syntheticKeyCode = if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) KeyEvent.KEYCODE_ENTER else keyCode
|
||||
val synthetic = KeyEvent(
|
||||
event.downTime, event.eventTime, event.action, syntheticKeyCode,
|
||||
@@ -334,15 +328,12 @@ class AmneziaActivity : QtActivity() {
|
||||
event.flags, InputDevice.SOURCE_KEYBOARD
|
||||
)
|
||||
return super.dispatchKeyEvent(synthetic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.dispatchKeyEvent(event)
|
||||
}
|
||||
|
||||
|
||||
|
||||
private external fun nativeGamepadKeyEvent(deviceId: Int, keyCode: Int, pressed: Boolean)
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@@ -8,9 +8,10 @@ Item {
|
||||
id: root
|
||||
|
||||
property StackView stackView: StackView.view
|
||||
property bool enableTimer: true
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
if (visible && enableTimer) {
|
||||
timer.start()
|
||||
}
|
||||
}
|
||||
@@ -24,6 +25,6 @@ Item {
|
||||
FocusController.setFocusOnDefaultItem()
|
||||
}
|
||||
repeat: false // Stop the timer after one trigger
|
||||
running: true // Start the timer
|
||||
running: enableTimer // Start the timer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import "../Components"
|
||||
|
||||
PageType {
|
||||
id: root
|
||||
enableTimer: (SettingsController.isOnTv()) ? false : true
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
@@ -45,4 +46,22 @@ PageType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 250
|
||||
running: SettingsController.isOnTv()
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
startButton.forceActiveFocus()
|
||||
if (startButton.activeFocus) {
|
||||
running = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible && SettingsController.isOnTv()) {
|
||||
startButton.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user