mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
fix(dual-screen): DiRT 3 and DiRT Showdown telemetry no longer stops the game (error 10038)
DiRT 3 and DiRT Showdown keep sending motion telemetry on the UDP socket they closed at the end of a race (and when leaving Joyride); sendto() fails with WSAENOTSOCK and the game stops with "sendto failed with error 10038". - tools/dirt-ws2: a 32-bit ws2_32.dll stand-in. Every export jumps to the same-ordinal export of Wine's own ws2_32.dll; only a sendto() failing with 10038 reports 0 bytes sent. Built in CI (components recipe dirt-ws2, clang + lld) with its exports checked against Wine 11's list, staged to /usr/local/lib/droiddeck-dirt. - droiddeck-game-env: for dirt3_game.exe / showdown.exe / showdown_avx.exe with the game's UDP/motion output on, and a Proton whose own ws2_32.dll lacks the fix, the stand-in replaces the prefix's syswow64/ws2_32.dll (Wine loads ws2_32 as a KnownDLL from there, so a copy beside the game is ignored) with WINEDLLOVERRIDES=ws2_32=n,b; the launch waits for the game and puts the prefix's own file back. A copy left by a killed launch is put back at the next launch in that prefix. - Automatic turns DiRT 3 and DiRT Showdown on like the other games again; the crash warning and the switched-on-by-hand memory from the previous build are gone. Same behaviour as DiRTTelemetryErrorFix by RoccoC (MIT), based on the fix by Carsten Gottschling. DroidDeck-Proton gets the same rule in its own ws2_32 (branch fix/dirt-telemetry-sendto); the swap is skipped there.
This commit is contained in:
1 parent
66abf0c707
commit
268dcef559
19 files changed
+664
-53
No files matched your search
@@ -170,6 +170,7 @@ object SessionFiles {
|
||||
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
|
||||
"usr/local/lib/droiddeck-pipewire.tzst" to "usr/local/lib/droiddeck-pipewire.tzst",
|
||||
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
|
||||
"usr/local/lib/droiddeck-dirt/ws2_32.dll" to "usr/local/lib/droiddeck-dirt/ws2_32.dll",
|
||||
) + mangoapp + msitools.map { it to it } + vr + fexPreloads).filter { (asset, _) ->
|
||||
val dir = asset.substringBeforeLast('/')
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
|
||||
@@ -132,13 +132,6 @@ object SessionPrefs {
|
||||
prefs(context).edit().putStringSet("telemetryOff", keys.toSet()).apply()
|
||||
}
|
||||
|
||||
/** Games the user switched on by hand, as TelemetryOutput keys; Automatic keeps them on. */
|
||||
fun telemetryOnByHand(context: Context): Set<String> = prefs(context).getStringSet("telemetryOnByHand", null)?.toSet().orEmpty()
|
||||
|
||||
fun setTelemetryOnByHand(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putStringSet("telemetryOnByHand", keys.toSet()).apply()
|
||||
}
|
||||
|
||||
fun dualScreenLauncher(context: Context): Boolean = prefs(context).getBoolean("dualScreenLauncher", true)
|
||||
|
||||
fun setDualScreenLauncher(context: Context, on: Boolean) {
|
||||
|
||||
@@ -26,7 +26,7 @@ object SettingsReset {
|
||||
"upscaler", "upscaleSharpness", "screenEffects", "textureAnisotropy", "textureLodBias",
|
||||
"steamDownloadsInBackground", "steam_offline", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds",
|
||||
"bootMovieApplyNext", "bootMovieSteamSeen",
|
||||
"questDefaultsV1", "telemetryAuto", "telemetryOff", "telemetryOnByHand", "statsStrip", "statsDash",
|
||||
"questDefaultsV1", "telemetryAuto", "telemetryOff", "statsStrip", "statsDash",
|
||||
)
|
||||
|
||||
internal val SESSION_PREFIXES = listOf(
|
||||
|
||||
@@ -10,10 +10,7 @@ import java.io.File
|
||||
* In-game stats listener; the file as it was is kept beside it, and its element is put back when turned off.
|
||||
*/
|
||||
object TelemetryOutput {
|
||||
data class Game(val name: String, val prefixId: String, val file: File, val on: Boolean) {
|
||||
/** DiRT 3 and DiRT Showdown can stop at the end of a race with WinSock error 10038 while this output is on. */
|
||||
val raceEndCrash: Boolean get() = name.lowercase().replace(" ", "") in RACE_END_CRASH
|
||||
}
|
||||
data class Game(val name: String, val prefixId: String, val file: File, val on: Boolean)
|
||||
|
||||
data class MenuGame(val name: String, val setting: String, val port: Int)
|
||||
|
||||
@@ -31,7 +28,6 @@ object TelemetryOutput {
|
||||
private const val ADDRESS = "127.0.0.1"
|
||||
private const val EXTRADATA = "3"
|
||||
private val TAGS = listOf("udp", "motion")
|
||||
private val RACE_END_CRASH = setOf("dirtshowdown", "dirt3")
|
||||
// Byte-for-byte: every byte maps to one char and back, whatever the file's own encoding is.
|
||||
private val BYTES = Charsets.ISO_8859_1
|
||||
|
||||
@@ -66,24 +62,16 @@ object TelemetryOutput {
|
||||
true
|
||||
}.getOrDefault(false)
|
||||
|
||||
/**
|
||||
* Automatic: turns the output on for every found game the user has not switched off and that is not running.
|
||||
* Games with the race-end crash are left to the user, and ones Automatic switched on go back to their own setting.
|
||||
*/
|
||||
/** Automatic: turns the output on for every found game the user has not switched off and that is not running. */
|
||||
fun applyAutomatic(context: Context, running: String?) {
|
||||
if (!SessionPrefs.telemetryAuto(context)) return
|
||||
val games = scan(Library.compatdataDirs(context))
|
||||
automaticTargets(games, SessionPrefs.telemetryOff(context), running).forEach { set(it, true) }
|
||||
automaticRestores(games, SessionPrefs.telemetryOnByHand(context), running).forEach { set(it, false) }
|
||||
automaticTargets(scan(Library.compatdataDirs(context)), SessionPrefs.telemetryOff(context), running).forEach { set(it, true) }
|
||||
}
|
||||
|
||||
internal fun key(game: Game) = "${game.prefixId}/${game.name}"
|
||||
|
||||
internal fun automaticTargets(games: List<Game>, off: Set<String>, running: String?): List<Game> =
|
||||
games.filter { !it.on && !it.raceEndCrash && key(it) !in off && !isRunning(it.prefixId, running) }
|
||||
|
||||
internal fun automaticRestores(games: List<Game>, onByHand: Set<String>, running: String?): List<Game> =
|
||||
games.filter { it.raceEndCrash && it.on && key(it) !in onByHand && File(it.file.path + ORIGINAL_SUFFIX).isFile && !isRunning(it.prefixId, running) }
|
||||
games.filter { !it.on && key(it) !in off && !isRunning(it.prefixId, running) }
|
||||
|
||||
/** Games DroidDeck changed, which go back to their own setting when Automatic is switched off. */
|
||||
internal fun restoreTargets(games: List<Game>, running: String?): List<Game> =
|
||||
|
||||
@@ -271,18 +271,13 @@ fun BottomTelemetryPage(fps: () -> Float?, runningGame: () -> String? = { null }
|
||||
}
|
||||
for (game in outputs) {
|
||||
val locked = TelemetryOutput.isRunning(game.prefixId, running)
|
||||
val hint = listOfNotNull(
|
||||
if (locked) stringResource(R.string.bottom_telemetry_send_close, game.name) else null,
|
||||
if (game.raceEndCrash) stringResource(R.string.bottom_telemetry_send_crash) else null,
|
||||
).joinToString("\n").ifEmpty { null }
|
||||
val hint = if (locked) stringResource(R.string.bottom_telemetry_send_close, game.name) else null
|
||||
SwitchRow(game.name, hint, game.on, !locked) { want ->
|
||||
scope.launch {
|
||||
val ok = withContext(Dispatchers.IO) {
|
||||
val key = TelemetryOutput.key(game)
|
||||
val off = SessionPrefs.telemetryOff(context)
|
||||
val byHand = SessionPrefs.telemetryOnByHand(context)
|
||||
SessionPrefs.setTelemetryOff(context, if (want) off - key else off + key)
|
||||
SessionPrefs.setTelemetryOnByHand(context, if (want) byHand + key else byHand - key)
|
||||
TelemetryOutput.set(game, want)
|
||||
}
|
||||
outputFailed = if (ok) null else game.name
|
||||
|
||||
@@ -1916,7 +1916,6 @@
|
||||
<string name="stats_fuel_main">Main %1$s t</string>
|
||||
<string name="stats_fuel_reserve">Reserve %1$s t</string>
|
||||
<string name="stats_tap_hint">Tap the top strip or the dash to change its style.</string>
|
||||
<string name="bottom_telemetry_send_crash">This game can stop at the end of a race while this is on, so Automatic leaves it off.</string>
|
||||
<string name="bottom_telemetry_send_title">Send dashboard data</string>
|
||||
<string name="bottom_telemetry_send_auto">Automatic</string>
|
||||
<string name="bottom_telemetry_send_auto_hint">Turns it on for every game listed here, including games found later. Games you switch off stay off.</string>
|
||||
|
||||
@@ -101,28 +101,13 @@ class TelemetryOutputTest {
|
||||
assertTrue(TelemetryOutput.restoreTargets(TelemetryOutput.scan(listOf(compatdata)), "2848447563").isEmpty())
|
||||
}
|
||||
|
||||
@Test fun automaticLeavesTheRaceEndCrashGamesToTheUser() {
|
||||
@Test fun automaticTurnsOnDirt3AndShowdownLikeTheOtherGames() {
|
||||
val f = File("x")
|
||||
val showdownGame = TelemetryOutput.Game("DiRT Showdown", "2848447563", f, on = false)
|
||||
val dirt3 = TelemetryOutput.Game("DiRT3", "321040", f, on = false)
|
||||
val rally = TelemetryOutput.Game("DiRT Rally 2.0", "690790", f, on = false)
|
||||
assertTrue(showdownGame.raceEndCrash)
|
||||
assertTrue(dirt3.raceEndCrash)
|
||||
assertFalse(rally.raceEndCrash)
|
||||
assertEquals(listOf(rally), TelemetryOutput.automaticTargets(listOf(showdownGame, dirt3, rally), emptySet(), null))
|
||||
}
|
||||
|
||||
@Test fun automaticPutsBackAShowdownItSwitchedOnButNotOneTheUserDid() {
|
||||
val compatdata = tmp.newFolder("steamapps", "compatdata")
|
||||
val config = configFile(compatdata, "2848447563", "DiRT Showdown").apply { writeText(showdown) }
|
||||
val game = TelemetryOutput.scan(listOf(compatdata)).single()
|
||||
assertTrue(TelemetryOutput.set(game, true))
|
||||
val on = TelemetryOutput.scan(listOf(compatdata))
|
||||
assertEquals(on, TelemetryOutput.automaticRestores(on, emptySet(), null))
|
||||
assertTrue(TelemetryOutput.automaticRestores(on, setOf("2848447563/DiRT Showdown"), null).isEmpty())
|
||||
assertTrue(TelemetryOutput.automaticRestores(on, emptySet(), "2848447563").isEmpty())
|
||||
on.forEach { TelemetryOutput.set(it, false) }
|
||||
assertEquals(showdown, config.readText())
|
||||
assertEquals(listOf(showdownGame, dirt3, rally), TelemetryOutput.automaticTargets(listOf(showdownGame, dirt3, rally), emptySet(), null))
|
||||
assertEquals(listOf(rally), TelemetryOutput.automaticTargets(listOf(showdownGame, dirt3, rally), setOf("2848447563/DiRT Showdown", "321040/DiRT3"), null))
|
||||
}
|
||||
|
||||
private fun configFile(compatdata: File, id: String, game: String): File =
|
||||
|
||||
Reference in new issue
Block a user