mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fba54f2fd2 | ||
|
|
9555cb9f65 | ||
|
|
70d8fc6559 | ||
|
|
70c512693a | ||
|
|
43266b2923 | ||
|
|
9d85af7558 | ||
|
|
d905f03bf7 | ||
|
|
f13916ee25 |
No files matched your search
@@ -61,7 +61,7 @@ Compatibility and performance vary by device; hardware validation is limited. De
|
||||
|
||||
## Credits and licence
|
||||
|
||||
GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. Battle.net support is [@kayakyakr](https://github.com/kayakyakr)'s: it runs Blizzard's own Battle.net client, downloaded from Blizzard and not included, in Proton, and shows the key art from each game's [Battle.net Shop](https://shop.battle.net) page; without the Steam client its games see DroidDeck's pad as an Xbox 360 controller through `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`. Its games install from Stores through Blizzard's own Agent and the local HTTP API it serves, driven the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) drives it, with the requests described on [wowdev.wiki](https://wowdev.wiki/Agent); how other launchers find, install and start Blizzard games was read in [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader, without taking their code. The registry entries a GOG game's install script (`goggame-<id>.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. x86 AppImages packed with [sharun](https://github.com/VHSgunzo/sharun) by VHSgunzo (MIT) start because DroidDeck's own [FEX](https://github.com/FEX-Emu/FEX) build (MIT) puts the platform name under `AT_PLATFORM`, which sharun's [userland-execve](https://crates.io/crates/userland-execve) loader (MIT) requires; FEX filed it under `AT_BASE_PLATFORM`. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc/<pid>/mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. Games render with [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's own per-render-pass choice between tile memory and system memory, while the Steam client keeps `TU_DEBUG=sysmem`; [FEX](https://github.com/FEX-Emu/FEX)'s code disk cache was checked in its source and is already on through Proton. The proot fast path picks the guest name of a host file bound under several names in the order [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later) sorts its bindings, so links and `/proc/self/fd` read back as they do through proot. The session's [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) opens its sockets with the per-socket access settings documented in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions through its `access.rules`. Wine write watches use the userfaultLine truncated
|
||||
GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. Battle.net support is [@kayakyakr](https://github.com/kayakyakr)'s: it runs Blizzard's own Battle.net client, downloaded from Blizzard and not included, in Proton, and shows the key art from each game's [Battle.net Shop](https://shop.battle.net) page; without the Steam client its games see DroidDeck's pad as an Xbox 360 controller through `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`. Its games install from Stores through Blizzard's own Agent and the local HTTP API it serves, driven the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) drives it, with the requests described on [wowdev.wiki](https://wowdev.wiki/Agent); how other launchers find, install and start Blizzard games was read in [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader, without taking their code. The registry entries a GOG game's install script (`goggame-<id>.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. x86 AppImages packed with [sharun](https://github.com/VHSgunzo/sharun) by VHSgunzo (MIT) start because DroidDeck's own [FEX](https://github.com/FEX-Emu/FEX) build (MIT) puts the platform name under `AT_PLATFORM`, which sharun's [userland-execve](https://crates.io/crates/userland-execve) loader (MIT) requires; FEX filed it under `AT_BASE_PLATFORM`. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc/<pid>/mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. Games render with [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's own per-render-pass choice between tile memory and system memory, while the Steam client keeps `TU_DEBUG=sysmem`; [FEX](https://github.com/FEX-Emu/FEX)'s code disk cache was checked in its source and is already on through Proton. The proot fast path picks the guest name of a host file bound under several names in the order [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later) sorts its bindings, so links and `/proc/self/fd` read back as they do through proot. The session's [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) opens its sockets with the per-socket access settings documented in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions through its `access.rules`. Wine write watches use the userfaultLine truncated
|
||||
|
||||
XR glasses support builds on WinNative's VITURE glasses work. VITURE protocol details were checked against [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) by [@wheaney](https://github.com/wheaney), including the VITURE protocol header it ships, [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) by [@badicsalex](https://github.com/badicsalex) and the [go-macos/iokit VITURE package](https://pkg.go.dev/github.com/go-macos/iokit/viture); the optional VITURE SDK belongs to VITURE and is not included. RayNeo support adapts [@informalTechCode](https://github.com/informalTechCode)'s [RayNeo-Air-Series-3DoF-Scaffold](https://github.com/informalTechCode/RayNeo-Air-Series-3DoF-Scaffold) (Apache-2.0) and references [@verncat](https://github.com/verncat)'s [RayNeo-Air-3S-Pro-OpenVR](https://github.com/verncat/RayNeo-Air-3S-Pro-OpenVR) (MIT) and [Monado](https://gitlab.freedesktop.org/monado/monado) (BSL-1.0); see [docs/third-party/rayneo](docs/third-party/rayneo/README.md). XREAL 1S support references [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) and [xrealOneDeviceKit](https://github.com/wheaney/xrealOneDeviceKit) by @wheaney, [xreal_one_driver](https://github.com/rohitsangwan01/xreal_one_driver) by [@rohitsangwan01](https://github.com/rohitsangwan01) (MIT) and [xr-tools](https://github.com/0xcaff/xr-tools) by [@0xcaff](https://github.com/0xcaff). Rokid support follows the Rokid protocol notes in [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) and @badicsalex's [Void Computing write-ups](https://voidcomputing.hu/blog/worse-better-prettier/), and [Monado](https://gitlab.freedesktop.org/monado/monado)'s Rokid driver. The REDMAGIC glasses-display findings draw on [@mekhontsev](https://github.com/mekhontsev)'s [MagicDesk investigation](https://github.com/mekhontsev/magicdesk/blob/main/docs/xr-resolution-fix.md) and [@Coding-BR](https://github.com/Coding-BR)'s [decompiled Nubia kernel](https://github.com/Coding-BR/android_kernel_nubia_sm8850_qwjujube). VITURE, RayNeo, XREAL, Rokid and REDMAGIC are trademarks of their owners; this project is not affiliated with them.
|
||||
|
||||
|
||||
@@ -58,6 +58,15 @@
|
||||
<meta-data android:name="android.game_mode_config" android:resource="@xml/game_mode_config" />
|
||||
<service android:name=".glasses.LumaRgbCaptureService" android:exported="false"
|
||||
android:process=":rgb_diagnostic" />
|
||||
<service android:name=".input.HomeButtonService"
|
||||
android:label="@string/integration_shortcuts_service"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accessibilityservice" android:resource="@xml/home_button_service" />
|
||||
</service>
|
||||
<meta-data android:name="com.oculus.supportedDevices" android:value="quest2|quest3|quest3s" />
|
||||
<activity android:name=".QuestXrActivity" android:exported="true" android:launchMode="singleTask"
|
||||
android:permission="android.permission.DUMP"
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.droiddeck.launcher.core.PhantomProcessLimit
|
||||
import com.droiddeck.launcher.core.PhantomProcessStatus
|
||||
import com.droiddeck.launcher.core.WirelessAdbFix
|
||||
import com.droiddeck.launcher.core.WifiDiscovery
|
||||
import com.droiddeck.launcher.core.SteamIntegration
|
||||
import com.droiddeck.launcher.core.WirelessAdbPairingService
|
||||
import com.droiddeck.launcher.ui.CoreRow
|
||||
import com.droiddeck.launcher.ui.PerformancePage
|
||||
@@ -197,6 +198,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
private var wifiDiscoveryLocation by mutableStateOf(false)
|
||||
private var wifiDiscoveryAsked by mutableStateOf(false)
|
||||
private var wifiDiscoveryBlocked by mutableStateOf(false)
|
||||
private var integrationState by mutableStateOf(SteamIntegration.State())
|
||||
private var integrationFocus by mutableStateOf<SteamIntegration.Feature?>(null)
|
||||
private val wifiLocationReceiver = object : android.content.BroadcastReceiver() {
|
||||
override fun onReceive(context: android.content.Context?, intent: Intent?) {
|
||||
refreshWifiDiscovery()
|
||||
@@ -265,8 +268,65 @@ class FrontEndActivity : ComponentActivity() {
|
||||
SessionPrefs.setWifiDiscoveryEnabled(this, false)
|
||||
}
|
||||
wifiDiscovery = SessionPrefs.wifiDiscoveryEnabled(this)
|
||||
integrationState = readIntegration()
|
||||
}
|
||||
|
||||
private var shortcutsTried = false
|
||||
|
||||
private fun readIntegration() = SteamIntegration.read(this)
|
||||
.copy(locationBlocked = wifiDiscoveryBlocked, shortcutsTried = shortcutsTried)
|
||||
|
||||
private fun openIntegration(feature: SteamIntegration.Feature? = null) {
|
||||
SteamIntegration.dismissSuggestion(this)
|
||||
refreshWifiDiscovery()
|
||||
integrationState = readIntegration()
|
||||
integrationFocus = feature
|
||||
navRequest = "setup:integration"
|
||||
}
|
||||
|
||||
private fun readIntegrationIntent(incoming: Intent) {
|
||||
if (incoming.action != SteamIntegration.ACTION_SETUP) return
|
||||
openIntegration(incoming.getStringExtra(SteamIntegration.EXTRA_FEATURE)?.let {
|
||||
runCatching { SteamIntegration.Feature.valueOf(it) }.getOrNull()
|
||||
})
|
||||
}
|
||||
|
||||
private fun integrationSettings(intent: Intent, fallback: String = android.provider.Settings.ACTION_SETTINGS) {
|
||||
try { startActivity(intent) }
|
||||
catch (_: android.content.ActivityNotFoundException) { startActivity(Intent(fallback)) }
|
||||
catch (_: SecurityException) { startActivity(Intent(fallback)) }
|
||||
}
|
||||
|
||||
private fun configureIntegration(feature: SteamIntegration.Feature) {
|
||||
when (feature) {
|
||||
SteamIntegration.Feature.WIFI -> {
|
||||
if (wifiDiscovery && wifiDiscoveryPermission) {
|
||||
SessionPrefs.setWifiDiscoveryEnabled(this, false)
|
||||
} else if (wifiDiscoveryPermission) {
|
||||
SessionPrefs.setWifiDiscoveryEnabled(this, true)
|
||||
} else {
|
||||
SessionPrefs.setWifiDiscoveryAsked(this)
|
||||
wifiLocationPermission.launch(WifiDiscovery.permissions)
|
||||
}
|
||||
refreshWifiDiscovery()
|
||||
}
|
||||
SteamIntegration.Feature.BRIGHTNESS -> integrationSettings(SteamIntegration.brightnessSettings(this))
|
||||
SteamIntegration.Feature.HOME -> if (HomeApp.isDefault(this)) HomeApp.openSystemHomeSettings(this) else {
|
||||
HomeApp.setHomeScreenEnabled(this, true)
|
||||
refreshHomeAppState()
|
||||
manageHomeApp()
|
||||
}
|
||||
SteamIntegration.Feature.SHORTCUTS -> {
|
||||
if (!integrationState.shortcuts) shortcutsTried = true
|
||||
if (!HomeApp.isDefault(this)) configureIntegration(SteamIntegration.Feature.HOME)
|
||||
else integrationSettings(SteamIntegration.shortcutSettings(this), android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun openAppInfo() =
|
||||
integrationSettings(Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:$packageName")))
|
||||
|
||||
private fun openWifiDiscoverySettings() {
|
||||
if (!WifiDiscovery.permissionGranted(this)) {
|
||||
wifiPermissionSettings.launch(Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
@@ -839,6 +899,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (savedInstanceState == null) readIntegrationIntent(intent)
|
||||
readGameIntent(intent)
|
||||
gameSyncFolder = GameFileSync.folder(this)
|
||||
displayManager = getSystemService(DISPLAY_SERVICE) as DisplayManager
|
||||
@@ -905,6 +966,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
isHomeApp = homeAppSelected,
|
||||
homeScreenEnabled = homeScreenEnabled,
|
||||
defaultHomeLabel = defaultHomeLabel,
|
||||
integration = integrationState,
|
||||
integrationFocus = integrationFocus,
|
||||
androidApps = androidApps,
|
||||
secondScreenDisplays = secondScreenDisplays,
|
||||
packages = packageRows,
|
||||
@@ -1144,6 +1207,14 @@ class FrontEndActivity : ComponentActivity() {
|
||||
downloadProxy = DownloadSource.proxyHostPort(this)
|
||||
},
|
||||
onHomeApp = { manageHomeApp() },
|
||||
onSteamIntegration = ::openIntegration,
|
||||
onIntegration = { integrationFocus = null; configureIntegration(it) },
|
||||
onIntegrationAppInfo = ::openAppInfo,
|
||||
onIntegrationLocation = ::openWifiDiscoverySettings,
|
||||
onDismissIntegration = {
|
||||
SteamIntegration.dismissSuggestion(this)
|
||||
integrationState = readIntegration()
|
||||
},
|
||||
onHomeScreen = { on ->
|
||||
HomeApp.setHomeScreenEnabled(this, on)
|
||||
refreshHomeAppState()
|
||||
@@ -1336,6 +1407,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
setIntent(intent)
|
||||
if (intent.action == SteamIntegration.ACTION_SETUP) {
|
||||
readIntegrationIntent(intent)
|
||||
return
|
||||
}
|
||||
readGameIntent(intent)
|
||||
refresh()
|
||||
startSteamAtStartupIfEnabled()
|
||||
@@ -1521,6 +1596,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
homeAppSelected = homeScreenEnabled && HomeApp.isDefault(this)
|
||||
defaultHomeLabel = HomeApp.defaultLabel(this)
|
||||
androidApps = if (homeAppSelected) HomeApp.launchableApps(this) else emptyList()
|
||||
integrationState = readIntegration()
|
||||
}
|
||||
|
||||
private fun refreshSecondScreenDisplays() {
|
||||
@@ -1844,11 +1920,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
bootMovieCustomName = bootMovieCustomName,
|
||||
bootMovieImporting = bootMovieImporting,
|
||||
bootMovieProgress = bootMovieProgress,
|
||||
wifiDiscovery = if (mode == SessionService.MODE_STEAM) wifiDiscovery else null,
|
||||
wifiDiscoveryPermission = wifiDiscoveryPermission,
|
||||
wifiDiscoveryLocation = wifiDiscoveryLocation,
|
||||
wifiDiscoveryAsked = wifiDiscoveryAsked,
|
||||
wifiDiscoveryBlocked = wifiDiscoveryBlocked,
|
||||
integration = if (mode == SessionService.MODE_STEAM) integrationState else null,
|
||||
deckyInstalled = if (mode == SessionService.MODE_STEAM) decky.deckyInstalled else null,
|
||||
deckyLatestRelease = if (mode == SessionService.MODE_STEAM) decky.deckyLatest else null,
|
||||
deckyBranch = decky.deckyBranch,
|
||||
@@ -1857,21 +1929,9 @@ class FrontEndActivity : ComponentActivity() {
|
||||
deckyEnabled = decky.deckySupervisor, deckySessionRunning = SessionState.running,
|
||||
),
|
||||
ModeSettingsActions(
|
||||
onWifiDiscovery = { on ->
|
||||
if (!on) {
|
||||
SessionPrefs.setWifiDiscoveryEnabled(this, false)
|
||||
refreshWifiDiscovery()
|
||||
} else if (WifiDiscovery.permissionGranted(this)) {
|
||||
SessionPrefs.setWifiDiscoveryEnabled(this, true)
|
||||
refreshWifiDiscovery()
|
||||
} else if (wifiDiscoveryBlocked) {
|
||||
openWifiDiscoverySettings()
|
||||
} else {
|
||||
SessionPrefs.setWifiDiscoveryAsked(this)
|
||||
wifiLocationPermission.launch(WifiDiscovery.permissions)
|
||||
}
|
||||
},
|
||||
onWifiDiscoverySettings = { openWifiDiscoverySettings() },
|
||||
onIntegration = ::configureIntegration,
|
||||
onIntegrationAppInfo = ::openAppInfo,
|
||||
onIntegrationLocation = ::openWifiDiscoverySettings,
|
||||
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); resolution = value },
|
||||
onHdr = { on -> SessionPrefs.setHdr(this, mode, on); hdrOn = on },
|
||||
onGpuDrivers = { openComponents(focusContent = true, tab = com.droiddeck.launcher.ui.GPU_TAB) },
|
||||
|
||||
@@ -788,6 +788,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
LaunchedEffect(drawerOpen, pcKeyboardOpen, achievementsOpen, gestureSettingsOpen, pipUi, SessionState.suspended) {
|
||||
if (drawerOpen || pcKeyboardOpen || achievementsOpen || gestureSettingsOpen || pipUi || SessionState.suspended) {
|
||||
backQamInput.cancel()
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this@SessionActivity)
|
||||
cancelTouchGestures()
|
||||
screenKeys?.stopEditing()
|
||||
}
|
||||
@@ -2127,6 +2128,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private fun releasePads() {
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this)
|
||||
backQamInput.cancel()
|
||||
padBridge?.releaseAll()
|
||||
joyConVr?.releaseButtons()
|
||||
@@ -3277,6 +3279,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
onScreenControls?.reload()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
resumed = true
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.attach(this,
|
||||
enabled = {
|
||||
resumed && window.decorView.hasWindowFocus() && !ended && !drawerOpen && !pcKeyboardOpen &&
|
||||
!achievementsOpen && !gestureSettingsOpen && !pipUi && SessionState.running && !SessionState.suspended &&
|
||||
SessionState.mode == SessionService.MODE_STEAM && padBridge?.canHoldGuide() == true
|
||||
},
|
||||
setPressed = { padBridge?.setHomeGuidePressed(it) },
|
||||
onCancel = { padBridge?.cancelHomeGuide() },
|
||||
)
|
||||
updatePointerCapture()
|
||||
if (!pipUi) sessionClipboard.start()
|
||||
updatePadMotion()
|
||||
@@ -3288,6 +3299,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this)
|
||||
if (runtimeRemovalBlocked) { super.onPause(); return }
|
||||
backQamInput.cancel()
|
||||
capturePausedFrame()
|
||||
@@ -3673,6 +3685,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (!hasFocus) com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this)
|
||||
if (!hasFocus) backQamInput.cancel()
|
||||
if (!hasFocus && ::padMouse.isInitialized) padMouse.reset()
|
||||
if (runtimeRemovalBlocked) return
|
||||
@@ -3721,6 +3734,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this)
|
||||
backQamInput.cancel()
|
||||
steamVrRecovery.close()
|
||||
uiHandler.removeCallbacks(steamTouchRetry)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import android.view.accessibility.AccessibilityManager
|
||||
import com.droiddeck.launcher.HomeApp
|
||||
import com.droiddeck.launcher.input.HomeButtonService
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
object SteamIntegration {
|
||||
const val ACTION_SETUP = "com.droiddeck.launcher.STEAM_INTEGRATION"
|
||||
const val EXTRA_FEATURE = "integration_feature"
|
||||
enum class Feature { WIFI, BRIGHTNESS, HOME, SHORTCUTS }
|
||||
|
||||
data class State(
|
||||
val wifi: Boolean = false,
|
||||
val locationPermission: Boolean = false,
|
||||
val locationOn: Boolean = false,
|
||||
val locationBlocked: Boolean = false,
|
||||
val brightness: Boolean = false,
|
||||
val home: Boolean = false,
|
||||
val shortcuts: Boolean = false,
|
||||
val shortcutsRestricted: Boolean = false,
|
||||
val shortcutsTried: Boolean = false,
|
||||
val suggested: Boolean = true,
|
||||
)
|
||||
|
||||
fun read(context: Context) = State(
|
||||
wifi = SessionPrefs.wifiDiscoveryEnabled(context),
|
||||
locationPermission = WifiDiscovery.permissionGranted(context),
|
||||
locationOn = WifiDiscovery.locationEnabled(context),
|
||||
brightness = Settings.System.canWrite(context),
|
||||
home = HomeApp.isDefault(context),
|
||||
shortcuts = context.getSystemService(AccessibilityManager::class.java)
|
||||
.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK).any {
|
||||
val service = it.resolveInfo.serviceInfo
|
||||
ComponentName(service.packageName, service.name) == ComponentName(context, HomeButtonService::class.java)
|
||||
},
|
||||
shortcutsRestricted = restrictedSettings(context),
|
||||
suggested = !SessionPrefs.sessionPrefs(context).getBoolean("steam_integration_seen", false),
|
||||
)
|
||||
|
||||
// Android 13+ blocks accessibility services for sideloaded APKs until the user allows restricted settings in App info.
|
||||
// MODE_DEFAULT is inconclusive on Android 15, so only an explicit denial counts here.
|
||||
private fun restrictedSettings(context: Context): Boolean {
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.TIRAMISU) return false
|
||||
val mode = runCatching {
|
||||
context.getSystemService(android.app.AppOpsManager::class.java)
|
||||
.unsafeCheckOpNoThrow("android:access_restricted_settings", android.os.Process.myUid(), context.packageName)
|
||||
}.getOrDefault(android.app.AppOpsManager.MODE_ALLOWED)
|
||||
return mode == android.app.AppOpsManager.MODE_ERRORED || mode == android.app.AppOpsManager.MODE_IGNORED
|
||||
}
|
||||
|
||||
fun dismissSuggestion(context: Context) {
|
||||
SessionPrefs.sessionPrefs(context).edit().putBoolean("steam_integration_seen", true).apply()
|
||||
}
|
||||
|
||||
fun brightnessSettings(context: Context) = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS,
|
||||
Uri.parse("package:${context.packageName}"))
|
||||
|
||||
// ACCESSIBILITY_DETAILS_SETTINGS is restricted to system apps; the fragment args key highlights our entry in the list.
|
||||
fun shortcutSettings(context: Context): Intent {
|
||||
val service = ComponentName(context, HomeButtonService::class.java).flattenToString()
|
||||
return Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||
.putExtra(":settings:fragment_args_key", service)
|
||||
.putExtra(":settings:show_fragment_args", android.os.Bundle().apply { putString(":settings:fragment_args_key", service) })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.accessibilityservice.AccessibilityService
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.hardware.input.InputManager
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.KeyEvent
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import com.droiddeck.launcher.HomeApp
|
||||
|
||||
object HomeButtonShortcuts {
|
||||
private var owner: Any? = null
|
||||
private var enabled: () -> Boolean = { false }
|
||||
private var setPressed: (Boolean) -> Unit = {}
|
||||
private var onCancel: () -> Unit = {}
|
||||
private val input = HomeGuideInput({ setPressed(it) }, { onCancel() })
|
||||
|
||||
fun attach(owner: Any, enabled: () -> Boolean, setPressed: (Boolean) -> Unit, onCancel: () -> Unit) {
|
||||
input.cancel()
|
||||
this.owner = owner
|
||||
this.enabled = enabled
|
||||
this.setPressed = setPressed
|
||||
this.onCancel = onCancel
|
||||
}
|
||||
|
||||
fun cancel(owner: Any) { if (this.owner === owner) input.cancel() }
|
||||
|
||||
fun detach(owner: Any) {
|
||||
if (this.owner !== owner) return
|
||||
input.cancel()
|
||||
this.owner = null
|
||||
enabled = { false }
|
||||
setPressed = {}
|
||||
onCancel = {}
|
||||
}
|
||||
|
||||
fun onKeyEvent(context: Context, event: KeyEvent): Boolean {
|
||||
if (event.keyCode != KeyEvent.KEYCODE_HOME) return false
|
||||
return input.onKeyEvent(event, enabled() && HomeApp.isDefault(context))
|
||||
}
|
||||
|
||||
fun release() = input.cancel()
|
||||
fun onDeviceRemoved(device: Int) = input.onDeviceRemoved(device)
|
||||
}
|
||||
|
||||
class HomeButtonService : AccessibilityService(), InputManager.InputDeviceListener {
|
||||
override fun onServiceConnected() {
|
||||
getSystemService(InputManager::class.java).registerInputDeviceListener(this, Handler(Looper.getMainLooper()))
|
||||
}
|
||||
|
||||
override fun onKeyEvent(event: KeyEvent) = HomeButtonShortcuts.onKeyEvent(this, event)
|
||||
override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
|
||||
override fun onInterrupt() { HomeButtonShortcuts.release() }
|
||||
override fun onInputDeviceAdded(deviceId: Int) {}
|
||||
override fun onInputDeviceChanged(deviceId: Int) {}
|
||||
override fun onInputDeviceRemoved(deviceId: Int) { HomeButtonShortcuts.onDeviceRemoved(deviceId) }
|
||||
|
||||
override fun onUnbind(intent: Intent?): Boolean {
|
||||
HomeButtonShortcuts.release()
|
||||
return super.onUnbind(intent)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
HomeButtonShortcuts.release()
|
||||
getSystemService(InputManager::class.java).unregisterInputDeviceListener(this)
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.view.KeyEvent
|
||||
|
||||
class HomeGuideInput(private val setPressed: (Boolean) -> Unit, private val onCancel: () -> Unit = {}) {
|
||||
private val presses = mutableSetOf<Int>()
|
||||
private val cancelled = mutableSetOf<Int>()
|
||||
|
||||
fun onKeyEvent(event: KeyEvent, enabled: Boolean): Boolean {
|
||||
if (event.keyCode != KeyEvent.KEYCODE_HOME) return false
|
||||
if (!enabled) cancel()
|
||||
val device = event.deviceId
|
||||
return when (event.action) {
|
||||
KeyEvent.ACTION_DOWN -> {
|
||||
if (event.repeatCount > 0) return device in presses || device in cancelled
|
||||
cancelled.remove(device)
|
||||
if (!enabled || event.isCanceled) return false
|
||||
if (presses.add(device) && presses.size == 1) setPressed(true)
|
||||
true
|
||||
}
|
||||
KeyEvent.ACTION_UP -> {
|
||||
val owned = presses.remove(device)
|
||||
val wasCancelled = cancelled.remove(device)
|
||||
if (owned && presses.isEmpty()) setPressed(false)
|
||||
owned || wasCancelled
|
||||
}
|
||||
else -> device in presses || device in cancelled
|
||||
}
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
val held = presses.isNotEmpty()
|
||||
cancelled.addAll(presses)
|
||||
presses.clear()
|
||||
if (held) { onCancel(); setPressed(false) }
|
||||
}
|
||||
|
||||
fun onDeviceRemoved(device: Int) {
|
||||
cancelled.remove(device)
|
||||
if (presses.remove(device) && presses.isEmpty()) { onCancel(); setPressed(false) }
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ public final class PadBridge {
|
||||
private boolean systemGuidePressed;
|
||||
private boolean systemQamPressed;
|
||||
private boolean backQamPressed;
|
||||
private boolean homeGuidePressed;
|
||||
private final PadState lastBackQamReport = new PadState();
|
||||
private final PadState lastWrittenReport = new PadState();
|
||||
private boolean backQamAxesBlocked;
|
||||
@@ -136,6 +137,7 @@ public final class PadBridge {
|
||||
}
|
||||
|
||||
private void resetBuiltin() {
|
||||
homeGuidePressed = false;
|
||||
clearBackQamWrites();
|
||||
routedTouch.clear();
|
||||
systemGuidePressed = false;
|
||||
@@ -159,6 +161,7 @@ public final class PadBridge {
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
homeGuidePressed = false;
|
||||
clearBackQamWrites();
|
||||
releaseBackPaddles();
|
||||
activeControllerId = NO_CONTROLLER;
|
||||
@@ -481,6 +484,7 @@ public final class PadBridge {
|
||||
}
|
||||
|
||||
public synchronized void releaseAll() {
|
||||
homeGuidePressed = false;
|
||||
clearBackQamWrites();
|
||||
routedTouch.clear();
|
||||
backQamPressed = false;
|
||||
@@ -508,10 +512,33 @@ public final class PadBridge {
|
||||
return builtinPad && nativeQam();
|
||||
}
|
||||
|
||||
public boolean canHoldGuide() {
|
||||
return builtinPad;
|
||||
}
|
||||
|
||||
public synchronized void setHomeGuidePressed(boolean pressed) {
|
||||
if (pressed && !canHoldGuide()) return;
|
||||
if (homeGuidePressed == pressed) return;
|
||||
homeGuidePressed = pressed;
|
||||
updateHeldModifier(PadState.GUIDE, pressed);
|
||||
}
|
||||
|
||||
public synchronized void cancelHomeGuide() {
|
||||
if (!homeGuidePressed) return;
|
||||
clearBackQamWrites();
|
||||
homeGuidePressed = false;
|
||||
state.clear();
|
||||
publish();
|
||||
}
|
||||
|
||||
public synchronized void setBackQamPressed(boolean pressed) {
|
||||
if (pressed && !canHoldQam()) return;
|
||||
if (backQamPressed == pressed) return;
|
||||
backQamPressed = pressed;
|
||||
updateHeldModifier(PadState.QAM, pressed);
|
||||
}
|
||||
|
||||
private void updateHeldModifier(int button, boolean pressed) {
|
||||
if (pressed && (open || start())) {
|
||||
backQamAxesBlocked = false;
|
||||
long now = android.os.SystemClock.uptimeMillis();
|
||||
@@ -519,10 +546,10 @@ public final class PadBridge {
|
||||
backQamDelayMs = modifierAt - now + QAM_GUIDE_LEAD_MIN_MS;
|
||||
PadState modifier = new PadState();
|
||||
modifier.copyFrom(lastBackQamReport);
|
||||
modifier.press(PadState.QAM, true);
|
||||
modifier.press(button, true);
|
||||
writeBackQamReport(modifier, modifierAt);
|
||||
}
|
||||
if (!pressed) {
|
||||
if (!pressed && !backQamPressed && !homeGuidePressed) {
|
||||
backQamAxesBlocked = hasAxes(state);
|
||||
if (!backQamWrites.isEmpty()) {
|
||||
PadState neutral = new PadState();
|
||||
@@ -578,7 +605,7 @@ public final class PadBridge {
|
||||
if (backQamAxesBlocked && !hasAxes(state)) backQamAxesBlocked = false;
|
||||
long at = android.os.SystemClock.uptimeMillis();
|
||||
// Steam must see the modifier before a partner; preserve quick press/release pairs in order.
|
||||
if (backQamPressed || !backQamWrites.isEmpty()) at += backQamDelayMs;
|
||||
if (backQamPressed || homeGuidePressed || !backQamWrites.isEmpty()) at += backQamDelayMs;
|
||||
writeBackQamReport(report, at);
|
||||
}
|
||||
|
||||
@@ -609,7 +636,8 @@ public final class PadBridge {
|
||||
live.rightX = state.rightX; live.rightY = state.rightY;
|
||||
live.leftTrigger = state.leftTrigger; live.rightTrigger = state.rightTrigger;
|
||||
}
|
||||
if ((queued && (!backQamPressed || !report.isDown(PadState.QAM))) || backQamAxesBlocked) clearAxes(live);
|
||||
boolean held = (backQamPressed && report.isDown(PadState.QAM)) || (homeGuidePressed && report.isDown(PadState.GUIDE));
|
||||
if ((queued && !held) || backQamAxesBlocked) clearAxes(live);
|
||||
lastWrittenReport.copyFrom(live);
|
||||
writer.writePad(live);
|
||||
}
|
||||
@@ -821,7 +849,7 @@ public final class PadBridge {
|
||||
statDropped++;
|
||||
return;
|
||||
}
|
||||
boolean guide = systemGuidePressed || qamChordActive;
|
||||
boolean guide = systemGuidePressed || qamChordActive || homeGuidePressed;
|
||||
boolean qam = nativeQam() && (systemQamPressed || qamTapPressed || backQamPressed);
|
||||
if (!guide && !qam) {
|
||||
writePad(state);
|
||||
|
||||
@@ -8,11 +8,9 @@ import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.database.ContentObserver
|
||||
import android.media.AudioManager
|
||||
import android.net.Uri
|
||||
import android.os.FileObserver
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.SystemClock
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.SessionPart
|
||||
@@ -29,8 +27,7 @@ class DeviceControlsComponent(context: Context, root: File, private val activity
|
||||
private val directory = directory(root)
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var running = false
|
||||
private var pendingBrightness: Float? = null
|
||||
private var permissionRequestAt = -5_000L
|
||||
private var permissionNotified = false
|
||||
private var previous = ""
|
||||
private var revision = 0L
|
||||
init { prepareBacklight(context, root) }
|
||||
@@ -46,13 +43,8 @@ class DeviceControlsComponent(context: Context, root: File, private val activity
|
||||
override fun run() {
|
||||
if (!running) return
|
||||
consume()
|
||||
pendingBrightness?.let { value ->
|
||||
if (Settings.System.canWrite(context)) {
|
||||
pendingBrightness = null
|
||||
context.getSystemService(NotificationManager::class.java).cancel(PERMISSION_NOTIFICATION)
|
||||
brightness(value)
|
||||
}
|
||||
}
|
||||
if (permissionNotified && Settings.System.canWrite(context))
|
||||
context.getSystemService(NotificationManager::class.java).cancel(PERMISSION_NOTIFICATION)
|
||||
publish()
|
||||
handler.postDelayed(this, 250)
|
||||
}
|
||||
@@ -86,6 +78,7 @@ class DeviceControlsComponent(context: Context, root: File, private val activity
|
||||
File(directory, "$it.processing").delete()
|
||||
}
|
||||
running = true
|
||||
permissionNotified = false
|
||||
context.contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, observer)
|
||||
requests.startWatching()
|
||||
refresh.run()
|
||||
@@ -98,7 +91,6 @@ class DeviceControlsComponent(context: Context, root: File, private val activity
|
||||
handler.removeCallbacks(refresh)
|
||||
requests.stopWatching()
|
||||
context.contentResolver.unregisterContentObserver(observer)
|
||||
pendingBrightness = null
|
||||
context.getSystemService(NotificationManager::class.java).cancel(PERMISSION_NOTIFICATION)
|
||||
}
|
||||
}
|
||||
@@ -134,13 +126,13 @@ class DeviceControlsComponent(context: Context, root: File, private val activity
|
||||
|
||||
private fun brightness(value: Float) {
|
||||
if (!Settings.System.canWrite(context)) {
|
||||
pendingBrightness = value
|
||||
val now = SystemClock.elapsedRealtime()
|
||||
if (now - permissionRequestAt >= 5_000) {
|
||||
permissionRequestAt = now
|
||||
if (!permissionNotified) {
|
||||
permissionNotified = true
|
||||
try {
|
||||
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS,
|
||||
Uri.parse("package:${context.packageName}")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
val intent = Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java)
|
||||
.setAction(com.droiddeck.launcher.core.SteamIntegration.ACTION_SETUP)
|
||||
.putExtra(com.droiddeck.launcher.core.SteamIntegration.EXTRA_FEATURE, "BRIGHTNESS")
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
val manager = context.getSystemService(NotificationManager::class.java)
|
||||
manager.createNotificationChannel(NotificationChannel(PERMISSION_CHANNEL,
|
||||
context.getString(R.string.brightness_permission_title), NotificationManager.IMPORTANCE_DEFAULT))
|
||||
@@ -150,7 +142,8 @@ class DeviceControlsComponent(context: Context, root: File, private val activity
|
||||
.setContentTitle(context.getString(R.string.brightness_permission_title))
|
||||
.setContentText(context.getString(R.string.brightness_permission_text))
|
||||
.setContentIntent(action).setOnlyAlertOnce(true).setAutoCancel(true).build())
|
||||
if (activityVisible()) context.startActivity(intent)
|
||||
if (activityVisible()) android.widget.Toast.makeText(context, R.string.integration_brightness_needed,
|
||||
android.widget.Toast.LENGTH_LONG).show()
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Could not open brightness permission", e)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ object StoresState {
|
||||
|
||||
fun detailItem(store: Store, id: String): CatalogItem? = detailCatalogItem(
|
||||
store, id, library[store].orEmpty(),
|
||||
found[store].orEmpty() + if (store == Store.ITCH) com.droiddeck.launcher.stores.itch.ItchBrowseState.items else emptyList(),
|
||||
found[store].orEmpty() + if (store == Store.ITCH) com.droiddeck.launcher.stores.itch.ItchBrowseState.items + com.droiddeck.launcher.stores.itch.ItchCollections.items() else emptyList(),
|
||||
shelves[store],
|
||||
)
|
||||
|
||||
@@ -191,6 +191,7 @@ object StoresState {
|
||||
backend?.signOut(app)
|
||||
if (store == Store.GOG) com.droiddeck.launcher.stores.gog.GogComet.replaceAccount { StoreAccounts.clear(app, store) }
|
||||
else if (store != Store.XBOX || backend == null) StoreAccounts.clear(app, store)
|
||||
if (store == Store.ITCH) com.droiddeck.launcher.stores.itch.ItchCollections.clear()
|
||||
main.post {
|
||||
if (store == Store.XBOX && StoreAccounts.signedInAs(app, store) != null) return@post
|
||||
accounts.remove(store); library.remove(store); status.remove(store); problems.remove(store); libraryAsked.remove(store)
|
||||
|
||||
@@ -19,6 +19,11 @@ internal object ItchApi {
|
||||
|
||||
fun ownedKeys(key: String, page: Int): JSONObject? = get("/profile/owned-keys?page=$page&per_page=500", key)
|
||||
|
||||
fun collections(key: String): JSONArray? = get("/profile/collections", key)?.optJSONArray("collections")
|
||||
|
||||
fun collectionGames(key: String, collectionId: String, page: Int): JSONObject? =
|
||||
get("/collections/$collectionId/collection-games?page=$page", key)
|
||||
|
||||
fun uploads(key: String, gameId: String, downloadKeyId: String): JSONArray? =
|
||||
get("/games/$gameId/uploads" + keyQuery(downloadKeyId), key)?.optJSONArray("uploads")
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.droiddeck.launcher.stores.itch
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class ItchCollection(val id: String, val title: String, val count: Int)
|
||||
|
||||
internal object ItchCollections {
|
||||
var list by mutableStateOf<List<ItchCollection>>(emptyList())
|
||||
private set
|
||||
var selected by mutableStateOf<String?>(null)
|
||||
private set
|
||||
private val games = mutableStateMapOf<String, List<CatalogItem>>()
|
||||
private val loading = ConcurrentHashMap.newKeySet<String>()
|
||||
@Volatile private var generation = 0
|
||||
|
||||
fun items(): List<CatalogItem> = games.values.flatten()
|
||||
|
||||
fun gamesOf(id: String): List<CatalogItem>? = games[id]
|
||||
|
||||
fun chosen(): ItchCollection? = list.firstOrNull { it.id == selected }
|
||||
|
||||
fun clear() {
|
||||
generation++
|
||||
StoresState.post {
|
||||
list = emptyList()
|
||||
selected = null
|
||||
games.clear()
|
||||
}
|
||||
}
|
||||
|
||||
fun load(context: Context) {
|
||||
val app = context.applicationContext
|
||||
val started = generation
|
||||
val guard = "$started:"
|
||||
if (!loading.add(guard)) return
|
||||
Thread({
|
||||
try {
|
||||
val key = ItchAuth.key(app)
|
||||
if (key.isBlank()) return@Thread
|
||||
val parsed = parseCollections(ItchApi.collections(key) ?: return@Thread)
|
||||
if (started != generation) return@Thread
|
||||
StoresState.post {
|
||||
if (started != generation) return@post
|
||||
list = parsed
|
||||
if (selected != null && parsed.none { it.id == selected }) selected = null
|
||||
}
|
||||
StoresState.logLine("itch.io: ${parsed.size} collections")
|
||||
selected?.let { fetchGames(key, it, started) }
|
||||
} finally {
|
||||
loading.remove(guard)
|
||||
}
|
||||
}, "itch-collections").start()
|
||||
}
|
||||
|
||||
fun select(context: Context, id: String?) {
|
||||
selected = id
|
||||
if (id == null) return
|
||||
val app = context.applicationContext
|
||||
val started = generation
|
||||
Thread({
|
||||
val key = ItchAuth.key(app)
|
||||
if (key.isNotBlank()) fetchGames(key, id, started)
|
||||
}, "itch-collection-games").start()
|
||||
}
|
||||
|
||||
private fun fetchGames(key: String, id: String, started: Int) {
|
||||
val guard = "$started:$id"
|
||||
if (!loading.add(guard)) return
|
||||
try {
|
||||
val out = ArrayList<CatalogItem>()
|
||||
val seen = HashSet<String>()
|
||||
var page = 1
|
||||
while (true) {
|
||||
val body = ItchApi.collectionGames(key, id, page)
|
||||
if (body == null) {
|
||||
StoresState.logLine("itch.io: collection $id page $page failed")
|
||||
return
|
||||
}
|
||||
val batch = parseGames(body)
|
||||
if (batch.isEmpty()) break
|
||||
val before = out.size
|
||||
out.addAll(batch.filter { seen.add(it.id) })
|
||||
if (out.size == before) break
|
||||
page++
|
||||
}
|
||||
val distinct = out.toList()
|
||||
StoresState.post { if (started == generation) games[id] = distinct }
|
||||
StoresState.logLine("itch.io: collection $id has ${distinct.size} games")
|
||||
} finally {
|
||||
loading.remove(guard)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun parseCollections(array: JSONArray): List<ItchCollection> = (0 until array.length()).mapNotNull { i ->
|
||||
val c = array.optJSONObject(i) ?: return@mapNotNull null
|
||||
val id = c.opt("id")?.toString().orEmpty().takeIf { it.isNotBlank() && it != "null" } ?: return@mapNotNull null
|
||||
val title = c.optString("title").ifBlank { return@mapNotNull null }
|
||||
ItchCollection(id, title, c.optInt("games_count", c.optInt("gamesCount")))
|
||||
}
|
||||
|
||||
internal fun parseGames(body: JSONObject): List<CatalogItem> {
|
||||
val rows = body.optJSONArray("collection_games") ?: body.optJSONArray("collectionGames") ?: return emptyList()
|
||||
return (0 until rows.length()).mapNotNull { i ->
|
||||
rows.optJSONObject(i)?.optJSONObject("game")?.let { ItchLibrary.item(it, "") }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.graphics.vector.addPathNodes
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
internal val CollectionsIcon: ImageVector = ImageVector.Builder("Collections", 24.dp, 24.dp, 24f, 24f).apply {
|
||||
for (d in listOf(
|
||||
"M2.65,4.6H7.33V22H2.65Z",
|
||||
"M8.32,2H13V22H8.32Z",
|
||||
"M13.9,5.4H18.5L21.4,22H16.8Z",
|
||||
)) addPath(addPathNodes(d), fill = SolidColor(Color.Black))
|
||||
}.build()
|
||||
@@ -121,6 +121,8 @@ class FrontEndState(
|
||||
val isHomeApp: Boolean = false,
|
||||
val homeScreenEnabled: Boolean = false,
|
||||
val defaultHomeLabel: String? = null,
|
||||
val integration: com.droiddeck.launcher.core.SteamIntegration.State = com.droiddeck.launcher.core.SteamIntegration.State(suggested = false),
|
||||
val integrationFocus: com.droiddeck.launcher.core.SteamIntegration.Feature? = null,
|
||||
val androidApps: List<HomeApp.LaunchableApp> = emptyList(),
|
||||
val secondScreenDisplays: List<SecondScreenDisplay> = emptyList(),
|
||||
val packages: List<PackageRow>? = null,
|
||||
@@ -237,6 +239,11 @@ class FrontEndActions(
|
||||
val onLibraryChanged: () -> Unit = {},
|
||||
val onHomeApp: () -> Unit = {},
|
||||
val onHomeScreen: (Boolean) -> Unit = {},
|
||||
val onSteamIntegration: (com.droiddeck.launcher.core.SteamIntegration.Feature?) -> Unit = {},
|
||||
val onDismissIntegration: () -> Unit = {},
|
||||
val onIntegration: (com.droiddeck.launcher.core.SteamIntegration.Feature) -> Unit = {},
|
||||
val onIntegrationAppInfo: () -> Unit = {},
|
||||
val onIntegrationLocation: () -> Unit = {},
|
||||
val onAndroidApp: (HomeApp.LaunchableApp, Int?) -> Unit = { _, _ -> },
|
||||
val onBackActionsInverted: (Boolean) -> Unit = {},
|
||||
val onRefreshPhantomStatus: () -> Unit = {},
|
||||
@@ -408,6 +415,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
"stores:downloads" -> { com.droiddeck.launcher.stores.StoresState.openDownloads = true; selected = "stores" }
|
||||
"components" -> a.onComponents(true)
|
||||
"setup:launcher" -> { SetupTabs.openLauncher = true; selected = "setup" }
|
||||
"setup:integration" -> { SetupTabs.openOverview = true; selected = "setup" }
|
||||
else -> selected = target
|
||||
}
|
||||
a.onNavigated()
|
||||
|
||||
@@ -91,6 +91,7 @@ private const val LAUNCHER_TAB = 2
|
||||
|
||||
internal object SetupTabs {
|
||||
var openLauncher = false
|
||||
var openOverview = false
|
||||
}
|
||||
private const val GLASSES_TAB = 5
|
||||
|
||||
@@ -191,6 +192,7 @@ internal fun SetupPanel(
|
||||
val tabs = listOf(stringResource(R.string.setup_tab_overview), stringResource(R.string.setup_tab_controller), stringResource(R.string.setup_tab_launcher), stringResource(R.string.setup_tab_storage), stringResource(R.string.setup_tab_diagnostics), stringResource(R.string.setup_tab_glasses))
|
||||
var tab by rememberSaveable { mutableStateOf(if (SetupTabs.openLauncher) LAUNCHER_TAB else 0) }
|
||||
SetupTabs.openLauncher = false
|
||||
if (SetupTabs.openOverview) { tab = 0; SetupTabs.openOverview = false }
|
||||
val chipFocus = remember { List(tabs.size) { FocusRequester() } }
|
||||
var tabTurned by remember { mutableStateOf(false) }
|
||||
val pick: (Int) -> Unit = { i -> tab = i; tabTurned = true }
|
||||
@@ -341,6 +343,7 @@ internal fun SetupPanel(
|
||||
}
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.setup_runtime)) { runtimeCheck(false) }
|
||||
SteamIntegrationGroup(s.integration, s.integrationFocus, a.onIntegration, a.onIntegrationAppInfo, a.onIntegrationLocation)
|
||||
}
|
||||
1 -> {
|
||||
val controller = s.controller
|
||||
|
||||
@@ -89,6 +89,8 @@ import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.arrangeStoreTabs
|
||||
import com.droiddeck.launcher.stores.download.DownloadEntry
|
||||
import com.droiddeck.launcher.stores.formatBytes
|
||||
import com.droiddeck.launcher.stores.itch.ItchCollection
|
||||
import com.droiddeck.launcher.stores.itch.ItchCollections
|
||||
import com.droiddeck.launcher.stores.retainOrder
|
||||
import com.droiddeck.launcher.stores.xbox.XboxLibraryFilter
|
||||
import com.droiddeck.launcher.stores.sortGames
|
||||
@@ -127,6 +129,14 @@ internal fun libraryEntries(
|
||||
return out.distinctBy { it.key }
|
||||
}
|
||||
|
||||
internal fun collectionEntries(all: List<LibraryEntry>, items: List<CatalogItem>): List<LibraryEntry> {
|
||||
val keys = items.map { it.key }.toSet()
|
||||
val itch = all.filter { it.source == Store.ITCH.id }
|
||||
val have = itch.mapNotNull { it.storeKey }.toSet()
|
||||
return itch.filter { it.storeKey in keys } +
|
||||
items.filter { it.key !in have }.map { LibraryEntry(GameRef.key(it), Store.ITCH.id, it.title, null, it, false) }
|
||||
}
|
||||
|
||||
internal fun installedFirst(entries: List<LibraryEntry>): List<LibraryEntry> = entries.partition { it.installed }.let { (on, off) -> on + off }
|
||||
|
||||
internal const val LIBRARY_ALL = "all"
|
||||
@@ -169,19 +179,30 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
val all = remember(s.steamGames, cloudRows, owned, installedStore) { libraryEntries(s.steamGames + cloudRows, owned, installedStore) }
|
||||
LaunchedEffect(Unit) { XboxLibraryFilter.load(ctx) }
|
||||
var showUninstalled by remember(LibraryView.ownedRequest) { mutableStateOf(SessionPrefs.libraryShowUninstalled(ctx)) }
|
||||
var collectionShows by remember { mutableStateOf<Pair<String, Boolean>?>(null) }
|
||||
val setShowUninstalled = { show: Boolean ->
|
||||
showUninstalled = show
|
||||
SessionPrefs.setLibraryShowUninstalled(ctx, show)
|
||||
val picked = ItchCollections.selected.takeIf { LibraryView.source == Store.ITCH.id }
|
||||
if (picked != null) collectionShows = picked to show
|
||||
else {
|
||||
showUninstalled = show
|
||||
SessionPrefs.setLibraryShowUninstalled(ctx, show)
|
||||
}
|
||||
}
|
||||
val sources = librarySources(all, SessionPrefs.storesTabOrder(ctx))
|
||||
val itchSignedIn = owned.containsKey(Store.ITCH)
|
||||
val listed = librarySources(all, SessionPrefs.storesTabOrder(ctx))
|
||||
val sources = if (itchSignedIn && Store.ITCH.id !in listed) listed + Store.ITCH.id else listed
|
||||
val source = LibraryView.source.takeIf { it == LIBRARY_ALL || it in sources } ?: LIBRARY_ALL
|
||||
val q = LibraryView.query.trim().lowercase()
|
||||
val xboxFilter = if (source == Store.XBOX.id) XboxLibraryFilter.current else XboxLibraryFilter.ALL
|
||||
val matching = all.filter {
|
||||
LaunchedEffect(source, itchSignedIn) { if (source == Store.ITCH.id && itchSignedIn) ItchCollections.load(ctx) }
|
||||
val collection = if (source == Store.ITCH.id) ItchCollections.chosen() else null
|
||||
val pool = if (collection == null) all else collectionEntries(all, ItchCollections.gamesOf(collection.id).orEmpty())
|
||||
val matching = pool.filter {
|
||||
(source == LIBRARY_ALL || it.source == source) && (q.isEmpty() || it.title.lowercase().contains(q)) && keepsXbox(xboxFilter, it)
|
||||
}
|
||||
val candidates = if (showUninstalled) matching else matching.filter { it.installed }
|
||||
val hiddenUninstalled = if (showUninstalled) 0 else matching.count { !it.installed }
|
||||
val listUninstalled = if (collection == null) showUninstalled else collectionShows?.takeIf { it.first == collection.id }?.second ?: true
|
||||
val candidates = if (listUninstalled) matching else matching.filter { it.installed }
|
||||
val hiddenUninstalled = if (listUninstalled) 0 else matching.count { !it.installed }
|
||||
val sort = s.storesSort
|
||||
val sizeSort = sort == "sizeAsc" || sort == "sizeDesc"
|
||||
val installedAt = StoresState.installed.associate { it.key to it.sidecar.installedAt }
|
||||
@@ -264,7 +285,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
kotlinx.coroutines.delay(Motion.ms(240).toLong())
|
||||
focusWithinFrames({ ff.last?.startsWith("card:") == true }) { if (ff.firstTileAttached > 0) ff.firstTile else FocusRequester.Default }
|
||||
}
|
||||
if (all.isEmpty() && open == null) {
|
||||
if (all.isEmpty() && open == null && !itchSignedIn) {
|
||||
LibraryEmpty(s, a, modifier)
|
||||
return
|
||||
}
|
||||
@@ -272,7 +293,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
val detailScroll = rememberScrollState()
|
||||
var cycled by remember { mutableIntStateOf(0) }
|
||||
var gridFocused by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(source, sort, showUninstalled) { grid.scrollToItem(0) }
|
||||
LaunchedEffect(source, sort, listUninstalled) { grid.scrollToItem(0) }
|
||||
LaunchedEffect(cycled) {
|
||||
if (cycled == 0 || ff == null || inputMode.inputMode != androidx.compose.ui.input.InputMode.Keyboard) return@LaunchedEffect
|
||||
focusWithinFrames({ gridFocused }) {
|
||||
@@ -288,7 +309,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
grid = {
|
||||
LibraryGrid(
|
||||
s, a, grid, visible, split, visible.size, sources, source, sizesPending, syncing,
|
||||
showUninstalled = showUninstalled.takeIf { stores }, onShowUninstalled = setShowUninstalled,
|
||||
showUninstalled = listUninstalled.takeIf { stores }, onShowUninstalled = setShowUninstalled,
|
||||
hiddenUninstalled = hiddenUninstalled,
|
||||
onSource = { LibraryView.source = it },
|
||||
onCycle = { step ->
|
||||
@@ -383,7 +404,7 @@ private fun LibraryGrid(
|
||||
contentPadding = PaddingValues(top = 4.dp, bottom = 16.dp),
|
||||
) {
|
||||
item(key = "header", span = { GridItemSpan(maxLineSpan) }) {
|
||||
Rise(0) { LibraryHeader(s, a, total, searchCleared, source == Store.XBOX.id, showUninstalled, onShowUninstalled) }
|
||||
Rise(0) { LibraryHeader(s, a, total, searchCleared, source == Store.XBOX.id, showUninstalled, onShowUninstalled, collections = source == Store.ITCH.id) }
|
||||
}
|
||||
item(key = "filters", span = { GridItemSpan(maxLineSpan) }) {
|
||||
Rise(1) { LibraryFilters(sources, source, onSource) }
|
||||
@@ -430,7 +451,7 @@ private fun LazyGridScope.libraryGrid(entries: List<LibraryEntry>, empty: Int, t
|
||||
@Composable
|
||||
private fun LibraryHeader(
|
||||
s: FrontEndState, a: FrontEndActions, total: Int, searchCleared: Boolean, xbox: Boolean,
|
||||
showUninstalled: Boolean?, onShowUninstalled: (Boolean) -> Unit,
|
||||
showUninstalled: Boolean?, onShowUninstalled: (Boolean) -> Unit, collections: Boolean,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val narrow = LocalNarrowPane.current
|
||||
@@ -447,6 +468,7 @@ private fun LibraryHeader(
|
||||
},
|
||||
) {
|
||||
if (showUninstalled != null || xbox) LibraryFilterButton(showUninstalled, onShowUninstalled, xbox)
|
||||
if (collections) CollectionsButton()
|
||||
SortButton(s, a)
|
||||
ViewButton(s, a)
|
||||
GameFileFolderActions(s, a)
|
||||
@@ -700,6 +722,39 @@ private fun LibraryFilterButton(showUninstalled: Boolean?, onShowUninstalled: (B
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CollectionsButton() {
|
||||
val pal = LocalPalette.current
|
||||
val ctx = LocalContext.current
|
||||
val title = stringResource(R.string.itch_collections)
|
||||
val all = stringResource(R.string.stores_tab_all)
|
||||
var at by remember { mutableStateOf<Rect?>(null) }
|
||||
Box(Modifier.onGloballyPositioned { at = it.boundsInRoot() }) {
|
||||
HeaderIconButton(title + " · " + (ItchCollections.chosen()?.title ?: all), CollectionsIcon, "itch-collections") {
|
||||
val from = at ?: return@HeaderIconButton
|
||||
val choices = listOf<ItchCollection?>(null) + ItchCollections.list
|
||||
Steps.ask(StepAsk(
|
||||
anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = choices.size,
|
||||
handle = { Icon(CollectionsIcon, null, tint = pal.signal, modifier = Modifier.size(18.dp)) },
|
||||
) {
|
||||
StepTitle(title)
|
||||
StepList {
|
||||
choices.forEachIndexed { i, c ->
|
||||
val picked = c?.id == ItchCollections.selected
|
||||
StepChoice(
|
||||
c?.let { it.title + " (" + it.count + ")" } ?: all, selected = picked, enabled = open,
|
||||
modifier = Modifier.fillMaxWidth().stepItem(i).then(if (picked) Modifier.focusRequester(first) else Modifier),
|
||||
) {
|
||||
ItchCollections.select(ctx, c?.id)
|
||||
Steps.fold()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SortButton(s: FrontEndState, a: FrontEndActions) {
|
||||
val pal = LocalPalette.current
|
||||
|
||||
@@ -96,11 +96,7 @@ class ModeSettings(
|
||||
val bootMovieCustomName: String? = null,
|
||||
val bootMovieImporting: Boolean = false,
|
||||
val bootMovieProgress: Int = -1,
|
||||
val wifiDiscovery: Boolean? = null,
|
||||
val wifiDiscoveryPermission: Boolean = false,
|
||||
val wifiDiscoveryLocation: Boolean = false,
|
||||
val wifiDiscoveryAsked: Boolean = false,
|
||||
val wifiDiscoveryBlocked: Boolean = false,
|
||||
val integration: com.droiddeck.launcher.core.SteamIntegration.State? = null,
|
||||
val deckyInstalled: String? = null,
|
||||
val deckyLatestRelease: DeckyManager.Release? = null,
|
||||
val deckyBranch: Int = DeckyManager.BRANCH_STABLE,
|
||||
@@ -148,8 +144,9 @@ class ModeSettingsActions(
|
||||
val onBootMovieSound: (Boolean) -> Unit = {},
|
||||
val onImportBootMovie: () -> Unit = {},
|
||||
val onBootMovieChanged: () -> Unit = {},
|
||||
val onWifiDiscovery: (Boolean) -> Unit = {},
|
||||
val onWifiDiscoverySettings: () -> Unit = {},
|
||||
val onIntegration: (com.droiddeck.launcher.core.SteamIntegration.Feature) -> Unit = {},
|
||||
val onIntegrationAppInfo: () -> Unit = {},
|
||||
val onIntegrationLocation: () -> Unit = {},
|
||||
val onDeckyInstall: (DeckyManager.Release) -> Unit = {},
|
||||
val onDeckyCheck: () -> Unit = {},
|
||||
val onDeckyBranch: (Int) -> Unit = {},
|
||||
@@ -208,7 +205,6 @@ class SheetExtras(
|
||||
fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras: SheetExtras = SheetExtras()) {
|
||||
val steam = s.mode == SessionService.MODE_STEAM
|
||||
val host = rememberMenuHost()
|
||||
var explainWifiDiscovery by remember { mutableStateOf(false) }
|
||||
if (tab == SheetTab.DISPLAY) {
|
||||
val context = LocalContext.current
|
||||
val portraitWindow = SessionPrefs.portrait(context)
|
||||
@@ -512,39 +508,9 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
)
|
||||
}
|
||||
if (s.bootMovie != null) BootMovieGroup(s, a, host)
|
||||
if (s.wifiDiscovery != null) SettingsGroup(stringResource(R.string.mode_network)) {
|
||||
val hint = when {
|
||||
s.wifiDiscovery && !s.wifiDiscoveryLocation -> stringResource(R.string.mode_wifi_location_off)
|
||||
!s.wifiDiscoveryPermission && s.wifiDiscoveryAsked -> stringResource(R.string.mode_wifi_permission_denied)
|
||||
else -> stringResource(R.string.mode_wifi_discovery_hint)
|
||||
}
|
||||
SettingsRow(stringResource(R.string.mode_wifi_discovery), hint) {
|
||||
Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,
|
||||
horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(8.dp)) {
|
||||
if (s.wifiDiscoveryBlocked || (s.wifiDiscovery && !s.wifiDiscoveryLocation)) {
|
||||
SecondaryButton(stringResource(R.string.mode_wifi_open_settings), onClick = a.onWifiDiscoverySettings)
|
||||
}
|
||||
ToggleSwitch(s.wifiDiscovery, label = stringResource(R.string.mode_wifi_discovery)) { on ->
|
||||
host.open = null
|
||||
if (on) explainWifiDiscovery = true else a.onWifiDiscovery(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (s.integration != null) SteamIntegrationGroup(s.integration,
|
||||
onFeature = a.onIntegration, onAppInfo = a.onIntegrationAppInfo, onLocation = a.onIntegrationLocation)
|
||||
}
|
||||
if (explainWifiDiscovery) AlertDialog(
|
||||
onDismissRequest = { explainWifiDiscovery = false },
|
||||
title = { Text(stringResource(R.string.mode_wifi_explain_title)) },
|
||||
text = { Text(stringResource(R.string.mode_wifi_explain_text)) },
|
||||
confirmButton = {
|
||||
TextButton(onClick = { explainWifiDiscovery = false; a.onWifiDiscovery(true) }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Text(stringResource(if (s.wifiDiscoveryBlocked) R.string.mode_wifi_open_settings else R.string.mode_wifi_continue))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { explainWifiDiscovery = false }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) }
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -422,7 +422,7 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsGroup(title: String, compact: Boolean = false, content: @Composable ColumnScope.() -> Unit) {
|
||||
fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, content: @Composable ColumnScope.() -> Unit) {
|
||||
val tight = compact || LocalCompactSettings.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -434,6 +434,7 @@ fun SettingsGroup(title: String, compact: Boolean = false, content: @Composable
|
||||
) {
|
||||
Text(title.uppercase(), fontSize = if (tight) 11.sp else 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = colors.onSurfaceVariant)
|
||||
Box(modifier = Modifier.weight(1f).height(1.dp).background(pal.line))
|
||||
if (detail != null) Text(detail, fontSize = if (tight) 11.sp else 12.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant)
|
||||
}
|
||||
Column(modifier = Modifier.fillMaxWidth().clip(GroupShape).background(colors.surface).border(1.dp, pal.line, GroupShape)) { content() }
|
||||
}
|
||||
|
||||
@@ -143,6 +143,8 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
|
||||
words = {
|
||||
val runtimeStatus: @Composable () -> Unit = {
|
||||
if (s.busy || !s.ready || (s.available != null && s.available != s.installed)) RuntimeChip(s)
|
||||
else if (s.integration.suggested && signedIn && !com.droiddeck.launcher.core.PhantomProcessLimit.blocksSteam(s.phantomProcessStatus))
|
||||
IntegrationSuggestion(s.integration, { a.onSteamIntegration(null) }, a.onDismissIntegration)
|
||||
}
|
||||
if (narrow) Column(
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.onPlaced { words = it.boundsInParent() },
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.relocation.bringIntoViewRequester
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.AutoAwesome
|
||||
import androidx.compose.material.icons.outlined.Close
|
||||
import androidx.compose.material.icons.outlined.Home
|
||||
import androidx.compose.material.icons.outlined.KeyboardCommandKey
|
||||
import androidx.compose.material.icons.outlined.LightMode
|
||||
import androidx.compose.material.icons.outlined.Wifi
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.SteamIntegration
|
||||
import com.droiddeck.launcher.core.SteamIntegration.Feature
|
||||
|
||||
private val BadgeShape = RoundedCornerShape(10.dp)
|
||||
|
||||
internal fun SteamIntegration.State.enabled(feature: Feature) = when (feature) {
|
||||
Feature.WIFI -> wifi && locationPermission && locationOn
|
||||
Feature.BRIGHTNESS -> brightness
|
||||
Feature.HOME -> home
|
||||
Feature.SHORTCUTS -> home && shortcuts
|
||||
}
|
||||
|
||||
internal fun SteamIntegration.State.enabledCount() = Feature.entries.count { enabled(it) }
|
||||
|
||||
@Composable
|
||||
internal fun SteamIntegrationGroup(
|
||||
state: SteamIntegration.State,
|
||||
focus: Feature? = null,
|
||||
onFeature: (Feature) -> Unit,
|
||||
onAppInfo: () -> Unit,
|
||||
onLocation: () -> Unit = {},
|
||||
) {
|
||||
SettingsGroup(
|
||||
stringResource(R.string.integration_title),
|
||||
detail = stringResource(R.string.integration_count, state.enabledCount(), Feature.entries.size),
|
||||
) {
|
||||
Feature.entries.forEachIndexed { i, feature ->
|
||||
IntegrationRow(state, feature, focus == feature, i < Feature.entries.lastIndex, onFeature, onAppInfo, onLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun IntegrationRow(
|
||||
state: SteamIntegration.State,
|
||||
feature: Feature,
|
||||
focused: Boolean,
|
||||
divider: Boolean,
|
||||
onFeature: (Feature) -> Unit,
|
||||
onAppInfo: () -> Unit,
|
||||
onLocation: () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val on = state.enabled(feature)
|
||||
var flash by remember { mutableStateOf(false) }
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
LaunchedEffect(focused) {
|
||||
if (focused) try { flash = true; reveal.bringIntoView(); kotlinx.coroutines.delay(1600) } finally { flash = false }
|
||||
}
|
||||
val bg by animateColorAsState(if (flash) pal.signal.copy(alpha = 0.12f) else Color.Transparent, Motion.tw(400), label = "integrationFlash")
|
||||
val wifiLocationOff = feature == Feature.WIFI && state.wifi && state.locationPermission && !state.locationOn
|
||||
val wifiDenied = feature == Feature.WIFI && !state.locationPermission && state.locationBlocked
|
||||
val needsHome = feature == Feature.SHORTCUTS && !state.home
|
||||
val restricted = feature == Feature.SHORTCUTS && !needsHome && !state.shortcuts && state.shortcutsRestricted
|
||||
val maybeRestricted = feature == Feature.SHORTCUTS && !needsHome && !state.shortcuts && !restricted && state.shortcutsTried &&
|
||||
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU
|
||||
val hint = stringResource(when {
|
||||
wifiLocationOff -> R.string.integration_wifi_location_off
|
||||
wifiDenied -> R.string.integration_wifi_denied
|
||||
needsHome -> R.string.integration_shortcuts_needs_home
|
||||
restricted -> R.string.integration_shortcuts_restricted
|
||||
maybeRestricted -> R.string.integration_shortcuts_maybe_restricted
|
||||
feature == Feature.WIFI -> if (on) R.string.integration_wifi_on else R.string.integration_wifi_hint
|
||||
feature == Feature.BRIGHTNESS -> R.string.integration_brightness_hint
|
||||
feature == Feature.HOME -> R.string.integration_home_hint
|
||||
else -> R.string.integration_shortcuts_hint
|
||||
})
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
modifier = Modifier.fillMaxWidth().bringIntoViewRequester(reveal).background(bg).heightIn(min = 64.dp)
|
||||
.padding(horizontal = 14.dp, vertical = 10.dp)
|
||||
.testTag("integration-${feature.name.lowercase()}"),
|
||||
) {
|
||||
FeatureBadge(featureIcon(feature), on)
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(stringResource(featureTitle(feature)), fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground,
|
||||
maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(hint, fontSize = 13.sp, color = if (wifiLocationOff || wifiDenied || restricted) AttentionAmber else colors.onSurfaceVariant,
|
||||
maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
when {
|
||||
wifiLocationOff -> SecondaryButton(stringResource(R.string.integration_location), compact = true, onClick = onLocation)
|
||||
wifiDenied -> SecondaryButton(stringResource(R.string.integration_app_info), compact = true, onClick = onLocation)
|
||||
restricted || maybeRestricted -> SecondaryButton(stringResource(R.string.integration_app_info), compact = true, onClick = onAppInfo)
|
||||
}
|
||||
val checked = if (feature == Feature.WIFI) state.wifi && state.locationPermission else on
|
||||
ToggleSwitch(checked, enabled = !needsHome && !restricted, label = stringResource(featureTitle(feature)),
|
||||
modifier = Modifier.testTag("integration-action-${feature.name.lowercase()}")) { onFeature(feature) }
|
||||
}
|
||||
}
|
||||
if (divider) Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line))
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FeatureBadge(icon: ImageVector, on: Boolean) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val tint by animateColorAsState(if (on) pal.good else colors.onSurfaceVariant, Motion.tw(250), label = "badgeTint")
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.size(36.dp).clip(BadgeShape)
|
||||
.background(if (on) pal.good.copy(alpha = 0.14f) else colors.surfaceVariant)
|
||||
.border(1.dp, if (on) pal.good.copy(alpha = 0.3f) else pal.line2, BadgeShape),
|
||||
) { Icon(icon, contentDescription = null, tint = tint, modifier = Modifier.size(19.dp)) }
|
||||
}
|
||||
|
||||
private fun featureIcon(feature: Feature) = when (feature) {
|
||||
Feature.WIFI -> Icons.Outlined.Wifi
|
||||
Feature.BRIGHTNESS -> Icons.Outlined.LightMode
|
||||
Feature.HOME -> Icons.Outlined.Home
|
||||
Feature.SHORTCUTS -> Icons.Outlined.KeyboardCommandKey
|
||||
}
|
||||
|
||||
private fun featureTitle(feature: Feature) = when (feature) {
|
||||
Feature.WIFI -> R.string.integration_wifi
|
||||
Feature.BRIGHTNESS -> R.string.integration_brightness
|
||||
Feature.HOME -> R.string.integration_home
|
||||
Feature.SHORTCUTS -> R.string.integration_shortcuts
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun IntegrationSuggestion(state: SteamIntegration.State, onOpen: () -> Unit, onLater: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val pill = RoundedCornerShape(99.dp)
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.clip(pill).background(colors.surfaceVariant.copy(alpha = 0.85f))
|
||||
.border(1.dp, pal.signal.copy(alpha = 0.3f), pill).testTag("integration-suggestion"),
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.heightIn(min = 40.dp).clip(pill).glideBorder(hot, pill, pal.signal, Color.Transparent)
|
||||
.hoverable(src).clickable(role = Role.Button, interactionSource = src, indication = LocalIndication.current, onClick = onOpen)
|
||||
.controllerConfirm(onClick = onOpen)
|
||||
.padding(start = 12.dp, end = 10.dp, top = 6.dp, bottom = 6.dp),
|
||||
) {
|
||||
Icon(Icons.Outlined.AutoAwesome, contentDescription = null, tint = pal.signal, modifier = Modifier.size(16.dp))
|
||||
Text(stringResource(R.string.integration_title), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1)
|
||||
Text(stringResource(R.string.integration_count, state.enabledCount(), Feature.entries.size), fontSize = 12.sp,
|
||||
color = colors.onSurfaceVariant, maxLines = 1)
|
||||
}
|
||||
val closeSrc = remember { MutableInteractionSource() }
|
||||
val closeHot = rememberHot(closeSrc)
|
||||
val later = stringResource(R.string.integration_later)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.padding(end = 4.dp).size(32.dp).clip(CircleShape)
|
||||
.background(if (closeHot) pal.signal.copy(alpha = 0.16f) else Color.Transparent)
|
||||
.glideBorder(closeHot, CircleShape, pal.signal, Color.Transparent)
|
||||
.hoverable(closeSrc).clickable(role = Role.Button, interactionSource = closeSrc, indication = LocalIndication.current, onClick = onLater)
|
||||
.controllerConfirm(onClick = onLater)
|
||||
.semantics { contentDescription = later },
|
||||
) { Icon(Icons.Outlined.Close, contentDescription = null, tint = colors.onSurfaceVariant, modifier = Modifier.size(16.dp)) }
|
||||
}
|
||||
}
|
||||
@@ -3219,6 +3219,7 @@
|
||||
<string name="library_remove">إزالة من المكتبة</string>
|
||||
<string name="library_in">في المكتبة</string>
|
||||
<string name="xbox_filter_show">عرض</string>
|
||||
<string name="itch_collections">المجموعات</string>
|
||||
<string name="xbox_filter_cloud">سحابية</string>
|
||||
<string name="stores_xbox_cloud_settings">إعدادات السحابة</string>
|
||||
</resources>
|
||||
@@ -3069,6 +3069,7 @@
|
||||
<string name="library_remove">Quitar de Biblioteca</string>
|
||||
<string name="library_in">En Biblioteca</string>
|
||||
<string name="xbox_filter_show">Mostrar</string>
|
||||
<string name="itch_collections">Colecciones</string>
|
||||
<string name="xbox_filter_cloud">Nube</string>
|
||||
<string name="stores_xbox_cloud_settings">Configuración de nube</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Премахни от Библиотека</string>
|
||||
<string name="library_in">В Библиотека</string>
|
||||
<string name="xbox_filter_show">Показване</string>
|
||||
<string name="itch_collections">Колекции</string>
|
||||
<string name="xbox_filter_cloud">Облак</string>
|
||||
<string name="stores_xbox_cloud_settings">Настройки на облака</string>
|
||||
</resources>
|
||||
@@ -3151,6 +3151,7 @@
|
||||
<string name="library_remove">Odebrat z knihovny</string>
|
||||
<string name="library_in">V knihovně</string>
|
||||
<string name="xbox_filter_show">Zobrazit</string>
|
||||
<string name="itch_collections">Kolekce</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Nastavení cloudu</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Fjern fra Bibliotek</string>
|
||||
<string name="library_in">I Bibliotek</string>
|
||||
<string name="xbox_filter_show">Vis</string>
|
||||
<string name="itch_collections">Samlinger</string>
|
||||
<string name="xbox_filter_cloud">Sky</string>
|
||||
<string name="stores_xbox_cloud_settings">Skyindstillinger</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Aus der Bibliothek entfernen</string>
|
||||
<string name="library_in">In der Bibliothek</string>
|
||||
<string name="xbox_filter_show">Anzeigen</string>
|
||||
<string name="itch_collections">Sammlungen</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Cloud-Einstellungen</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Αφαίρεση από τη Βιβλιοθήκη</string>
|
||||
<string name="library_in">Στη Βιβλιοθήκη</string>
|
||||
<string name="xbox_filter_show">Εμφάνιση</string>
|
||||
<string name="itch_collections">Συλλογές</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Ρυθμίσεις cloud</string>
|
||||
</resources>
|
||||
@@ -3119,6 +3119,7 @@
|
||||
<string name="library_remove">Quitar de la Biblioteca</string>
|
||||
<string name="library_in">En la Biblioteca</string>
|
||||
<string name="xbox_filter_show">Mostrar</string>
|
||||
<string name="itch_collections">Colecciones</string>
|
||||
<string name="xbox_filter_cloud">Nube</string>
|
||||
<string name="stores_xbox_cloud_settings">Ajustes de nube</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Poista kirjastosta</string>
|
||||
<string name="library_in">Kirjastossa</string>
|
||||
<string name="xbox_filter_show">Näytä</string>
|
||||
<string name="itch_collections">Kokoelmat</string>
|
||||
<string name="xbox_filter_cloud">Pilvi</string>
|
||||
<string name="stores_xbox_cloud_settings">Pilviasetukset</string>
|
||||
</resources>
|
||||
@@ -3119,6 +3119,7 @@
|
||||
<string name="library_remove">Retirer de la Bibliothèque</string>
|
||||
<string name="library_in">Dans la Bibliothèque</string>
|
||||
<string name="xbox_filter_show">Afficher</string>
|
||||
<string name="itch_collections">Collections</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Paramètres cloud</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">लाइब्रेरी से हटाएँ</string>
|
||||
<string name="library_in">लाइब्रेरी में</string>
|
||||
<string name="xbox_filter_show">दिखाएँ</string>
|
||||
<string name="itch_collections">संग्रह</string>
|
||||
<string name="xbox_filter_cloud">क्लाउड</string>
|
||||
<string name="stores_xbox_cloud_settings">क्लाउड सेटिंग्स</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Eltávolítás a könyvtárból</string>
|
||||
<string name="library_in">A könyvtárban</string>
|
||||
<string name="xbox_filter_show">Megjelenítés</string>
|
||||
<string name="itch_collections">Gyűjtemények</string>
|
||||
<string name="xbox_filter_cloud">Felhő</string>
|
||||
<string name="stores_xbox_cloud_settings">Felhőbeállítások</string>
|
||||
</resources>
|
||||
@@ -3073,6 +3073,7 @@
|
||||
<string name="library_remove">Hapus dari Pustaka</string>
|
||||
<string name="library_in">Di Pustaka</string>
|
||||
<string name="xbox_filter_show">Tampilkan</string>
|
||||
<string name="itch_collections">Koleksi</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Pengaturan cloud</string>
|
||||
</resources>
|
||||
@@ -3117,6 +3117,7 @@
|
||||
<string name="library_remove">Rimuovi dalla Libreria</string>
|
||||
<string name="library_in">Nella Libreria</string>
|
||||
<string name="xbox_filter_show">Mostra</string>
|
||||
<string name="itch_collections">Raccolte</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Impostazioni cloud</string>
|
||||
</resources>
|
||||
@@ -3060,6 +3060,7 @@
|
||||
<string name="library_remove">ライブラリから削除</string>
|
||||
<string name="library_in">ライブラリにあります</string>
|
||||
<string name="xbox_filter_show">表示</string>
|
||||
<string name="itch_collections">コレクション</string>
|
||||
<string name="xbox_filter_cloud">クラウド</string>
|
||||
<string name="stores_xbox_cloud_settings">クラウド設定</string>
|
||||
</resources>
|
||||
@@ -3060,6 +3060,7 @@
|
||||
<string name="library_remove">라이브러리에서 제거</string>
|
||||
<string name="library_in">라이브러리에 있음</string>
|
||||
<string name="xbox_filter_show">표시</string>
|
||||
<string name="itch_collections">컬렉션</string>
|
||||
<string name="xbox_filter_cloud">클라우드</string>
|
||||
<string name="stores_xbox_cloud_settings">클라우드 설정</string>
|
||||
</resources>
|
||||
@@ -3058,6 +3058,7 @@
|
||||
<string name="library_remove">Alih keluar dari Pustaka</string>
|
||||
<string name="library_in">Dalam Pustaka</string>
|
||||
<string name="xbox_filter_show">Tunjukkan</string>
|
||||
<string name="itch_collections">Koleksi</string>
|
||||
<string name="xbox_filter_cloud">Awan</string>
|
||||
<string name="stores_xbox_cloud_settings">Tetapan awan</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Fjern fra Bibliotek</string>
|
||||
<string name="library_in">I Bibliotek</string>
|
||||
<string name="xbox_filter_show">Vis</string>
|
||||
<string name="itch_collections">Samlinger</string>
|
||||
<string name="xbox_filter_cloud">Sky</string>
|
||||
<string name="stores_xbox_cloud_settings">Skyinnstillinger</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Verwijderen uit Bibliotheek</string>
|
||||
<string name="library_in">In Bibliotheek</string>
|
||||
<string name="xbox_filter_show">Weergeven</string>
|
||||
<string name="itch_collections">Collecties</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Cloudinstellingen</string>
|
||||
</resources>
|
||||
@@ -3154,6 +3154,7 @@
|
||||
<string name="library_remove">Usuń z biblioteki</string>
|
||||
<string name="library_in">W bibliotece</string>
|
||||
<string name="xbox_filter_show">Pokaż</string>
|
||||
<string name="itch_collections">Kolekcje</string>
|
||||
<string name="xbox_filter_cloud">Chmura</string>
|
||||
<string name="stores_xbox_cloud_settings">Ustawienia chmury</string>
|
||||
</resources>
|
||||
@@ -3117,6 +3117,7 @@
|
||||
<string name="library_remove">Remover da Biblioteca</string>
|
||||
<string name="library_in">Na Biblioteca</string>
|
||||
<string name="xbox_filter_show">Mostrar</string>
|
||||
<string name="itch_collections">Coleções</string>
|
||||
<string name="xbox_filter_cloud">Nuvem</string>
|
||||
<string name="stores_xbox_cloud_settings">Definições da nuvem</string>
|
||||
</resources>
|
||||
@@ -3117,6 +3117,7 @@
|
||||
<string name="library_remove">Remover da Biblioteca</string>
|
||||
<string name="library_in">Na Biblioteca</string>
|
||||
<string name="xbox_filter_show">Mostrar</string>
|
||||
<string name="itch_collections">Coleções</string>
|
||||
<string name="xbox_filter_cloud">Nuvem</string>
|
||||
<string name="stores_xbox_cloud_settings">Configurações da nuvem</string>
|
||||
</resources>
|
||||
@@ -3117,6 +3117,7 @@
|
||||
<string name="library_remove">Elimină din Bibliotecă</string>
|
||||
<string name="library_in">În Bibliotecă</string>
|
||||
<string name="xbox_filter_show">Afișează</string>
|
||||
<string name="itch_collections">Colecții</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Setări cloud</string>
|
||||
</resources>
|
||||
@@ -3153,6 +3153,7 @@
|
||||
<string name="library_remove">Убрать из библиотеки</string>
|
||||
<string name="library_in">В библиотеке</string>
|
||||
<string name="xbox_filter_show">Показать</string>
|
||||
<string name="itch_collections">Коллекции</string>
|
||||
<string name="xbox_filter_cloud">Облако</string>
|
||||
<string name="stores_xbox_cloud_settings">Настройки облака</string>
|
||||
</resources>
|
||||
@@ -3083,6 +3083,7 @@
|
||||
<string name="library_remove">Ta bort från Bibliotek</string>
|
||||
<string name="library_in">I Bibliotek</string>
|
||||
<string name="xbox_filter_show">Visa</string>
|
||||
<string name="itch_collections">Samlingar</string>
|
||||
<string name="xbox_filter_cloud">Moln</string>
|
||||
<string name="stores_xbox_cloud_settings">Molninställningar</string>
|
||||
</resources>
|
||||
@@ -3058,6 +3058,7 @@
|
||||
<string name="library_remove">นำออกจากไลบรารี</string>
|
||||
<string name="library_in">อยู่ในไลบรารี</string>
|
||||
<string name="xbox_filter_show">แสดง</string>
|
||||
<string name="itch_collections">คอลเลกชัน</string>
|
||||
<string name="xbox_filter_cloud">คลาวด์</string>
|
||||
<string name="stores_xbox_cloud_settings">การตั้งค่าคลาวด์</string>
|
||||
</resources>
|
||||
@@ -3085,6 +3085,7 @@
|
||||
<string name="library_remove">Kütüphane içinden kaldır</string>
|
||||
<string name="library_in">Kütüphane içinde</string>
|
||||
<string name="xbox_filter_show">Göster</string>
|
||||
<string name="itch_collections">Koleksiyonlar</string>
|
||||
<string name="xbox_filter_cloud">Bulut</string>
|
||||
<string name="stores_xbox_cloud_settings">Bulut ayarları</string>
|
||||
</resources>
|
||||
@@ -3151,6 +3151,7 @@
|
||||
<string name="library_remove">Прибрати з бібліотеки</string>
|
||||
<string name="library_in">У бібліотеці</string>
|
||||
<string name="xbox_filter_show">Показати</string>
|
||||
<string name="itch_collections">Колекції</string>
|
||||
<string name="xbox_filter_cloud">Хмара</string>
|
||||
<string name="stores_xbox_cloud_settings">Налаштування хмари</string>
|
||||
</resources>
|
||||
@@ -3058,6 +3058,7 @@
|
||||
<string name="library_remove">Xóa khỏi Thư viện</string>
|
||||
<string name="library_in">Trong Thư viện</string>
|
||||
<string name="xbox_filter_show">Hiển thị</string>
|
||||
<string name="itch_collections">Bộ sưu tập</string>
|
||||
<string name="xbox_filter_cloud">Đám mây</string>
|
||||
<string name="stores_xbox_cloud_settings">Cài đặt đám mây</string>
|
||||
</resources>
|
||||
@@ -3062,6 +3062,7 @@
|
||||
<string name="library_remove">从游戏库移除</string>
|
||||
<string name="library_in">已在游戏库</string>
|
||||
<string name="xbox_filter_show">显示</string>
|
||||
<string name="itch_collections">收藏集</string>
|
||||
<string name="xbox_filter_cloud">云</string>
|
||||
<string name="stores_xbox_cloud_settings">云设置</string>
|
||||
</resources>
|
||||
@@ -3061,6 +3061,7 @@
|
||||
<string name="library_remove">從收藏庫移除</string>
|
||||
<string name="library_in">已在收藏庫</string>
|
||||
<string name="xbox_filter_show">顯示</string>
|
||||
<string name="itch_collections">收藏集</string>
|
||||
<string name="xbox_filter_cloud">雲端</string>
|
||||
<string name="stores_xbox_cloud_settings">雲端設定</string>
|
||||
</resources>
|
||||
@@ -3061,6 +3061,7 @@
|
||||
<string name="library_remove">從收藏庫移除</string>
|
||||
<string name="library_in">已在收藏庫</string>
|
||||
<string name="xbox_filter_show">顯示</string>
|
||||
<string name="itch_collections">收藏集</string>
|
||||
<string name="xbox_filter_cloud">雲端</string>
|
||||
<string name="stores_xbox_cloud_settings">雲端設定</string>
|
||||
</resources>
|
||||
@@ -310,7 +310,7 @@
|
||||
<string name="back_double_tap_window">Double-tap window</string>
|
||||
<string name="back_tap_ms">%1$d ms</string>
|
||||
<string name="brightness_permission_title">Allow brightness control</string>
|
||||
<string name="brightness_permission_text">Tap to allow Steam to change Android screen brightness.</string>
|
||||
<string name="brightness_permission_text">Set up brightness control in DroidDeck.</string>
|
||||
<string name="back_menu_then_qam">Menu → QAM</string>
|
||||
<string name="back_qam_then_menu">QAM → Menu</string>
|
||||
<string name="mode_session">Session</string>
|
||||
@@ -3236,8 +3236,32 @@
|
||||
<string name="library_remove">Remove from Library</string>
|
||||
<string name="library_in">In Library</string>
|
||||
<string name="xbox_filter_show">Show</string>
|
||||
<string name="itch_collections">Collections</string>
|
||||
<string name="xbox_filter_cloud">Cloud</string>
|
||||
<string name="stores_xbox_cloud_settings">Cloud settings</string>
|
||||
<string name="xbox_cloud_gaming" translatable="false">Xbox Cloud Gaming</string>
|
||||
<string name="xbox_filter_game_pass" translatable="false">Game Pass</string>
|
||||
<string name="integration_title">Steam integration</string>
|
||||
<string name="integration_count">%1$d of %2$d on</string>
|
||||
<string name="integration_set_up">Set up</string>
|
||||
<string name="integration_later">Not now</string>
|
||||
<string name="integration_location">Location</string>
|
||||
<string name="integration_app_info">App info</string>
|
||||
<string name="integration_wifi">Wi-Fi names</string>
|
||||
<string name="integration_brightness">Brightness</string>
|
||||
<string name="integration_home">DroidDeck as Home</string>
|
||||
<string name="integration_shortcuts">Home button shortcuts</string>
|
||||
<string name="integration_wifi_hint">Show networks in Steam · needs Location access, never tracked</string>
|
||||
<string name="integration_wifi_on">Networks show in Steam</string>
|
||||
<string name="integration_wifi_location_off">Location is off</string>
|
||||
<string name="integration_wifi_denied">Location denied · allow it in App info</string>
|
||||
<string name="integration_brightness_hint">Steam’s slider sets screen brightness</string>
|
||||
<string name="integration_home_hint">Home opens the Steam menu in a session</string>
|
||||
<string name="integration_shortcuts_hint">Hold Home for Steam Guide chords</string>
|
||||
<string name="integration_shortcuts_needs_home">Needs DroidDeck as Home</string>
|
||||
<string name="integration_shortcuts_maybe_restricted">Greyed out in Android? App info → ⋮ → Allow restricted settings</string>
|
||||
<string name="integration_shortcuts_restricted">Blocked by Android · App info → ⋮ → Allow restricted settings</string>
|
||||
<string name="integration_shortcuts_service">DroidDeck Home button</string>
|
||||
<string name="integration_shortcuts_service_description">Pass Home button presses to Steam Guide while a Steam session is focused and DroidDeck is the default Home app. Does not read screen content.</string>
|
||||
<string name="integration_brightness_needed">Turn on Brightness in Setup → Steam integration</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:accessibilityFeedbackType="feedbackGeneric"
|
||||
android:accessibilityFlags="flagRequestFilterKeyEvents"
|
||||
android:canRequestFilterKeyEvents="true"
|
||||
android:canRetrieveWindowContent="false"
|
||||
android:description="@string/integration_shortcuts_service_description" />
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.app.Application
|
||||
import android.view.KeyEvent
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28, 33], manifest = Config.NONE, application = Application::class)
|
||||
class HomeGuideInputTest {
|
||||
private val states = mutableListOf<Boolean>()
|
||||
private var cancellations = 0
|
||||
private val input = HomeGuideInput({ states.add(it) }, { cancellations++ })
|
||||
|
||||
private fun home(action: Int, device: Int = 10, repeat: Int = 0, down: Long = 10) =
|
||||
KeyEvent(down, down + 100, action, KeyEvent.KEYCODE_HOME, repeat, 0, device, 102)
|
||||
|
||||
@Test fun guideIsHeldImmediatelyAndReleaseDoesNotDependOnAndroidDownTime() {
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true))
|
||||
assertEquals(listOf(true), states)
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN, repeat = 1), true))
|
||||
assertFalse(input.onKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_X), true))
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP, down = 77), true))
|
||||
assertEquals(listOf(true, false), states)
|
||||
}
|
||||
|
||||
@Test fun anUnownedHomePressKeepsAndroidBehaviorEvenIfSessionBecomesEligibleBeforeRelease() {
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), false))
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_UP), true))
|
||||
assertTrue(states.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun focusLossReleasesGuideAndConsumesTheOwnedReleaseWithoutAnotherTap() {
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true)
|
||||
input.cancel()
|
||||
assertEquals(1, cancellations)
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN, repeat = 2), false))
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP), false))
|
||||
assertEquals(listOf(true, false), states)
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_UP), false))
|
||||
}
|
||||
|
||||
@Test fun disablingDuringAHoldReleasesItAndDoesNotStealTheNextAndroidHomePress() {
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true)
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP), false))
|
||||
assertEquals(listOf(true, false), states)
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), false))
|
||||
}
|
||||
|
||||
@Test fun guideStaysHeldUntilAllOwnersReleaseAndDisconnectCancelsTheLastOwner() {
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true)
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN, device = 11), true)
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_UP), true)
|
||||
assertEquals(listOf(true), states)
|
||||
input.onDeviceRemoved(11)
|
||||
assertEquals(listOf(true, false), states)
|
||||
assertEquals(1, cancellations)
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,53 @@ class PadBridgeQamTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun homeGuidePrecedesEarlyPartnerInputAndDoesNotGenerateABareButton() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
assertTrue(pad().isDown(PadState.GUIDE))
|
||||
bridge.applyExternal({ it.press(PadState.X, true) }, true)
|
||||
assertFalse(pad().isDown(PadState.X))
|
||||
advance(80)
|
||||
assertTrue(pad().isDown(PadState.GUIDE))
|
||||
assertTrue(pad().isDown(PadState.X))
|
||||
bridge.applyExternal({ it.press(PadState.X, false) }, true)
|
||||
bridge.setHomeGuidePressed(false)
|
||||
advance(1000)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
assertFalse(pad().isDown(PadState.X))
|
||||
}
|
||||
|
||||
@Test fun cancellingHomeDiscardsQueuedPartnersAndReleasesGuideImmediately() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
bridge.applyExternal({ it.press(PadState.LB, true); it.leftY = -1f }, true)
|
||||
bridge.cancelHomeGuide()
|
||||
advance(1000)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
assertFalse(pad().isDown(PadState.LB))
|
||||
assertEquals(0f, pad().leftY)
|
||||
}
|
||||
|
||||
@Test fun homeAndTouchGuideHaveIndependentReleases() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
bridge.setSystemButtons(true, false)
|
||||
bridge.setHomeGuidePressed(false)
|
||||
advance(1000)
|
||||
assertTrue(pad().isDown(PadState.GUIDE))
|
||||
bridge.setSystemButtons(false, false)
|
||||
advance(1000)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
}
|
||||
|
||||
@Test fun releasingHomeStopsHeldAxesFromBecomingNavigation() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
bridge.applyExternal({ it.leftY = -1f }, true)
|
||||
advance(80)
|
||||
assertEquals(-1f, pad().leftY)
|
||||
bridge.setHomeGuidePressed(false)
|
||||
advance(1000)
|
||||
assertEquals(0f, pad().leftY)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
}
|
||||
|
||||
private fun key(device: InputDevice, code: Int, action: Int = KeyEvent.ACTION_DOWN, repeat: Int = 0, scan: Int = 0) =
|
||||
KeyEvent(0L, 0L, action, code, repeat, 0, device.id, scan, 0, InputDevice.SOURCE_GAMEPAD)
|
||||
|
||||
|
||||
@@ -66,14 +66,16 @@ class DeviceControlsComponentTest {
|
||||
assertEquals(3, audio.getStreamVolume(AudioManager.STREAM_MUSIC))
|
||||
}
|
||||
|
||||
@Test fun deniedBrightnessIsReadBackAndAppliedOnlyAfterPermission() {
|
||||
@Test fun deniedBrightnessDoesNotOpenSettingsOrReplayAnOldSliderValueAfterPermission() {
|
||||
WriteSettingsShadow.writable = false
|
||||
request("brightness", "0.75")
|
||||
assertEquals(128, Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
|
||||
assertEquals(Settings.ACTION_MANAGE_WRITE_SETTINGS, shadowOf(context).nextStartedActivity.action)
|
||||
assertNull(shadowOf(context).nextStartedActivity)
|
||||
assertFalse(JSONObject(File(directory, "state.json").readText()).getBoolean("brightnessWritable"))
|
||||
WriteSettingsShadow.writable = true
|
||||
tick()
|
||||
assertEquals(128, Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
|
||||
request("brightness", "0.75")
|
||||
assertEquals(192, Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
|
||||
}
|
||||
|
||||
@@ -87,7 +89,7 @@ class DeviceControlsComponentTest {
|
||||
assertEquals(1.0, JSONObject(File(directory, "state.json").readText()).getDouble("brightness"), 0.0001)
|
||||
}
|
||||
|
||||
@Test fun hiddenPermissionRequestOffersANotificationAndRetainsTheLatestValue() {
|
||||
@Test fun permissionNotificationOpensOptionalLauncherSetupOnlyWhenSelected() {
|
||||
visible = false
|
||||
WriteSettingsShadow.writable = false
|
||||
request("brightness", "0.25")
|
||||
@@ -96,11 +98,13 @@ class DeviceControlsComponentTest {
|
||||
val notifications = context.getSystemService(NotificationManager::class.java)
|
||||
val notification = notifications.activeNotifications.single().notification
|
||||
notification.contentIntent.send()
|
||||
assertEquals(Settings.ACTION_MANAGE_WRITE_SETTINGS, shadowOf(context).nextStartedActivity.action)
|
||||
val intent = shadowOf(context).nextStartedActivity
|
||||
assertEquals(com.droiddeck.launcher.core.SteamIntegration.ACTION_SETUP, intent.action)
|
||||
assertEquals("BRIGHTNESS", intent.getStringExtra(com.droiddeck.launcher.core.SteamIntegration.EXTRA_FEATURE))
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(121))
|
||||
WriteSettingsShadow.writable = true
|
||||
tick()
|
||||
assertEquals(192, Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
|
||||
assertEquals(128, Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
|
||||
assertTrue(notifications.activeNotifications.isEmpty())
|
||||
}
|
||||
|
||||
@@ -123,15 +127,15 @@ class DeviceControlsComponentTest {
|
||||
assertEquals(128, Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
|
||||
}
|
||||
|
||||
@Test fun rejectedPermissionCanBeRequestedAgainWithoutOpeningRepeatedScreens() {
|
||||
@Test fun repeatedSliderChangesDoNotInterruptTheSession() {
|
||||
WriteSettingsShadow.writable = false
|
||||
request("brightness", "0.75")
|
||||
assertNotNull(shadowOf(context).nextStartedActivity)
|
||||
assertNull(shadowOf(context).nextStartedActivity)
|
||||
request("brightness", "0.8")
|
||||
assertNull(shadowOf(context).nextStartedActivity)
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(5))
|
||||
request("brightness", "0.8")
|
||||
assertNotNull(shadowOf(context).nextStartedActivity)
|
||||
assertNull(shadowOf(context).nextStartedActivity)
|
||||
}
|
||||
|
||||
@Test fun oversizedRequestsAreDiscardedAndDoNotBlockLaterCommands() {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.droiddeck.launcher.stores.itch
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
@org.junit.runner.RunWith(org.robolectric.RobolectricTestRunner::class)
|
||||
@org.robolectric.annotation.Config(sdk = [33], application = android.app.Application::class)
|
||||
class ItchCollectionsTest {
|
||||
@Test fun collectionsKeepTheirIdTitleAndCount() {
|
||||
val body = JSONArray()
|
||||
.put(JSONObject().put("id", 8356509).put("title", "library").put("games_count", 12))
|
||||
.put(JSONObject().put("id", 7).put("title", "").put("games_count", 3))
|
||||
.put(JSONObject().put("title", "no id"))
|
||||
val list = ItchCollections.parseCollections(body)
|
||||
assertEquals(listOf("8356509"), list.map { it.id })
|
||||
assertEquals("library", list.single().title)
|
||||
assertEquals(12, list.single().count)
|
||||
}
|
||||
|
||||
@Test fun collectionGamesReadBothKeyStylesAndSkipRowsWithoutAGame() {
|
||||
val game = JSONObject().put("id", 99).put("title", "Celeste 64").put("url", "https://noel.itch.io/celeste64")
|
||||
val snake = JSONObject().put("collection_games", JSONArray().put(JSONObject().put("game", game)).put(JSONObject().put("position", 1)))
|
||||
val camel = JSONObject().put("collectionGames", JSONArray().put(JSONObject().put("game", game)))
|
||||
assertEquals(listOf("noel.itch.io/celeste64"), ItchCollections.parseGames(snake).map { it.id })
|
||||
assertEquals(1, ItchCollections.parseGames(camel).size)
|
||||
assertEquals(false, ItchCollections.parseGames(snake).single().owned)
|
||||
assertEquals(0, ItchCollections.parseGames(JSONObject()).size)
|
||||
}
|
||||
}
|
||||
@@ -94,4 +94,23 @@ class LibraryEntriesTest {
|
||||
GameRef.parse("xbox:9NBLGGH4R315").let { assertEquals(Store.XBOX, it.store); assertEquals("9NBLGGH4R315", it.storeId) }
|
||||
GameRef.parse("app:nope:1").let { assertNull(it.store); assertNull(it.appId) }
|
||||
}
|
||||
|
||||
@Test fun aCollectionKeepsItsInstalledGamesAndListsTheRestAsNotInstalled() {
|
||||
val games = listOf(
|
||||
Library.SteamGame(440, "Team Fortress 2", null, "Steam library"),
|
||||
Library.SteamGame(-5, "Celeste", null, Library.ADDED, source = "itch", storeId = "a/celeste"),
|
||||
Library.SteamGame(-6, "Other", null, Library.ADDED, source = "itch", storeId = "a/other"),
|
||||
)
|
||||
val library = mapOf(Store.ITCH to listOf(owned(Store.ITCH, "a/celeste"), owned(Store.ITCH, "a/other"), owned(Store.ITCH, "b/owned")))
|
||||
val all = libraryEntries(games, library, setOf("itch:a/celeste", "itch:a/other"))
|
||||
val collection = listOf(owned(Store.ITCH, "a/celeste"), owned(Store.ITCH, "b/owned"), owned(Store.ITCH, "c/new"))
|
||||
val out = collectionEntries(all, collection)
|
||||
assertEquals(listOf("app:-5", "app:itch:b/owned", "app:itch:c/new"), out.map { it.key })
|
||||
assertEquals(listOf(true, false, false), out.map { it.installed })
|
||||
}
|
||||
|
||||
@Test fun anEmptyCollectionHidesEveryGame() {
|
||||
val all = libraryEntries(listOf(Library.SteamGame(440, "Team Fortress 2", null, "Steam library")), emptyMap(), emptySet())
|
||||
assertEquals(emptyList<String>(), collectionEntries(all, emptyList()).map { it.key })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.test.assertIsEnabled
|
||||
import androidx.compose.ui.test.assertIsNotEnabled
|
||||
import androidx.compose.ui.semantics.SemanticsProperties
|
||||
import androidx.compose.ui.test.SemanticsMatcher
|
||||
import androidx.compose.ui.test.assert
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import com.droiddeck.launcher.core.SteamIntegration
|
||||
import com.droiddeck.launcher.core.SteamIntegration.Feature
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33], qualifiers = "w960dp-h540dp-land")
|
||||
class SteamIntegrationGroupTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
private val state = mutableStateOf(SteamIntegration.State())
|
||||
private val requests = mutableListOf<Feature>()
|
||||
private var appInfo = 0
|
||||
private var location = 0
|
||||
|
||||
private fun stateIs(value: String) = SemanticsMatcher.expectValue(SemanticsProperties.StateDescription, value)
|
||||
|
||||
private fun show() = compose.setContent {
|
||||
DroidDeckTheme {
|
||||
SteamIntegrationGroup(state.value, onFeature = { requests.add(it) }, onAppInfo = { appInfo++ }, onLocation = { location++ })
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun everySwitchRequestsOnlyItsOwnFeature() {
|
||||
state.value = SteamIntegration.State(home = true)
|
||||
show()
|
||||
compose.onNodeWithTag("integration-action-brightness").performClick()
|
||||
compose.onNodeWithTag("integration-action-home").performClick()
|
||||
compose.onNodeWithTag("integration-action-shortcuts").performClick()
|
||||
assertEquals(listOf(Feature.BRIGHTNESS, Feature.HOME, Feature.SHORTCUTS), requests)
|
||||
}
|
||||
|
||||
@Test fun switchesReflectAndroidGrants() {
|
||||
state.value = SteamIntegration.State(brightness = true, home = true, shortcuts = true)
|
||||
show()
|
||||
compose.onNodeWithTag("integration-action-brightness").assert(stateIs("On"))
|
||||
compose.onNodeWithTag("integration-action-shortcuts").assert(stateIs("On"))
|
||||
compose.onNodeWithTag("integration-action-wifi").assert(stateIs("Off"))
|
||||
compose.onNodeWithText("3 of 4 on").assertExists()
|
||||
}
|
||||
|
||||
@Test fun shortcutsWaitForHome() {
|
||||
show()
|
||||
compose.onNodeWithTag("integration-action-shortcuts").assertIsNotEnabled()
|
||||
compose.onNodeWithText("Needs DroidDeck as Home").assertExists()
|
||||
compose.runOnIdle { state.value = state.value.copy(home = true) }
|
||||
compose.onNodeWithTag("integration-action-shortcuts").assertIsEnabled()
|
||||
}
|
||||
|
||||
@Test fun restrictedShortcutsPointToAppInfo() {
|
||||
state.value = SteamIntegration.State(home = true, shortcutsRestricted = true)
|
||||
show()
|
||||
compose.onNodeWithTag("integration-action-shortcuts").assertIsNotEnabled()
|
||||
compose.onNodeWithText("App info").performClick()
|
||||
assertEquals(1, appInfo)
|
||||
compose.runOnIdle { state.value = state.value.copy(shortcutsRestricted = false) }
|
||||
compose.onNodeWithText("App info").assertDoesNotExist()
|
||||
compose.onNodeWithTag("integration-action-shortcuts").assertIsEnabled()
|
||||
}
|
||||
|
||||
@Test fun unconfirmedRestrictionOffersAppInfoAfterAnAttempt() {
|
||||
state.value = SteamIntegration.State(home = true)
|
||||
show()
|
||||
compose.onNodeWithText("App info").assertDoesNotExist()
|
||||
compose.runOnIdle { state.value = state.value.copy(shortcutsTried = true) }
|
||||
compose.onNodeWithTag("integration-action-shortcuts").assertIsEnabled()
|
||||
compose.onNodeWithText("App info").performClick()
|
||||
assertEquals(1, appInfo)
|
||||
}
|
||||
|
||||
@Test fun deniedLocationPointsToAppInfoWithoutTogglingWifi() {
|
||||
state.value = SteamIntegration.State(locationBlocked = true)
|
||||
show()
|
||||
compose.onNodeWithText("Location denied · allow it in App info").assertExists()
|
||||
compose.onNodeWithText("App info").performClick()
|
||||
assertEquals(1, location)
|
||||
assertTrue(requests.isEmpty())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
# itch.io collections
|
||||
|
||||
On the Library's itch tab a Collections button in the header lists the collections of the signed-in
|
||||
itch account. Picking one hides every game that is not in it; the games of the collection that are not
|
||||
installed show in the existing "Not installed" section, and All brings the full library back. The button
|
||||
exists only while the itch chip is selected.
|
||||
|
||||
## Data
|
||||
|
||||
`ItchCollections` (`stores/itch/ItchCollections.kt`) asks itch with the account's API key:
|
||||
|
||||
```
|
||||
GET /profile/collections -> collections[{id, title, games_count}]
|
||||
GET /collections/<id>/collection-games?page=N -> collection_games[{game{...}}]
|
||||
```
|
||||
|
||||
Pages are read until one comes back empty. Each game goes through `ItchLibrary.item`, the reader the
|
||||
library and shelves share, so it looks the same everywhere. The selection and the loaded games live in
|
||||
memory; the list is asked again whenever the itch tab opens. Counts are logged
|
||||
(`itch.io: <n> collections`, `itch.io: collection <id> has <n> games`).
|
||||
|
||||
## Filtering
|
||||
|
||||
`collectionEntries` keeps the itch entries whose store key is in the collection, then adds the
|
||||
collection games the library has no entry for as not installed ones. Their game page resolves through
|
||||
`StoresState.detailItem`, which also looks at the collection games.
|
||||
@@ -0,0 +1,49 @@
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 6c9299d..bb42fbc 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -1278,6 +1278,8 @@ void steamcompmgr_set_app_refresh_cycle_override( gamescope::GamescopeScreenType
|
||||
g_nCombinedAppRefreshCycleChangeRefresh[ type ] = change_refresh;
|
||||
g_nCombinedAppRefreshCycleChangeFPS[ type ] = change_fps_cap;
|
||||
update_app_target_refresh_cycle();
|
||||
+ xwm_log.infof( "ddlimit: override type %d fps %d change_refresh %d change_fps %d -> target fps %d (refresh %d mHz, nested %d mHz)",
|
||||
+ (int) type, override_fps, change_refresh, change_fps_cap, g_nSteamCompMgrTargetFPS, g_nOutputRefresh, g_nNestedRefresh );
|
||||
}
|
||||
|
||||
gamescope::ConCommand cc_debug_set_fps_limit( "debug_set_fps_limit", "Set refresh cycle (debug)",
|
||||
@@ -7309,6 +7311,7 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
|
||||
if ( ev->atom == ctx->atoms.gamescopeFPSLimit )
|
||||
{
|
||||
g_nSteamCompMgrTargetFPS = get_prop( ctx, ctx->root, ctx->atoms.gamescopeFPSLimit, 0 );
|
||||
+ xwm_log.infof( "ddlimit: GAMESCOPE_FPS_LIMIT atom -> target fps %d", g_nSteamCompMgrTargetFPS );
|
||||
update_runtime_info();
|
||||
}
|
||||
for (int i = 0; i < gamescope::GAMESCOPE_SCREEN_TYPE_COUNT; i++)
|
||||
diff --git a/src/wlserver.cpp b/src/wlserver.cpp
|
||||
index 9a027a2..76d65e6 100644
|
||||
--- a/src/wlserver.cpp
|
||||
+++ b/src/wlserver.cpp
|
||||
@@ -1164,6 +1164,7 @@ void wlserver_flush_frame_limiter_state( void )
|
||||
|
||||
wlserver_lock();
|
||||
uint32_t uState = s_uFrameLimiterState;
|
||||
+ wl_log.infof( "ddlimit: limiter state %u", uState );
|
||||
for ( CGamescopeLimiter *pLimiter : CGamescopeLimiter::GetLimiters() )
|
||||
{
|
||||
pLimiter->SendState( uState );
|
||||
@@ -1203,6 +1204,7 @@ static void create_gamescope_pipewire( void )
|
||||
|
||||
static void gamescope_control_set_app_target_refresh_cycle( struct wl_client *client, struct wl_resource *resource, uint32_t fps, uint32_t flags )
|
||||
{
|
||||
+ wl_log.infof( "ddlimit: steam set_app_target_refresh_cycle fps=%u flags=0x%x", fps, flags );
|
||||
auto display_type = gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL;
|
||||
if ( flags & GAMESCOPE_CONTROL_TARGET_REFRESH_CYCLE_FLAG_INTERNAL_DISPLAY )
|
||||
display_type = gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL;
|
||||
@@ -1452,6 +1454,7 @@ void wlserver_send_gamescope_control( wl_resource *control )
|
||||
uint32_t *ptr = (uint32_t *)wl_array_add( &display_rates, sizeof(uint32_t) );
|
||||
*ptr = (uint32_t)gamescope::ConvertmHzToHz( g_nOutputRefresh );
|
||||
}
|
||||
+ wl_log.infof( "ddlimit: display info to steam, flags 0x%x, %zu rate(s), first %u", flags, display_rates.size / sizeof( uint32_t ), display_rates.size ? *(uint32_t *)display_rates.data : 0u );
|
||||
gamescope_control_send_active_display_info( control, pConn->GetName(), pConn->GetMake(), pConn->GetModel(), flags, &display_rates );
|
||||
wl_array_release(&display_rates);
|
||||
}
|
||||
@@ -151,6 +151,12 @@ def robocop_rogue_city_feature_level(game):
|
||||
return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "RoboCop: Rogue City: D3D12 feature level 12_1"
|
||||
|
||||
|
||||
@fix
|
||||
def reskate_feature_level(game):
|
||||
if "skate.exe" in game.files and "reskate.dll" in game.files:
|
||||
return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "ReSkate (skate.): D3D12 feature level 12_1"
|
||||
|
||||
|
||||
@fix
|
||||
def cyberpunk_feature_level(game):
|
||||
if game.stem == "cyberpunk2077" or (
|
||||
@@ -351,6 +357,26 @@ def game_cores(env):
|
||||
print("droiddeck-game-env: could not use game cores %r (%s)" % (text, error), file=sys.stderr)
|
||||
|
||||
|
||||
def cpu_topology(env):
|
||||
if "PROTON_CPU_TOPOLOGY" in env:
|
||||
return
|
||||
if "WINE_CPU_TOPOLOGY" in env:
|
||||
if env["WINE_CPU_TOPOLOGY"]:
|
||||
env["PROTON_CPU_TOPOLOGY"] = env["WINE_CPU_TOPOLOGY"]
|
||||
return
|
||||
if not (env.get("DROIDDECK_GAME_CORES", "").strip() or env.get("BL_GAME_CPUS", "").strip()):
|
||||
return
|
||||
try:
|
||||
cores = sorted(os.sched_getaffinity(0))
|
||||
except OSError:
|
||||
return
|
||||
online = online_cores()
|
||||
if not cores or set(cores) >= online or cores[-1] >= len(online):
|
||||
return
|
||||
env["WINE_CPU_TOPOLOGY"] = env["PROTON_CPU_TOPOLOGY"] = "%d:%s" % (len(cores), ",".join(map(str, cores)))
|
||||
print("droiddeck-game-env: Windows sees %d cores (%s)" % (len(cores), env["WINE_CPU_TOPOLOGY"]), file=sys.stderr)
|
||||
|
||||
|
||||
def apply_config(env, config, app_id, fixes=None):
|
||||
if config.get("version") != 1:
|
||||
raise ValueError("unsupported environment configuration")
|
||||
@@ -627,6 +653,7 @@ def main():
|
||||
env = vram_cap(env)
|
||||
env = force_ssbs(command, env)
|
||||
game_cores(env)
|
||||
cpu_topology(env)
|
||||
try:
|
||||
xbox = runpy.run_path(str(Path(__file__).with_name("droiddeck-xbox")))
|
||||
except Exception as error:
|
||||
|
||||
@@ -449,6 +449,47 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertEqual(calls, [{0, 1, 2}])
|
||||
self.assertEqual(MODULE["parse_cores"]("0,2-7"), {0, 2, 3, 4, 5, 6, 7})
|
||||
|
||||
def test_windows_games_see_only_the_cores_they_are_pinned_to(self):
|
||||
os_mod = MODULE["os"]
|
||||
online = {"online_cores": lambda: {0, 1, 2, 3, 4, 5, 6, 7}}
|
||||
cases = [
|
||||
({"BL_GAME_CPUS": "6,7"}, {6, 7}, "2:6,7", "2:6,7"),
|
||||
({"DROIDDECK_GAME_CORES": "0-2"}, {0, 1, 2}, "3:0,1,2", "3:0,1,2"),
|
||||
({"BL_GAME_CPUS": "0-7"}, set(range(8)), None, None),
|
||||
({}, {6, 7}, None, None),
|
||||
({"BL_GAME_CPUS": "6,7", "WINE_CPU_TOPOLOGY": "4:0,1,2,3"}, {6, 7}, "4:0,1,2,3", "4:0,1,2,3"),
|
||||
({"WINE_CPU_TOPOLOGY": "2:0,1"}, set(range(8)), "2:0,1", "2:0,1"),
|
||||
({"BL_GAME_CPUS": "6,7", "WINE_CPU_TOPOLOGY": ""}, {6, 7}, "", None),
|
||||
({"BL_GAME_CPUS": "6,7", "PROTON_CPU_TOPOLOGY": "1:7"}, {6, 7}, None, "1:7"),
|
||||
({"BL_GAME_CPUS": "9"}, {9}, None, None),
|
||||
]
|
||||
for env, affinity, expected, proton in cases:
|
||||
with mock.patch.dict(MODULE["cpu_topology"].__globals__, online), \
|
||||
mock.patch.object(os_mod, "sched_getaffinity", return_value=affinity, create=True):
|
||||
MODULE["cpu_topology"](env)
|
||||
self.assertEqual(env.get("WINE_CPU_TOPOLOGY"), expected, env)
|
||||
self.assertEqual(env.get("PROTON_CPU_TOPOLOGY"), proton, env)
|
||||
|
||||
def test_reskate_runs_at_feature_level_12_1(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
reskate = Path(tmp) / "ReSkate"
|
||||
reskate.mkdir()
|
||||
for name in ("Skate.exe", "ReSkate.dll", "ReSkateLauncher.exe", "EAAntiCheat.GameServiceLauncher.exe"):
|
||||
(reskate / name).touch()
|
||||
for exe in ("ReSkateLauncher.exe", "Skate.exe"):
|
||||
env, extra, notes = MODULE["engine_fixes"](str(reskate / exe), [])
|
||||
self.assertEqual((env, extra), ({"VKD3D_FEATURE_LEVEL": "12_1"}, []), exe)
|
||||
self.assertTrue(notes)
|
||||
config = {"version": 1, "shared": {"VKD3D_FEATURE_LEVEL": "12_2"}}
|
||||
self.assertEqual(MODULE["apply_config"]({}, config, "3354750", env)["VKD3D_FEATURE_LEVEL"], "12_1")
|
||||
config["games"] = {"3354750": {"VKD3D_FEATURE_LEVEL": "12_2"}}
|
||||
self.assertEqual(MODULE["apply_config"]({}, config, "3354750", env)["VKD3D_FEATURE_LEVEL"], "12_2")
|
||||
skate = Path(tmp) / "Skate"
|
||||
skate.mkdir()
|
||||
for name in ("Skate.exe", "EAAntiCheat.GameServiceLauncher.exe"):
|
||||
(skate / name).touch()
|
||||
self.assertEqual(MODULE["engine_fixes"](str(skate / "EAAntiCheat.GameServiceLauncher.exe"), [])[:2], ({}, []))
|
||||
|
||||
def test_caravan_sandwitch_robocop_and_cyberpunk_run_at_feature_level_12_1(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
caravan = Path(tmp) / "Caravan SandWitch"
|
||||
|
||||
Reference in new issue
Block a user