Compare commits

..
Author SHA1 Message Date
The412Banner 75d79fc14d fix(steam): explain launches the offline client cannot start
Steam in offline mode only knows the games in its cached appinfo. A game
bought after its last online session and installed by DroidDeck's own
downloader fails at once with AppError_9 (missing configuration). Before
handing such a game to Steam, check the client's appinfo cache and say to
go online in Steam once.
2026-11-30 02:16:30 +00:00
MaxsTechReview c6743730aa Keep a signed-in store's Library tab when its game list is empty or failed to load (#3449) 2026-11-29 20:24:34 -05:00
MaxsTechReview 780c5658d0 fix(input): each pad is listed once in Windows games so both triggers read together (#3436)
* fix(input): each pad is listed once in Windows games so both triggers read together

A pad that Wine's SDL backend also reads was described to Wine's udev
backend as a Steam Input virtual pad, so Wine built two devices for one
pad. SDL RawInput games could not match the two and read held triggers as
released. The pad now keeps the identity the SDL backend sees unless that
backend is told to skip it.

Rumble that Wine starts through SDL is now held until the next update,
matching the udev path, instead of stopping after one second.

* fix(input): hold only the rumble Wine starts through SDL, not later SDL rumble in the same process

* fix(input): read @file SDL ignore lists when choosing the pad identity

SDL reads the ignore and except lists from a file when the value starts
with @. Match the ring pad ID against that file's contents too.

* fix(input): parse SDL controller ID lists the way SDL does when choosing the pad identity
2026-11-29 20:24:20 -05:00
MaxsTechReview a9e8a01bb6 fix(native): prepare the rootfs before a helper starts outside a session (#3447)
Prepare the rootfs before a native program starts outside a session

The linker and libc are patched for Android's seccomp filter only when a
session starts. A helper started between sessions, after a runtime
update and before the first session, ran the unpatched linker and died
of SIGSYS (exit code 159). The shared native process builder now
prepares the rootfs itself when no session is running.
2026-11-29 19:44:11 -05:00
MaxsTechReview 861121144c fix(xbox): try the next listed executable when one is missing (#3446)
A package can list several PC executables while shipping only some of them. Try each listed executable in order and fail only when none of them exist.
2026-11-29 19:33:55 -05:00
51 changed files with 551 additions and 401 deletions

No files matched your search

@@ -1038,14 +1038,18 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
onHandled()
return
}
val files = game.gameFiles
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
val files = game.gameFiles?.takeIf { game.source == com.droiddeck.launcher.stores.Store.XBOX.id }
val steamClient = Library.fromSteamClient(game)
if (files == null && !steamClient) {
if (startGame(game, returnHome, onHandled, request)) onSettled()
else launchCoordinator.releaseHandling(request)
return
}
val app = applicationContext
Thread({
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
val refused = files != null && com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
val uncached = steamClient && !com.droiddeck.launcher.session.NoSteamLaunch.enabled(app, game) &&
com.droiddeck.launcher.session.OfflineMode.lacksAppInfo(app, game.appId)
ui.post {
when {
!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed -> {
@@ -1057,11 +1061,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
onSettled()
}
startGame(game, returnHome, onHandled, request) -> onSettled()
else -> launchCoordinator.releaseHandling(request)
else -> {
if (uncached) android.widget.Toast.makeText(this, getString(R.string.game_steam_offline_uncached, game.name), android.widget.Toast.LENGTH_LONG).show()
if (startGame(game, returnHome, onHandled, request)) onSettled()
else launchCoordinator.releaseHandling(request)
}
}
}
}, "xbox-app-model").start()
}, "game-launch-check").start()
}
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit, ticket: LaunchTicket): Boolean {
@@ -80,20 +80,38 @@ object SteamAppInfo {
private fun JSONArray?.strings(): List<String> = if (this == null) emptyList() else (0 until length()).map { optString(it) }
internal fun read(file: File, appId: Int): Info? {
if (!file.isFile) return null
internal fun read(file: File, appId: Int): Info? = scan(file, appId, unreadable = null, missing = null) { raf, entry ->
if (entry.size > 64L * 1024 * 1024) return@scan null
val body = ByteArray(entry.size.toInt())
raf.readFully(body)
val strings = entry.tableAt?.let { readStrings(raf, it) }
val kv = ByteBuffer.wrap(body, entry.fixed, body.size - entry.fixed).order(ByteOrder.LITTLE_ENDIAN)
val tree = readMap(kv, strings)
@Suppress("UNCHECKED_CAST")
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
infoOf(app)
}
fun cached(file: File, appId: Int): Boolean? =
runCatching { scan(file, appId, unreadable = null, missing = false) { _, _ -> true } }
.onFailure { Log.w(TAG, "appinfo: ${it.javaClass.simpleName}") }
.getOrNull()
private class Entry(val fixed: Int, val tableAt: Long?, val size: Long)
private fun <T> scan(file: File, appId: Int, unreadable: T, missing: T, found: (RandomAccessFile, Entry) -> T): T {
if (!file.isFile) return unreadable
RandomAccessFile(file, "r").use { raf ->
val head = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
raf.readFully(head.array(), 0, 8)
val magic = head.getInt(0)
val version = magic and 0xFF
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return null
var strings: List<String>? = null
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return unreadable
var tableAt: Long? = null
var pos = 8L
if (version >= 0x29) {
raf.readFully(head.array(), 8, 8)
val tableAt = head.getLong(8)
strings = readStrings(raf, tableAt)
tableAt = head.getLong(8)
pos = 16L
}
val fixed = if (version >= 0x28) 4 + 4 + 8 + 20 + 4 + 20 else 4 + 4 + 8 + 20 + 4
@@ -103,20 +121,11 @@ object SteamAppInfo {
raf.readFully(entry.array(), 0, 8)
val id = entry.getInt(0)
val size = entry.getInt(4).toLong() and 0xFFFFFFFFL
if (id == 0) return null
if (id == appId) {
if (size > 64L * 1024 * 1024) return null
val body = ByteArray(size.toInt())
raf.readFully(body)
val kv = ByteBuffer.wrap(body, fixed, body.size - fixed).order(ByteOrder.LITTLE_ENDIAN)
val tree = readMap(kv, strings)
@Suppress("UNCHECKED_CAST")
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
return infoOf(app)
}
if (id == 0) return missing
if (id == appId) return found(raf, Entry(fixed, tableAt, size))
pos += 8 + size
}
return null
return missing
}
}
@@ -112,8 +112,9 @@ object NativeGuest {
File(BwrapSpawner.hostPath(binds.map { BwrapSpawner.Bind.parse(it) }, root.path, cwd)).takeIf { it.isDirectory } ?: root
/** A process for [guest] (argv) started as proot would with [binds], in guest directory [cwd]. */
fun processBuilder(context: Context, root: File, binds: List<String>, guest: List<String>, cwd: String = "/root"): ProcessBuilder =
ProcessBuilder(command(root, guest.first(), guest.drop(1)))
fun processBuilder(context: Context, root: File, binds: List<String>, guest: List<String>, cwd: String = "/root"): ProcessBuilder {
if (sessionMode == null) prepare(context, root)
return ProcessBuilder(command(root, guest.first(), guest.drop(1)))
.directory(workingDirectory(root, binds, cwd))
.also { builder ->
builder.environment().apply {
@@ -121,6 +122,7 @@ object NativeGuest {
putAll(sessionEnvironment(root, binds, guest.first(), SessionPrefs.guestHostname(context)))
}
}
}
private const val RUNPATH_CONF = "etc/ld.so.conf.d/zz-droiddeck-native.conf"
private val SCAN_DIRS = listOf("usr/lib", "usr/local/lib", "opt")
@@ -149,6 +151,7 @@ object NativeGuest {
}
/** What a rootfs needs before anything runs in it natively; cheap once done. */
@Synchronized
fun prepare(context: Context, root: File) {
val relinked = relinkAbsoluteSymlinks(context, root)
if (relinked > 0) android.util.Log.i(TAG, "native userland: $relinked absolute symlinks made relative")
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.session
import android.content.Context
import android.util.Log
import com.droiddeck.launcher.agent.AgentGuest
import com.droiddeck.launcher.frontend.SteamAppInfo
import com.droiddeck.launcher.runtime.LinuxRuntime
import java.io.File
@@ -63,6 +64,9 @@ object OfflineMode {
fun active(context: Context): Boolean =
offline(enabled(context), isOnline(context), auto(context))
fun lacksAppInfo(context: Context, appId: Int): Boolean =
active(context) && SteamAppInfo.cached(SteamAppInfo.appinfoFile(context), appId) == false
@Synchronized
fun setEnabled(context: Context, on: Boolean) {
write(context, LinuxRuntime.rootDir(context), on)
@@ -94,17 +94,16 @@ internal object XboxManifest {
}
fun executable(folder: File): String {
for (path in read(folder).executables) {
val listed = read(folder).executables
for (path in listed) {
require(!path.startsWith('/') && !path.contains(':') && path.split('/').none { it == ".." || it.isEmpty() })
var file = folder
for (part in path.split('/')) {
val matches = file.listFiles().orEmpty().filter { it.name.equals(part, true) }
require(matches.size == 1) { "Missing or ambiguous Xbox launch path." }
file = matches.single()
}
val file = path.split('/').fold<String, File?>(folder) { dir, part ->
dir?.listFiles().orEmpty().filter { it.name.equals(part, true) }.singleOrNull()
} ?: continue
require(file.canonicalPath.startsWith(folder.canonicalPath + File.separator))
if (file.isFile) return forwarded(folder, file) ?: file.relativeTo(folder).invariantSeparatorsPath
}
require(listed.isEmpty()) { "Missing or ambiguous Xbox launch path." }
error("The Xbox package has no supported PC launch executable.")
}
@@ -195,6 +195,10 @@ internal fun librarySources(
}
}
internal fun alwaysLibraryTabs(signedIn: Collection<Store>, stores: Boolean, soundMode: Boolean): Set<String> =
(if (soundMode) emptyList() else signedIn.map { it.librarySource }).toSet() +
listOfNotNull(Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores })
internal object LibraryDisplay {
const val DEFAULT_LEVEL = 2
val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f)
@@ -374,7 +378,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
.map { it.store.id }.toSet()
val sources = librarySources(
all, storeTabs.map { it.store.id },
listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores }).toSet() + signInChips,
alwaysLibraryTabs(owned.keys, stores, soundMode) + signInChips,
favorites, concealed,
offStores = if (soundMode) emptySet() else storeTabs.filterNot { it.shown }.map { it.store.id }.toSet(),
places = if (soundMode) DEFAULT_LIBRARY_PLACES else StoreTabsState.libraryPlaces,
+1
View File
@@ -4310,4 +4310,5 @@
<string name="steam_store_linux_build">تثبّت هذه اللعبة إصدار Linux الخاص بها. ثبّتها من Steam.</string>
<string name="game_zoom_title">تكبير اللعبة</string>
<string name="game_zoom_hint">اضبط تكبير اللعبة من 100% إلى 300%</string>
<string name="game_steam_offline_uncached">Steam في وضع عدم الاتصال ولم يحمّل %1$s بعد. اتصل بالإنترنت في Steam مرة واحدة لتشغيلها.</string>
</resources>
@@ -4188,4 +4188,5 @@
<string name="steam_store_close_steam">Cierra Steam primero</string>
<string name="steam_store_session_wait">Pausa primero la descarga de Steam</string>
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y todavía no cargó %1$s. Conéctate en Steam una vez para jugarlo.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Тази игра инсталира версията си за Linux. Инсталирайте я от Steam.</string>
<string name="game_zoom_title">Мащабиране на играта</string>
<string name="game_zoom_hint">Регулирайте увеличението на играта от 100% до 300%</string>
<string name="game_steam_offline_uncached">Steam е в офлайн режим и още не е заредил %1$s. Свържете Steam онлайн веднъж, за да я играете.</string>
</resources>
+1
View File
@@ -4230,4 +4230,5 @@
<string name="steam_store_linux_build">Tato hra instaluje svou verzi pro Linux. Nainstalujte ji ze Steamu.</string>
<string name="game_zoom_title">Přiblížení hry</string>
<string name="game_zoom_hint">Nastavte zvětšení hry od 100 % do 300 %</string>
<string name="game_steam_offline_uncached">Steam je v režimu offline a %1$s ještě nenačetl. Jednou se ve Steamu připojte online, abyste ji mohli hrát.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Dette spil installerer sin Linux-version. Installer det fra Steam.</string>
<string name="game_zoom_title">Spilzoom</string>
<string name="game_zoom_hint">Juster spillets forstørrelse fra 100 % til 300 %</string>
<string name="game_steam_offline_uncached">Steam er i offlinetilstand og har ikke indlæst %1$s endnu. Gå online i Steam én gang for at spille det.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Dieses Spiel installiert seine Linux-Version. Installiere es über Steam.</string>
<string name="game_zoom_title">Spielzoom</string>
<string name="game_zoom_hint">Spielvergrößerung von 100 % bis 300 % anpassen</string>
<string name="game_steam_offline_uncached">Steam ist im Offlinemodus und hat %1$s noch nicht geladen. Gehe einmal in Steam online, um es zu spielen.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Αυτό το παιχνίδι εγκαθιστά την έκδοσή του για Linux. Εγκαταστήστε το από το Steam.</string>
<string name="game_zoom_title">Ζουμ παιχνιδιού</string>
<string name="game_zoom_hint">Ρυθμίστε τη μεγέθυνση του παιχνιδιού από 100% έως 300%</string>
<string name="game_steam_offline_uncached">Το Steam είναι σε λειτουργία εκτός σύνδεσης και δεν έχει φορτώσει ακόμη το %1$s. Συνδεθείτε μία φορά στο Steam για να το παίξετε.</string>
</resources>
+1
View File
@@ -4190,4 +4190,5 @@
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
<string name="game_zoom_title">Zoom del juego</string>
<string name="game_zoom_hint">Ajusta la ampliación del juego del 100 % al 300 %</string>
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y aún no ha cargado %1$s. Conéctate en Steam una vez para jugarlo.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Tämä peli asentaa Linux-versionsa. Asenna se Steamista.</string>
<string name="game_zoom_title">Pelin zoomaus</string>
<string name="game_zoom_hint">Säädä pelin suurennusta välillä 100–300 %</string>
<string name="game_steam_offline_uncached">Steam on offline-tilassa eikä ole vielä ladannut peliä %1$s. Siirry Steamissa kerran online-tilaan pelataksesi sitä.</string>
</resources>
+1
View File
@@ -4189,4 +4189,5 @@
<string name="steam_store_linux_build">Ce jeu installe sa version Linux. Installez-le depuis Steam.</string>
<string name="game_zoom_title">Zoom du jeu</string>
<string name="game_zoom_hint">Réglez le grossissement du jeu de 100 % à 300 %</string>
<string name="game_steam_offline_uncached">Steam est en mode hors ligne et n\'a pas encore chargé %1$s. Passez en ligne une fois dans Steam pour y jouer.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">यह गेम अपना Linux संस्करण इंस्टॉल करता है। इसे Steam से इंस्टॉल करें।</string>
<string name="game_zoom_title">गेम ज़ूम</string>
<string name="game_zoom_hint">गेम का ज़ूम 100% से 300% तक समायोजित करें</string>
<string name="game_steam_offline_uncached">Steam ऑफ़लाइन मोड में है और उसने अभी तक %1$s लोड नहीं किया है। इसे खेलने के लिए Steam में एक बार ऑनलाइन जाएँ।</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Ez a játék a Linux-verzióját telepíti. Telepítsd a Steamből.</string>
<string name="game_zoom_title">Játék nagyítása</string>
<string name="game_zoom_hint">A játék nagyításának beállítása 100% és 300% között</string>
<string name="game_steam_offline_uncached">A Steam offline módban van, és még nem töltötte be ezt: %1$s. A játékhoz egyszer lépj online módba a Steamben.</string>
</resources>
+1
View File
@@ -4120,4 +4120,5 @@
<string name="steam_store_linux_build">Game ini memasang versi Linux-nya. Pasang dari Steam.</string>
<string name="game_zoom_title">Zoom game</string>
<string name="game_zoom_hint">Sesuaikan pembesaran game dari 100% hingga 300%</string>
<string name="game_steam_offline_uncached">Steam dalam mode luring dan belum memuat %1$s. Hubungkan Steam secara daring sekali untuk memainkannya.</string>
</resources>
+1
View File
@@ -4189,4 +4189,5 @@
<string name="steam_store_linux_build">Questo gioco installa la sua versione Linux. Installalo da Steam.</string>
<string name="game_zoom_title">Zoom del gioco</string>
<string name="game_zoom_hint">Regola l\'ingrandimento del gioco dal 100% al 300%</string>
<string name="game_steam_offline_uncached">Steam è in modalità offline e non ha ancora caricato %1$s. Vai online in Steam una volta per giocarci.</string>
</resources>
+1
View File
@@ -4120,4 +4120,5 @@
<string name="steam_store_linux_build">このゲームは Linux 版をインストールします。Steam からインストールしてください。</string>
<string name="game_zoom_title">ゲームズーム</string>
<string name="game_zoom_hint">ゲームの拡大率を100%から300%の間で調整します</string>
<string name="game_steam_offline_uncached">Steam はオフラインモードのため、%1$s をまだ読み込んでいません。プレイするには Steam で一度オンラインにしてください。</string>
</resources>
+1
View File
@@ -4120,4 +4120,5 @@
<string name="steam_store_linux_build">이 게임은 Linux 버전을 설치합니다. Steam에서 설치하세요.</string>
<string name="game_zoom_title">게임 확대</string>
<string name="game_zoom_hint">게임 확대율을 100%에서 300%까지 조정합니다</string>
<string name="game_steam_offline_uncached">Steam이 오프라인 모드이며 아직 %1$s을(를) 불러오지 않았습니다. 플레이하려면 Steam에서 한 번 온라인으로 전환하세요.</string>
</resources>
+1
View File
@@ -4120,4 +4120,5 @@
<string name="steam_store_linux_build">Permainan ini memasang versi Linuxnya. Pasang daripada Steam.</string>
<string name="game_zoom_title">Zum permainan</string>
<string name="game_zoom_hint">Laraskan pembesaran permainan daripada 100% hingga 300%</string>
<string name="game_steam_offline_uncached">Steam dalam mod luar talian dan belum memuatkan %1$s. Pergi dalam talian dalam Steam sekali untuk memainkannya.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Dette spillet installerer Linux-versjonen sin. Installer det fra Steam.</string>
<string name="game_zoom_title">Spillzoom</string>
<string name="game_zoom_hint">Juster spillforstørrelsen fra 100 % til 300 %</string>
<string name="game_steam_offline_uncached">Steam er i frakoblet modus og har ikke lastet inn %1$s ennå. Gå tilkoblet i Steam én gang for å spille det.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Deze game installeert zijn Linux-versie. Installeer hem via Steam.</string>
<string name="game_zoom_title">Gamezoom</string>
<string name="game_zoom_hint">Pas de spelvergroting aan van 100% tot 300%</string>
<string name="game_steam_offline_uncached">Steam staat in offlinemodus en heeft %1$s nog niet geladen. Ga één keer online in Steam om het te spelen.</string>
</resources>
+1
View File
@@ -4230,4 +4230,5 @@
<string name="steam_store_linux_build">Ta gra instaluje swoją wersję dla Linuksa. Zainstaluj ją ze Steama.</string>
<string name="game_zoom_title">Powiększenie gry</string>
<string name="game_zoom_hint">Dostosuj powiększenie gry w zakresie od 100% do 300%</string>
<string name="game_steam_offline_uncached">Steam jest w trybie offline i nie wczytał jeszcze %1$s. Przejdź raz do trybu online w Steamie, aby w to zagrać.</string>
</resources>
@@ -4189,4 +4189,5 @@
<string name="steam_store_linux_build">Este jogo instala a sua versão para Linux. Instale-o a partir do Steam.</string>
<string name="game_zoom_title">Zoom do jogo</string>
<string name="game_zoom_hint">Ajuste a ampliação do jogo de 100% a 300%</string>
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
</resources>
+1
View File
@@ -4197,4 +4197,5 @@
<string name="steam_store_close_steam">Feche o Steam primeiro</string>
<string name="steam_store_session_wait">Pause o download do Steam primeiro</string>
<string name="steam_store_linux_build">Este jogo instala sua versão para Linux. Instale-o pelo Steam.</string>
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
</resources>
+1
View File
@@ -4190,4 +4190,5 @@
<string name="steam_store_linux_build">Acest joc își instalează versiunea pentru Linux. Instalează-l din Steam.</string>
<string name="game_zoom_title">Zoom joc</string>
<string name="game_zoom_hint">Reglați mărirea jocului între 100% și 300%</string>
<string name="game_steam_offline_uncached">Steam este în modul offline și nu a încărcat încă %1$s. Treci o dată online în Steam ca să îl joci.</string>
</resources>
+1
View File
@@ -4231,4 +4231,5 @@
<string name="steam_store_linux_build">Эта игра устанавливает свою версию для Linux. Установите её из Steam.</string>
<string name="game_zoom_title">Масштаб игры</string>
<string name="game_zoom_hint">Настройте увеличение игры от 100% до 300%</string>
<string name="game_steam_offline_uncached">Steam в автономном режиме и ещё не загрузил %1$s. Чтобы играть, один раз переведите Steam в сеть.</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Det här spelet installerar sin Linux-version. Installera det från Steam.</string>
<string name="game_zoom_title">Spelzoom</string>
<string name="game_zoom_hint">Justera spelförstoringen från 100 % till 300 %</string>
<string name="game_steam_offline_uncached">Steam är i offlineläge och har inte läst in %1$s än. Gå online i Steam en gång för att spela det.</string>
</resources>
+1
View File
@@ -4120,4 +4120,5 @@
<string name="steam_store_linux_build">เกมนี้ติดตั้งเวอร์ชัน Linux ของตัวเอง ให้ติดตั้งจาก Steam</string>
<string name="game_zoom_title">ซูมเกม</string>
<string name="game_zoom_hint">ปรับการขยายเกมตั้งแต่ 100% ถึง 300%</string>
<string name="game_steam_offline_uncached">Steam อยู่ในโหมดออฟไลน์และยังไม่ได้โหลด %1$s ออนไลน์ใน Steam หนึ่งครั้งเพื่อเล่นเกมนี้</string>
</resources>
+1
View File
@@ -4150,4 +4150,5 @@
<string name="steam_store_linux_build">Bu oyun Linux sürümünü yükler. Steam\'den yükleyin.</string>
<string name="game_zoom_title">Oyun yakınlaştırma</string>
<string name="game_zoom_hint">Oyun yakınlaştırmasını %100 ile %300 arasında ayarlayın</string>
<string name="game_steam_offline_uncached">Steam çevrimdışı modda ve %1$s henüz yüklenmedi. Oynamak için Steam\'de bir kez çevrimiçi olun.</string>
</resources>
+1
View File
@@ -4230,4 +4230,5 @@
<string name="steam_store_linux_build">Ця гра встановлює свою версію для Linux. Установіть її зі Steam.</string>
<string name="game_zoom_title">Масштаб гри</string>
<string name="game_zoom_hint">Налаштуйте збільшення гри від 100% до 300%</string>
<string name="game_steam_offline_uncached">Steam в офлайн-режимі й ще не завантажив %1$s. Щоб грати, один раз перейдіть у Steam онлайн.</string>
</resources>
+1
View File
@@ -4120,4 +4120,5 @@
<string name="steam_store_linux_build">Trò chơi này cài bản dành cho Linux. Hãy cài từ Steam.</string>
<string name="game_zoom_title">Thu phóng trò chơi</string>
<string name="game_zoom_hint">Điều chỉnh độ phóng đại trò chơi từ 100% đến 300%</string>
<string name="game_steam_offline_uncached">Steam đang ở chế độ ngoại tuyến và chưa tải %1$s. Hãy trực tuyến trong Steam một lần để chơi.</string>
</resources>
@@ -4118,4 +4118,5 @@
<string name="steam_store_close_steam">请先关闭 Steam</string>
<string name="steam_store_session_wait">请先暂停 Steam 下载</string>
<string name="steam_store_linux_build">此游戏会安装其 Linux 版本。请通过 Steam 安装。</string>
<string name="game_steam_offline_uncached">Steam 处于离线模式,尚未加载 %1$s。请在 Steam 中联网一次后再玩。</string>
</resources>
@@ -4118,4 +4118,5 @@
<string name="steam_store_close_steam">請先關閉 Steam</string>
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
</resources>
@@ -4118,4 +4118,5 @@
<string name="steam_store_close_steam">請先關閉 Steam</string>
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
</resources>
+1
View File
@@ -1755,6 +1755,7 @@
<string name="game_link_session_busy">Stop the current session before launching a Steam game.</string>
<string name="game_link_failed">Could not send the game to Steam. Try launching it again.</string>
<string name="game_needs_app_model">%1$s is a UWP app. This runtime has no Windows app-model host to start it.</string>
<string name="game_steam_offline_uncached">Steam is in offline mode and has not loaded %1$s yet. Go online in Steam once to play it.</string>
<string name="setup_retry_removal">Retry removal</string>
<string name="runtime_removing">Removing</string>
<string name="runtime_removal_incomplete">Removal incomplete</string>
@@ -0,0 +1,64 @@
package com.droiddeck.launcher.frontend
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.ByteBuffer
import java.nio.ByteOrder
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class SteamAppInfoTest {
@get:Rule val tmp = TemporaryFolder()
private fun file() = File(tmp.newFolder(), "appinfo.vdf")
private fun le(size: Int) = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN)
private fun writeV28(file: File, appId: Int, name: String) {
val kv = ByteArrayOutputStream().apply {
fun cstring(s: String) { write(s.toByteArray()); write(0) }
write(0x00); cstring("appinfo")
write(0x00); cstring("common")
write(0x01); cstring("name"); cstring(name)
write(0x08); write(0x08); write(0x08)
}.toByteArray()
val body = ByteArray(60) + kv
val out = le(8 + 8 + body.size + 4).putInt(0x07564428).putInt(1).putInt(appId).putInt(body.size).put(body).putInt(0)
file.writeBytes(out.array())
}
@Test fun anAppInTheClientsCacheIsToldApartFromOneMissingFromIt() {
val file = file()
WinCompSourcesTest.writeAppinfo(file, 17470)
assertEquals(true, SteamAppInfo.cached(file, 17470))
assertEquals(false, SteamAppInfo.cached(file, 1145360))
}
@Test fun theOlderFormatWithoutAStringTableIsReadToo() {
val file = file()
writeV28(file, 17470, "Some Game")
assertTrue(SteamAppInfo.cached(file, 17470)!!)
assertFalse(SteamAppInfo.cached(file, 22330)!!)
assertEquals("Some Game", SteamAppInfo.read(file, 17470)!!.name)
assertNull(SteamAppInfo.read(file, 22330))
}
@Test fun aMissingOrUnknownCacheIsNotTakenAsMissingTheApp() {
val missing = file()
assertNull(SteamAppInfo.cached(missing, 17470))
val newer = file().apply { writeBytes(le(16).putInt(0x0756442A).putInt(1).array()) }
assertNull(SteamAppInfo.cached(newer, 17470))
val garbage = file().apply { writeBytes(byteArrayOf(1, 2, 3)) }
assertNull(SteamAppInfo.cached(garbage, 17470))
}
}
@@ -0,0 +1,79 @@
package com.droiddeck.launcher.runtime
import androidx.test.core.app.ApplicationProvider
import java.io.File
import java.nio.ByteBuffer
import java.nio.ByteOrder
import java.nio.file.Files
import org.junit.After
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class NativeGuestPrepareTest {
private val svc = 0xd4000001.toInt()
private val rseq = 0xd28024a8.toInt()
private val enosys = 0x928004a0.toInt()
private fun unpatchedLoader(): ByteArray {
val data = ByteArray(0x200)
val b = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN)
b.put(0, 0x7f); b.put(1, 'E'.code.toByte()); b.put(2, 'L'.code.toByte()); b.put(3, 'F'.code.toByte())
b.put(4, 2); b.put(5, 1)
b.putShort(18, 183)
b.putLong(32, 64)
b.putShort(54, 56); b.putShort(56, 1)
b.putInt(64, 1); b.putInt(68, 5)
b.putLong(72, 0x100); b.putLong(96, 0x100)
b.putInt(0x100, rseq); b.putInt(0x104, svc)
return data
}
private fun rootWithUnpatchedLoader(): Pair<File, File> {
val root = Files.createTempDirectory("native-prepare").toFile()
val loader = File(root, "usr/lib/ld-linux-aarch64.so.1")
loader.parentFile!!.mkdirs()
loader.writeBytes(unpatchedLoader())
return root to loader
}
private fun instructionAfterRseq(loader: File): Int =
ByteBuffer.wrap(loader.readBytes()).order(ByteOrder.LITTLE_ENDIAN).getInt(0x104)
@After
fun endSession() {
NativeGuest.sessionMode = null
}
@Test
fun aProgramStartedOutsideASessionGetsALoaderThatSurvivesSeccomp() {
val (root, loader) = rootWithUnpatchedLoader()
NativeGuest.sessionMode = null
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
assertEquals(enosys, instructionAfterRseq(loader))
}
@Test
fun aProgramStartedInARunningSessionLeavesTheRootfsAsTheSessionPreparedIt() {
val (root, loader) = rootWithUnpatchedLoader()
val before = loader.readBytes()
NativeGuest.sessionMode = true
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
assertArrayEquals(before, loader.readBytes())
}
@Test
fun anAlreadyPreparedLoaderIsNotRewritten() {
val (root, loader) = rootWithUnpatchedLoader()
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
val modified = loader.lastModified()
val bytes = loader.readBytes()
loader.setLastModified(modified - 10_000)
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
assertArrayEquals(bytes, loader.readBytes())
assertEquals(modified - 10_000, loader.lastModified())
}
}
@@ -54,6 +54,32 @@ class OfflineModeTest {
shadowOf(cm).setNetworkCapabilities(cm.activeNetwork, caps)
}
private fun clientCache(appId: Int) =
com.droiddeck.launcher.frontend.WinCompSourcesTest.writeAppinfo(com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context), appId)
@Test
fun offlineSteamReportsAGameMissingFromItsCache() {
writeSteam("1")
clientCache(220)
assertTrue(OfflineMode.active(context))
assertTrue(OfflineMode.lacksAppInfo(context, 17470))
assertFalse(OfflineMode.lacksAppInfo(context, 220))
}
@Test
fun onlineSteamNeverReportsAMissingGame() {
clientCache(220)
assertFalse(OfflineMode.active(context))
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
}
@Test
fun offlineSteamWithoutAReadableCacheReportsNothing() {
writeSteam("1")
com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context).delete()
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
}
@Test
fun offlineWhenChosenOrWithoutInternet() {
assertFalse(OfflineMode.offline(manual = false, online = true))
@@ -16,6 +16,34 @@ class XboxManifestTest {
java.io.File(root, "MicrosoftGame.Config").writeText("<Game><ExecutableList><Executable Name=\"bin\\GAME.EXE\" TargetDeviceFamily=\"PC\"/></ExecutableList></Game>")
assertEquals("Bin/Game.exe", XboxInstaller.executable(root))
}
@Test fun aListedExecutableThePackageDoesNotShipFallsThroughToTheNextOne() {
val root = temporary.newFolder()
java.io.File(root, "bin/x64_dx12").mkdirs()
java.io.File(root, "bin/x64_dx12/game.exe").writeText("encrypted")
java.io.File(root, "MicrosoftGame.config").writeText("<Game><ExecutableList>" +
"<Executable Name=\"bin\\x64\\game.exe\" TargetDeviceFamily=\"PC\"/>" +
"<Executable Name=\"Launcher\\start.exe\" TargetDeviceFamily=\"PC\"/>" +
"<Executable Name=\"bin\\x64_dx12\\game.exe\" TargetDeviceFamily=\"PC\"/></ExecutableList></Game>")
assertEquals("bin/x64_dx12/game.exe", XboxInstaller.executable(root))
}
@Test fun anAmbiguouslyCasedExecutableFallsThroughToTheNextOne() {
val root = temporary.newFolder()
java.io.File(root, "Game.exe").writeText("one")
java.io.File(root, "GAME.exe").writeText("two")
java.io.File(root, "Other.exe").writeText("three")
org.junit.Assume.assumeTrue(root.listFiles().orEmpty().count { it.name.equals("game.exe", true) } == 2)
java.io.File(root, "MicrosoftGame.config").writeText("<Game><ExecutableList>" +
"<Executable Name=\"game.exe\"/><Executable Name=\"Other.exe\"/></ExecutableList></Game>")
assertEquals("Other.exe", XboxInstaller.executable(root))
}
@Test fun aPackageWithNoneOfItsListedExecutablesStillFails() {
val root = temporary.newFolder()
java.io.File(root, "Unlisted.exe").writeText("encrypted")
java.io.File(root, "MicrosoftGame.config").writeText("<Game><ExecutableList>" +
"<Executable Name=\"bin\\Game.exe\"/><Executable Name=\"Game.exe\"/></ExecutableList></Game>")
val failure = assertThrows(IllegalArgumentException::class.java) { XboxInstaller.executable(root) }
assertEquals("Missing or ambiguous Xbox launch path.", failure.message)
}
@Test fun aLauncherMenuIsSkippedForTheProgramItNames() {
val root = temporary.newFolder()
java.io.File(root, "EmuMenu").mkdir()
@@ -122,6 +122,19 @@ class LibraryEntriesTest {
assertEquals(listOf("steam", "xbox", "itch", "gamejolt"), librarySources(entries, listOf("xbox", "itch", "gamejolt"), setOf("itch", "gamejolt")))
}
@Test fun everySignedInStoreKeepsItsTabWhenItsLibraryIsEmptyOrFailedToLoad() {
val entries = listOf(LibraryEntry("epic:1", "epic", "Game", null, null, true))
val order = listOf("epic", Store.ROCKSTAR.id, "gog")
val always = alwaysLibraryTabs(listOf(Store.STEAM, Store.ROCKSTAR), stores = true, soundMode = false)
assertEquals(listOf("steam", "epic", "rockstar", "battlenet", "added"), librarySources(entries, order, always))
}
@Test fun signedOutStoresAndSoundtrackModeDoNotGainEmptyTabs() {
assertEquals(setOf("added", "battlenet"), alwaysLibraryTabs(emptyList(), stores = true, soundMode = false))
assertEquals(setOf("added", "battlenet"), alwaysLibraryTabs(listOf(Store.STEAM, Store.ROCKSTAR), stores = true, soundMode = true))
assertEquals(emptySet<String>(), alwaysLibraryTabs(emptyList(), stores = false, soundMode = false))
}
@Test fun gameKeysNameEitherAnAppOrAStoreProduct() {
GameRef.parse("app:440").let { assertEquals(440, it.appId); assertNull(it.store) }
GameRef.parse("app:-12").let { assertEquals(-12, it.appId) }
-11
View File
@@ -484,14 +484,3 @@ not wait on fences attached to a dma-buf, so the composite now checks each outpu
It picks the next image that is neither held by the host nor still being scanned out. Only when every free image is
still on the display does it wait for one, up to 100 ms. On kernels that cannot attach the fence, the host keeps
waiting itself and nothing changes. `tools/gamescope/tests/nested-swapchain.cpp` covers the choice and the busy check.
## 0147 wlserver: a touch click presses after the pointer has moved to the finger
In the Left, Right and Middle touch click modes a touch-down warped the pointer to the finger and pressed the button in
the same instant. A game that handles the press before it updates the hovered item on that frame acted on the item
under the previous tap. When the touch-down moves the pointer, the press now waits 34 ms, about one frame at 30 fps, so
the game sees the hover first. A tap that lifts sooner, or within 50 ms of the press, keeps the button down for 50 ms,
so the game still sees a press and a release on separate frames. A finger that moves more than 16 pixels before the
press presses at once where it touched, so drags start under the finger. A new touch first finishes the previous tap.
A touch that does not move the pointer, and trackpad mode, press at once as before.
`tools/tests/test_gamescope_touch_click_hover.py` compiles the rule from this patch.
@@ -1,248 +0,0 @@
diff --git a/src/wlserver.cpp b/src/wlserver.cpp
--- a/src/wlserver.cpp
+++ b/src/wlserver.cpp
@@ -3315,6 +3315,167 @@ static bool touch_click_lift( TouchClickState &state, int nTouchId )
return !bTracked && state.nOwner < 0;
}
+static bool touch_click_release_held( uint32_t time )
+{
+ bool bReleasedAny = false;
+ for ( int i = 0; i < WLSERVER_BUTTON_COUNT; i++ )
+ {
+ if ( wlserver.button_held[ i ] == true )
+ {
+ uint32_t button = TouchClickModeToLinuxButton( (gamescope::TouchClickMode) i );
+
+ if ( button != 0 )
+ {
+ wlr_seat_pointer_notify_button( wlserver.wlr.seat, time, button, WL_POINTER_BUTTON_STATE_RELEASED );
+ bReleasedAny = true;
+ }
+
+ wlserver.button_held[ i ] = false;
+ }
+ }
+
+ if ( bReleasedAny == true )
+ {
+ wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
+ }
+ return bReleasedAny;
+}
+
+static constexpr uint64_t k_ulTouchClickHoverNs = 34'000'000ul;
+static constexpr uint64_t k_ulTouchClickHoldNs = 50'000'000ul;
+static constexpr double k_flTouchClickSlop = 16.0;
+
+enum class TouchClickStep { Idle, Press, Release };
+
+struct TouchClickTap
+{
+ uint32_t uButton = 0;
+ uint32_t uTime = 0;
+ uint64_t ulEventAt = 0;
+ uint64_t ulPressedAt = 0;
+ double flDownX = 0.0;
+ double flDownY = 0.0;
+ bool bPressPending = false;
+ bool bLifted = false;
+};
+
+static uint64_t touch_click_tap_down( TouchClickTap &tap, uint32_t uButton, uint32_t uTime, uint64_t ulNow, double flX, double flY, bool bMoved )
+{
+ tap = TouchClickTap{};
+ tap.uButton = uButton;
+ tap.uTime = uTime;
+ tap.ulEventAt = ulNow;
+ tap.flDownX = flX;
+ tap.flDownY = flY;
+ tap.bPressPending = bMoved;
+ if ( !bMoved )
+ tap.ulPressedAt = ulNow;
+ return bMoved ? k_ulTouchClickHoverNs : 0;
+}
+
+static bool touch_click_tap_motion( const TouchClickTap &tap, double flX, double flY )
+{
+ return tap.bPressPending && std::hypot( flX - tap.flDownX, flY - tap.flDownY ) > k_flTouchClickSlop;
+}
+
+static void touch_click_tap_pressed( TouchClickTap &tap, uint64_t ulNow )
+{
+ tap.bPressPending = false;
+ tap.ulPressedAt = ulNow;
+}
+
+static bool touch_click_tap_up( TouchClickTap &tap, uint32_t uTime, uint64_t ulNow, uint64_t *pDelay )
+{
+ tap.bLifted = true;
+ tap.uTime = uTime;
+ tap.ulEventAt = ulNow;
+ *pDelay = 0;
+ if ( tap.bPressPending )
+ return true;
+ const uint64_t ulHeld = ulNow - tap.ulPressedAt;
+ if ( ulHeld >= k_ulTouchClickHoldNs )
+ {
+ tap = TouchClickTap{};
+ return false;
+ }
+ *pDelay = k_ulTouchClickHoldNs - ulHeld;
+ return true;
+}
+
+static TouchClickStep touch_click_tap_fire( TouchClickTap &tap, uint64_t ulNow, uint64_t *pDelay )
+{
+ *pDelay = 0;
+ if ( tap.bPressPending )
+ {
+ touch_click_tap_pressed( tap, ulNow );
+ if ( tap.bLifted )
+ *pDelay = k_ulTouchClickHoldNs;
+ return TouchClickStep::Press;
+ }
+ if ( tap.bLifted )
+ {
+ tap = TouchClickTap{};
+ return TouchClickStep::Release;
+ }
+ return TouchClickStep::Idle;
+}
+
+static uint32_t touch_click_tap_time( const TouchClickTap &tap, uint64_t ulNow )
+{
+ return tap.uTime + uint32_t( ( ulNow - tap.ulEventAt ) / 1'000'000ul );
+}
+
+static TouchClickTap s_TouchTap;
+static struct wl_event_source *s_pTouchTapTimer = nullptr;
+
+static bool touch_click_tap_arm( uint64_t ulDelay )
+{
+ if ( !s_pTouchTapTimer )
+ s_pTouchTapTimer = wl_event_loop_add_timer( wlserver.event_loop, []( void * ) -> int
+ {
+ uint64_t ulDelay = 0;
+ const uint64_t ulNow = get_time_in_nanos();
+ const uint32_t uTime = touch_click_tap_time( s_TouchTap, ulNow );
+ const uint32_t uButton = s_TouchTap.uButton;
+ const TouchClickStep eStep = touch_click_tap_fire( s_TouchTap, ulNow, &ulDelay );
+ if ( eStep == TouchClickStep::Press )
+ {
+ wlr_seat_pointer_notify_button( wlserver.wlr.seat, uTime, uButton, WL_POINTER_BUTTON_STATE_PRESSED );
+ wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
+ if ( ulDelay )
+ touch_click_tap_arm( ulDelay );
+ }
+ else if ( eStep == TouchClickStep::Release )
+ {
+ touch_click_release_held( uTime );
+ }
+ bump_input_counter();
+ return 0;
+ }, nullptr );
+ if ( !s_pTouchTapTimer )
+ return false;
+ wl_event_source_timer_update( s_pTouchTapTimer, int( std::max<uint64_t>( 1, ( ulDelay + 999'999ul ) / 1'000'000ul ) ) );
+ return true;
+}
+
+static void touch_click_tap_settle( uint64_t ulNow )
+{
+ if ( s_pTouchTapTimer )
+ wl_event_source_timer_update( s_pTouchTapTimer, 0 );
+ uint64_t ulDelay = 0;
+ const uint32_t uTime = touch_click_tap_time( s_TouchTap, ulNow );
+ const uint32_t uButton = s_TouchTap.uButton;
+ TouchClickStep eStep = touch_click_tap_fire( s_TouchTap, ulNow, &ulDelay );
+ if ( eStep == TouchClickStep::Press )
+ {
+ wlr_seat_pointer_notify_button( wlserver.wlr.seat, uTime, uButton, WL_POINTER_BUTTON_STATE_PRESSED );
+ wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
+ eStep = touch_click_tap_fire( s_TouchTap, ulNow, &ulDelay );
+ }
+ if ( eStep == TouchClickStep::Release )
+ touch_click_release_held( uTime );
+}
+
void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time, bool bAlwaysWarpCursor, gamescope::IBackendConnector* connector )
{
assert( wlserver_is_lock_held() );
@@ -3372,6 +3533,9 @@ void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time, bool
{
g_bPendingTouchMovement = true;
+ if ( touch_click_drives( s_TouchClick, touch_id ) && touch_click_tap_motion( s_TouchTap, tx, ty ) )
+ touch_click_tap_settle( get_time_in_nanos() );
+
wlserver_mousewarp( tx, ty, time, false, !bAlwaysWarpCursor );
}
}
@@ -3426,18 +3590,30 @@ void wlserver_touchdown( double x, double y, int touch_id, uint32_t time, gamesc
{
g_bPendingTouchMovement = true;
+ const uint64_t ulNow = get_time_in_nanos();
+ touch_click_tap_settle( ulNow );
+
+ bool bMoved = false;
if ( eMode != gamescope::TouchClickModes::Trackpad )
{
+ const double flFromX = wlserver.mouse_surface_cursorx;
+ const double flFromY = wlserver.mouse_surface_cursory;
wlserver_mousewarp( tx, ty, time, false, true );
wlserver.ulTouchDownWarps++;
+ bMoved = flFromX != wlserver.mouse_surface_cursorx || flFromY != wlserver.mouse_surface_cursory;
}
uint32_t button = TouchClickModeToLinuxButton( eMode );
if ( touch_click_press( wlserver.button_held, eMode, button ) )
{
- wlr_seat_pointer_notify_button( wlserver.wlr.seat, time, button, WL_POINTER_BUTTON_STATE_PRESSED );
- wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
+ const uint64_t ulDelay = touch_click_tap_down( s_TouchTap, button, time, ulNow, tx, ty, bMoved );
+ if ( !ulDelay || !touch_click_tap_arm( ulDelay ) )
+ {
+ touch_click_tap_pressed( s_TouchTap, ulNow );
+ wlr_seat_pointer_notify_button( wlserver.wlr.seat, time, button, WL_POINTER_BUTTON_STATE_PRESSED );
+ wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
+ }
}
}
}
@@ -3450,28 +3626,12 @@ void wlserver_touchup( int touch_id, uint32_t time )
assert( wlserver_is_lock_held() );
// Release whatever the touch pressed even if its surface is gone, or the seat keeps the button down.
- bool bReleasedAny = false;
const bool bClickTouch = touch_click_lift( s_TouchClick, touch_id );
- for ( int i = 0; bClickTouch && i < WLSERVER_BUTTON_COUNT; i++ )
- {
- if ( wlserver.button_held[ i ] == true )
- {
- uint32_t button = TouchClickModeToLinuxButton( (gamescope::TouchClickMode) i );
-
- if ( button != 0 )
- {
- wlr_seat_pointer_notify_button( wlserver.wlr.seat, time, button, WL_POINTER_BUTTON_STATE_RELEASED );
- bReleasedAny = true;
- }
-
- wlserver.button_held[ i ] = false;
- }
- }
-
- if ( bReleasedAny == true )
- {
- wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
- }
+ uint64_t ulDelay = 0;
+ if ( bClickTouch && !touch_click_tap_up( s_TouchTap, time, get_time_in_nanos(), &ulDelay ) )
+ touch_click_release_held( time );
+ else if ( bClickTouch && ulDelay && !touch_click_tap_arm( ulDelay ) )
+ touch_click_tap_settle( get_time_in_nanos() );
if ( wlserver.touch_down_ids.count( touch_id ) > 0 )
{
+2 -2
View File
@@ -1,3 +1,3 @@
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
GAMESCOPE_TAG=gamescope-3.16.29-53b5432e
GAMESCOPE_SHA256=f88afe15f6b0fbb980cf4c7d9b757819c92131adf69eebf2c40a3dd53153df1f
GAMESCOPE_TAG=gamescope-3.16.29-f3a45b31
GAMESCOPE_SHA256=3908af87b2ee8a328e9780fc805c6a7bddd11d7405b9992d717b94e16c019313
+113 -8
View File
@@ -34,6 +34,8 @@
"NAME=\"Xbox 360 Controller (%d)\"\n" \
"PHYS=\"usb-fakeinput/input%d\"\n"
#define RING_SDL_ID 0x045e028eu
#define PARENT_NAME "droiddeck-input"
#define PARENT_SYSPATH_FORMAT "/sys/devices/droiddeck%d/" PARENT_NAME "%d"
#define EVENT_SYSPATH_FORMAT PARENT_SYSPATH_FORMAT "/event%d"
@@ -49,6 +51,8 @@ struct pad {
int live;
};
static const char *ring_uevent_format(void);
static struct pad pads[PAD_MAX];
static struct pad parents[PAD_MAX];
static int pad_count;
@@ -89,7 +93,7 @@ static void discover_pads(void) {
snprintf(pad->syspath, sizeof(pad->syspath), EVENT_SYSPATH_FORMAT, (int)slot, (int)slot,
(int)slot);
snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%ld", slot);
snprintf(pad->uevent, sizeof(pad->uevent), PAD_UEVENT_FORMAT, (int)slot, (int)slot);
snprintf(pad->uevent, sizeof(pad->uevent), ring_uevent_format(), (int)slot, (int)slot);
pad->devnum = makedev(13, EVENT_MINOR_BASE + (unsigned int)slot);
pad->node = (int)slot;
pad->live = 1;
@@ -137,6 +141,68 @@ static int any_virtual_pad(void) {
return 0;
}
static char *sdl_id_list_text(const char *list) {
char *text = NULL;
char *grown;
size_t length = 0;
size_t got;
FILE *file;
if (list[0] != '@') return strdup(list);
file = fopen(list + 1, "re");
if (file == NULL) return NULL;
do {
grown = realloc(text, length + 4097);
if (grown == NULL) {
free(text);
fclose(file);
return NULL;
}
text = grown;
got = fread(text + length, 1, 4096, file);
length += got;
} while (got > 0);
fclose(file);
text[length] = '\0';
return text;
}
static int sdl_id_list_entries(const char *list, int *has_ring) {
char *text = sdl_id_list_text(list);
char *spot = text;
uint32_t entry;
int entries = 0;
*has_ring = 0;
if (text == NULL) return 0;
while ((spot = strstr(spot, "0x")) != NULL) {
entry = (uint32_t)(uint16_t)strtol(spot, &spot, 0) << 16;
spot = strstr(spot, "0x");
if (spot == NULL) break;
entry |= (uint16_t)strtol(spot, &spot, 0);
entries++;
if (entry == RING_SDL_ID) *has_ring = 1;
}
free(text);
return entries;
}
static int sdl_bus_skips_ring_pad(void) {
const char *steam_virtual = getenv("FAKE_EVDEV_STEAM_VIRTUAL");
const char *except = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT");
const char *ignore = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES");
int has_ring;
if (steam_virtual != NULL && atoi(steam_virtual) != 0) return 1;
if (except != NULL && sdl_id_list_entries(except, &has_ring) > 0) return !has_ring;
return ignore != NULL && sdl_id_list_entries(ignore, &has_ring) > 0 && has_ring;
}
static const char *ring_uevent_format(void) {
if (uinput_enabled() && any_virtual_pad()) return PAD_PHYSICAL_UEVENT_FORMAT;
return sdl_bus_skips_ring_pad() ? PAD_UEVENT_FORMAT : PAD_PHYSICAL_UEVENT_FORMAT;
}
static void refresh_locked(int node) {
struct pad *pad = &pads[node];
@@ -167,9 +233,7 @@ static void refresh_locked(int node) {
} else {
snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%d", node);
pad->live = 1;
if (uinput_enabled())
snprintf(pad->uevent, sizeof(pad->uevent),
any_virtual_pad() ? PAD_PHYSICAL_UEVENT_FORMAT : PAD_UEVENT_FORMAT, node, node);
snprintf(pad->uevent, sizeof(pad->uevent), ring_uevent_format(), node, node);
}
}
sync_parent(node);
@@ -441,11 +505,48 @@ static void *next_symbol(const char *name) {
char *dd_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *))
__attribute__((visibility("hidden")));
static int caller_is_winebus(void *caller) {
static int caller_in_library(void *caller, const char *library) {
Dl_info info;
if (dladdr(caller, &info) == 0 || info.dli_fname == NULL) return 0;
return strstr(info.dli_fname, "winebus.so") != NULL;
return strstr(info.dli_fname, library) != NULL;
}
static int caller_is_winebus(void *caller) { return caller_in_library(caller, "winebus.so"); }
typedef int (*sdl_rumble_fn)(void *, uint16_t, uint16_t, uint32_t);
static _Atomic(sdl_rumble_fn) real_sdl_rumble;
static __thread int winebus_sdl_call;
static int winebus_sdl_rumble(void *joystick, uint16_t low, uint16_t high, uint32_t duration) {
sdl_rumble_fn real = atomic_load_explicit(&real_sdl_rumble, memory_order_acquire);
int result;
if (!caller_is_winebus(__builtin_return_address(0))) return real(joystick, low, high, duration);
if (low != 0 || high != 0) duration = 0;
winebus_sdl_call = 1;
result = real(joystick, low, high, duration);
winebus_sdl_call = 0;
return result;
}
static void *winebus_sdl_rumble_dlsym(void *handle, const char *name) {
(void)handle;
(void)name;
return (void *)winebus_sdl_rumble;
}
static void *sdl_rumble_target(void *handle, void *(*forward)(void *, const char *)) {
sdl_rumble_fn expected = NULL;
sdl_rumble_fn found;
if (handle == RTLD_NEXT || handle == RTLD_DEFAULT) return NULL;
found = (sdl_rumble_fn)forward(handle, "SDL_JoystickRumble");
if (found == NULL) return NULL;
atomic_compare_exchange_strong_explicit(&real_sdl_rumble, &expected, found, memory_order_acq_rel,
memory_order_acquire);
if (atomic_load_explicit(&real_sdl_rumble, memory_order_acquire) != found) return NULL;
return (void *)winebus_sdl_rumble_dlsym;
}
__attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd,
@@ -454,7 +555,8 @@ __attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(in
struct ff_effect *effect = arg;
__u16 length;
if (request != EVIOCSFF || effect == NULL || effect->type != FF_RUMBLE || !caller_is_winebus(caller)) return 0;
if (request != EVIOCSFF || effect == NULL || effect->type != FF_RUMBLE) return 0;
if (!caller_is_winebus(caller) && !(winebus_sdl_call && caller_in_library(caller, "libSDL"))) return 0;
length = effect->replay.length;
effect->replay.length = 0;
*rc = real(fd, request, arg);
@@ -1195,7 +1297,10 @@ static void *own_dlsym(void *handle, const char *name) {
__attribute__((visibility("hidden"), used)) void *inputudev_dlsym_target(void *handle, const char *name) {
void *forward = real_dlsym();
(void)handle;
if (forward != NULL && name != NULL && strcmp(name, "SDL_JoystickRumble") == 0) {
void *rumble = sdl_rumble_target(handle, forward);
if (rumble != NULL) return rumble;
}
if (name != NULL && strncmp(name, "udev_", 5) == 0 && own_udev_symbol(name) != NULL &&
!steam_client_process())
return (void *)own_dlsym;
@@ -1,92 +0,0 @@
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[2]
PATCH = ROOT / "tools/gamescope/patches/0147-touch-click-press-after-hover.patch"
def added_source(patch):
return "\n".join(line[1:] for line in patch.read_text().splitlines() if line.startswith("+") and not line.startswith("+++"))
def rules(text):
begin = text.index("static constexpr uint64_t k_ulTouchClickHoverNs")
end = text.index("static TouchClickTap s_TouchTap;")
return text[begin:end]
PREAMBLE = r'''
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#define None 0L
'''
MAIN = r'''
static const uint64_t MS = 1'000'000ul;
int main() {
TouchClickTap tap;
uint64_t delay = 0;
assert(touch_click_tap_down(tap, 272, 10, 100 * MS, 50.0, 60.0, true) == k_ulTouchClickHoverNs);
assert(tap.bPressPending);
assert(!touch_click_tap_motion(tap, 55.0, 64.0));
assert(touch_click_tap_motion(tap, 80.0, 60.0));
assert(touch_click_tap_fire(tap, 134 * MS, &delay) == TouchClickStep::Press);
assert(delay == 0);
assert(!touch_click_tap_motion(tap, 300.0, 300.0));
assert(!touch_click_tap_up(tap, 400, 500 * MS, &delay));
assert(touch_click_tap_down(tap, 272, 10, 100 * MS, 50.0, 60.0, true) > 0);
assert(touch_click_tap_up(tap, 15, 105 * MS, &delay));
assert(delay == 0);
assert(touch_click_tap_fire(tap, 134 * MS, &delay) == TouchClickStep::Press);
assert(delay == k_ulTouchClickHoldNs);
assert(touch_click_tap_time(tap, 134 * MS) == 44);
assert(touch_click_tap_fire(tap, 184 * MS, &delay) == TouchClickStep::Release);
assert(touch_click_tap_fire(tap, 200 * MS, &delay) == TouchClickStep::Idle);
assert(touch_click_tap_down(tap, 272, 10, 100 * MS, 50.0, 60.0, false) == 0);
assert(!tap.bPressPending);
assert(touch_click_tap_up(tap, 30, 120 * MS, &delay));
assert(delay == 30 * MS);
assert(touch_click_tap_fire(tap, 150 * MS, &delay) == TouchClickStep::Release);
assert(touch_click_tap_down(tap, 273, 10, 100 * MS, 0.0, 0.0, false) == 0);
assert(!touch_click_tap_up(tap, 90, 180 * MS, &delay));
assert(touch_click_tap_fire(tap, 190 * MS, &delay) == TouchClickStep::Idle);
return 0;
}
'''
class GamescopeTouchClickHoverTest(unittest.TestCase):
def test_press_waits_for_the_hover_and_a_tap_is_held(self):
compiler = shutil.which("c++") or shutil.which("g++") or shutil.which("clang++")
if not compiler:
self.skipTest("no C++ compiler")
source = PREAMBLE + rules(added_source(PATCH)) + MAIN
with tempfile.TemporaryDirectory() as tmp:
src = Path(tmp) / "touch_click_hover.cpp"
exe = Path(tmp) / "touch_click_hover"
src.write_text(source)
subprocess.run([compiler, "-std=c++17", "-Wall", "-Wextra", "-Werror", "-UNDEBUG", str(src), "-o", str(exe)], check=True)
subprocess.run([str(exe)], check=True)
def test_touch_down_defers_only_a_moved_press(self):
added = added_source(PATCH)
self.assertIn("bMoved = flFromX != wlserver.mouse_surface_cursorx || flFromY != wlserver.mouse_surface_cursory;", added)
self.assertIn("if ( !ulDelay || !touch_click_tap_arm( ulDelay ) )", added)
self.assertIn("touch_click_tap_settle( ulNow );", added)
self.assertEqual(1, added.count("touch_click_tap_motion( s_TouchTap, tx, ty )"))
self.assertIn("if ( bClickTouch && !touch_click_tap_up( s_TouchTap, time, get_time_in_nanos(), &ulDelay ) )", added)
if __name__ == "__main__":
unittest.main()
+64 -2
View File
@@ -260,6 +260,7 @@ static void *(*next)(void *);
static void *(*by_name)(void *, const char *);
static const char *(*name)(void *);
static const char *(*value)(void *);
static const char *(*sysattr)(void *, const char *);
static void *sym(const char *symbol) { return dlsym(lib, symbol); }
@@ -463,6 +464,20 @@ static void run_every(int count, char **entries) {
printf("pad %d real calls %d\n", pad != NULL, real_calls != NULL ? *real_calls : -1);
}
static void print_product(const char *label, void *device) {
const char *uevent = device != NULL ? sysattr(device, "uevent") : NULL;
printf("%s %.*s\n", label, uevent != NULL ? (int)strcspn(uevent, "\n") : 4, uevent != NULL ? uevent : "none");
}
static void run_identity(void) {
int udev;
void *device = new_device(&udev, PAD);
print_product("pad", device);
print_product("parent", device != NULL ? get_parent(device) : NULL);
}
static void run_probe(void) {
int udev;
@@ -539,7 +554,9 @@ int main(int argc, char **argv) {
by_name = sym("udev_list_entry_get_by_name");
name = sym("udev_list_entry_get_name");
value = sym("udev_list_entry_get_value");
sysattr = sym("udev_device_get_sysattr_value");
if (strcmp(argv[1], "probe") == 0) run_probe();
else if (strcmp(argv[1], "identity") == 0) run_identity();
else if (strcmp(argv[1], "every") == 0) run_every(argc - 3, argv + 3);
else if (strcmp(argv[1], "stable") == 0) run_stable();
else if (strcmp(argv[1], "enumerate") == 0) run_enumerate();
@@ -597,10 +614,13 @@ class InputUdevPreloadTest(unittest.TestCase):
(pads / node).write_text("")
return pads
def run_program(self, mode, *preloads, pads=None, slots="0=/pad", program=None, args=()):
def run_program(self, mode, *preloads, pads=None, slots="0=/pad", program=None, args=(), extra=None):
env = dict(os.environ, LD_PRELOAD=":".join(str(self.dir / name) for name in ("libddsession.so", *preloads)),
FAKE_EVDEV_MEMFD_PATHS=slots, FAKE_EVDEV_DIR=str(pads or self.pads))
env.pop("FAKE_EVDEV_UINPUT", None)
for key in ("FAKE_EVDEV_UINPUT", "FAKE_EVDEV_STEAM_VIRTUAL", "SDL_GAMECONTROLLER_IGNORE_DEVICES",
"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT"):
env.pop(key, None)
env.update(extra or {})
result = subprocess.run([str(program or self.program), mode, str(self.udev), *args], env=env, capture_output=True, text=True,
timeout=20)
self.assertEqual(result.returncode, 0, result.stderr)
@@ -684,6 +704,48 @@ class InputUdevPreloadTest(unittest.TestCase):
"nothing added scan -1",
])
def identity(self, pads=None, **extra):
return self.run_program("identity", pads=pads, extra=extra)
@classmethod
def id_list(cls, name, text):
path = cls.dir / name
path.write_text(text)
return "@" + str(path)
def test_a_pad_wine_also_reads_through_sdl_is_described_as_the_pad_sdl_sees(self):
xbox = ["pad PRODUCT=3/45e/28e/110", "parent PRODUCT=3/45e/28e/110"]
for extra in ({}, {"FAKE_EVDEV_UINPUT": "1"}, {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x045e/0x028e"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "0"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-other.txt", "0x28de/0x1142\n")},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "@" + str(self.dir / "missing.txt")},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": self.id_list("except-ring.txt", "0x045E/0x028E\n")},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x45e/0x28e"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": ""},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028f"}):
with self.subTest(**extra):
self.assertEqual(self.identity(**extra), xbox)
def test_a_pad_sdl_skips_keeps_the_steam_input_identity(self):
steam = ["pad PRODUCT=6/28de/11ff/110", "parent PRODUCT=6/28de/11ff/110"]
for extra in ({"FAKE_EVDEV_STEAM_VIRTUAL": "1"}, {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142,0x045E/0x028E"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x28de/0x11ff"},
{"FAKE_EVDEV_UINPUT": "1", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-ring.txt", "0x28de/0x1142\n0x045e/0x028e\n")},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": self.id_list("except-other.txt", "0x28de/0x11ff\n")},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-long.txt", "0x28de/0x1142\n" * 400 + "0x045e/0x028e\n")},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x45e/0x28e"},
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"}):
with self.subTest(**extra):
self.assertEqual(self.identity(**extra), steam)
def test_a_pad_under_steam_inputs_own_virtual_pad_stays_an_xbox_pad(self):
pads = self.pad_dir("under-virtual", "event0", "event16")
(pads / ".uinput-event16.uevent").write_text('PRODUCT=6/28de/11ff/1\nNAME="Microsoft X-Box 360 pad 0"\n')
self.assertEqual(self.identity(pads, FAKE_EVDEV_UINPUT="1", SDL_GAMECONTROLLER_IGNORE_DEVICES="0x045e/0x028e"),
["pad PRODUCT=3/45e/28e/110", "parent PRODUCT=3/45e/28e/110"])
def test_a_program_that_closes_and_reopens_libudev_keeps_working(self):
self.assertEqual(self.run_program("reload"), ["reload real0 real1"])
+69 -4
View File
@@ -40,6 +40,39 @@ void upload(unsigned short type, unsigned short length) {
}
"""
SDL = r"""
#include <linux/input.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
int SDL_JoystickRumble(void *joystick, uint16_t low, uint16_t high, uint32_t duration) {
struct ff_effect effect;
(void)joystick;
printf("sdl %u %u duration %u\n", low, high, duration);
memset(&effect, 0, sizeof(effect));
effect.id = -1;
effect.type = FF_RUMBLE;
effect.replay.length = 0xffff;
effect.u.rumble.strong_magnitude = low;
effect.u.rumble.weak_magnitude = high;
return ioctl(3, EVIOCSFF, &effect);
}
"""
SDL_CALLER = r"""
#include <dlfcn.h>
#include <stdint.h>
int rumble(const char *library, uint16_t low, uint16_t high, uint32_t duration) {
void *sdl = dlopen(library, RTLD_NOW | RTLD_LOCAL);
int (*call)(void *, uint16_t, uint16_t, uint32_t) = (int (*)(void *, uint16_t, uint16_t, uint32_t))dlsym(sdl, "SDL_JoystickRumble");
call(0, low, high, duration);
return 0;
}
"""
PROGRAM = r"""
#include <dlfcn.h>
#include <linux/input.h>
@@ -47,8 +80,21 @@ PROGRAM = r"""
void upload(unsigned short type, unsigned short length);
int rumble(const char *library, unsigned short low, unsigned short high, unsigned int duration);
int main(int argc, char **argv) {
void *winebus = dlopen(argv[1], RTLD_NOW);
if (argv[2][0] == 's') {
int (*from_winebus)(const char *, unsigned short, unsigned short, unsigned int) =
(int (*)(const char *, unsigned short, unsigned short, unsigned int))dlsym(winebus, "rumble");
for (const char *step = argv[3]; *step; step++) {
if (*step == 'w') from_winebus(argv[4], 65535, 32768, 1000);
if (*step == 'z') from_winebus(argv[4], 0, 0, 0);
if (*step == 'p') rumble(argv[4], 65535, 32768, 1000);
}
fflush(stdout);
return 0;
}
void (*from_winebus)(unsigned short, unsigned short) = (void (*)(unsigned short, unsigned short))dlsym(winebus, "upload");
if (argv[2][0] == 'w') from_winebus(argv[3][0] == 'r' ? FF_RUMBLE : FF_PERIODIC, 1000);
else upload(FF_RUMBLE, 1000);
@@ -65,7 +111,8 @@ class WinebusRumblePreloadTest(unittest.TestCase):
cls.dir = Path(tempfile.mkdtemp())
build = cls.dir / "build"
build.mkdir()
for name, text in (("shim.c", SHIM), ("upload.c", UPLOAD), ("program.c", PROGRAM)):
for name, text in (("shim.c", SHIM), ("upload.c", UPLOAD), ("program.c", PROGRAM), ("sdl.c", SDL),
("sdl_caller.c", SDL_CALLER)):
(build / name).write_text(text)
cls.lib = cls.dir / "libddsession.so"
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(cls.lib),
@@ -73,10 +120,13 @@ class WinebusRumblePreloadTest(unittest.TestCase):
cls.shim = cls.dir / "libshim.so"
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.shim), str(build / "shim.c")], check=True)
cls.winebus = cls.dir / "winebus.so"
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "upload.c")], check=True)
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "upload.c"),
str(build / "sdl_caller.c"), "-ldl"], check=True)
cls.sdl_library = cls.dir / "libSDL2-2.0.so.0"
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.sdl_library), str(build / "sdl.c")], check=True)
cls.program = cls.dir / "program"
subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "upload.c"), "-ldl"],
check=True)
subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "upload.c"),
str(build / "sdl_caller.c"), "-ldl"], check=True)
@classmethod
def tearDownClass(cls):
@@ -88,6 +138,21 @@ class WinebusRumblePreloadTest(unittest.TestCase):
capture_output=True, text=True, timeout=10, check=True)
return result.stdout.splitlines()
def sdl(self, steps):
env = dict(os.environ, LD_PRELOAD="%s:%s" % (self.lib, self.shim))
result = subprocess.run([str(self.program), str(self.winebus), "sdl", steps, str(self.sdl_library)], env=env,
capture_output=True, text=True, timeout=10, check=True)
return result.stdout.splitlines()
def test_rumble_winebus_starts_through_sdl_is_held_until_the_next_update(self):
self.assertEqual(self.sdl("wz"), ["sdl 65535 32768 duration 0", "shim type %d length 0" % 0x50,
"sdl 0 0 duration 0", "shim type %d length 0" % 0x50])
def test_sdl_rumble_from_other_code_keeps_its_duration_and_length(self):
self.assertEqual(self.sdl("p"), ["sdl 65535 32768 duration 1000", "shim type %d length 65535" % 0x50])
self.assertEqual(self.sdl("wp"), ["sdl 65535 32768 duration 0", "shim type %d length 0" % 0x50,
"sdl 65535 32768 duration 1000", "shim type %d length 65535" % 0x50])
def test_winebus_rumble_reaches_the_shim_held_and_comes_back_unchanged(self):
self.assertEqual(self.upload("winebus"), ["shim type %d length 0" % 0x50, "caller length 1000"])