mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f01c0f8e2 |
No files matched your search
@@ -23,11 +23,6 @@ jobs:
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq --no-install-recommends libwayland-bin libwayland-dev libx11-dev libx11-xcb-dev \
|
||||
libxcb1-dev libxcb-composite0-dev libglm-dev zstd
|
||||
- name: llvm-mingw for dd-directcontroller
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/llvm-mingw-bylaws-20250920
|
||||
key: llvm-mingw-bylaws-20250920-x86_64
|
||||
- name: Build
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -185,7 +185,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var unfoldedControls by mutableStateOf(false)
|
||||
private var unfoldedControlsWithController by mutableStateOf(false)
|
||||
private var adaptiveSticks by mutableStateOf<Boolean?>(null)
|
||||
private var directController by mutableStateOf<Boolean?>(null)
|
||||
private var quickButtons by mutableStateOf<Map<InputCommand, Boolean>>(emptyMap())
|
||||
private var picturePosition by mutableStateOf("center")
|
||||
|
||||
@@ -587,7 +586,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
drawerLayerOpen = false
|
||||
drawerPinned = false
|
||||
if (value) {
|
||||
directController = com.droiddeck.launcher.session.DirectControllerSwitch.state(this)
|
||||
releaseHeldKeys()
|
||||
drawerXr = com.droiddeck.launcher.session.xr.XrPanels.showMenu()
|
||||
drawerDocked = !drawerXr && dockDrawer() && openDockedMenu()
|
||||
@@ -2142,11 +2140,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
primaryInputLayout?.let { com.droiddeck.launcher.input.InputLibraries.setAdaptiveSticks(this@SessionActivity, it.id, on) }
|
||||
refreshInputProfile()
|
||||
},
|
||||
directController = directController,
|
||||
onDirectController = { on ->
|
||||
com.droiddeck.launcher.session.DirectControllerSwitch.set(this@SessionActivity, on)
|
||||
directController = on
|
||||
},
|
||||
showFloatingSteamControls = SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad && unfoldedPanel == null &&
|
||||
oscMode != SessionPrefs.OSC_NEVER && oscMode != SessionPrefs.OSC_STEAM_QAM &&
|
||||
!steamTouchInUse && OnScreenLayout.supportsFloatingSteamControls(padType, primaryInputLayout),
|
||||
|
||||
@@ -50,17 +50,6 @@ object GameEnvironment {
|
||||
return withScopeValue(config, scope, NO_STEAM, if (on) "1" else null)
|
||||
}
|
||||
|
||||
/** dd-directcontroller on DroidDeck-Bionic: "0" starts the game in pass-through (Wine's own xinput); unset = the pad state. */
|
||||
const val DIRECT_CONTROLLER = "DD_DIRECTCONTROLLER"
|
||||
|
||||
fun gameDirectController(config: Config, scope: String): Boolean =
|
||||
scope.isEmpty() || config.games[scope]?.get(DIRECT_CONTROLLER) != "0"
|
||||
|
||||
fun withGameDirectController(config: Config, scope: String, on: Boolean): Config {
|
||||
require(scope.isNotEmpty() && validScope(scope))
|
||||
return withScopeValue(config, scope, DIRECT_CONTROLLER, if (on) null else "0")
|
||||
}
|
||||
|
||||
const val GAME_RESOLUTION = "DROIDDECK_GAME_RESOLUTION"
|
||||
|
||||
fun gameResolution(config: Config, scope: String): GameResolution.Choice? =
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* dd-directcontroller's mode file. DroidDeck-Bionic's launch.sh writes it beside the controller folder when a game set to start
|
||||
* without Steam reads XInput through dd-directcontroller; the game's DLLs read it while it runs ('1' the pad state, '0' Wine's own
|
||||
* xinput). No file = the session's game does not use dd-directcontroller.
|
||||
*/
|
||||
object DirectControllerSwitch {
|
||||
const val FILE = "dd-directcontroller.mode"
|
||||
|
||||
fun file(context: Context): File = File(LinuxRuntime.sessionRoot(context), "dev/$FILE")
|
||||
|
||||
/** The running game's mode, or null when it does not use dd-directcontroller. */
|
||||
fun state(context: Context): Boolean? = runCatching {
|
||||
when (file(context).takeIf { it.isFile }?.readText()?.trim()) {
|
||||
"1" -> true
|
||||
"0" -> false
|
||||
else -> null
|
||||
}
|
||||
}.getOrNull()
|
||||
|
||||
/** One request after another, in call order: the last switch sets both the live mode and the saved choice. */
|
||||
private val queue = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "dd-directcontroller") }
|
||||
|
||||
/** Switches the running game now and remembers the choice for its next start. */
|
||||
fun set(context: Context, on: Boolean) {
|
||||
val app = context.applicationContext
|
||||
queue.execute {
|
||||
runCatching { file(app).takeIf { it.isFile }?.writeText(if (on) "1\n" else "0\n") }
|
||||
val scope = NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { NoSteamLaunch.battleNetTitleScope(app, it) }
|
||||
if (!scope.isNullOrEmpty() && GameEnvironment.validScope(scope)) runCatching {
|
||||
GameEnvironmentStore.setGameDirectController(app, scope, on)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A session starts without the file: only a launch that uses dd-directcontroller writes it again. */
|
||||
fun clear(context: Context) {
|
||||
file(context).delete()
|
||||
}
|
||||
}
|
||||
@@ -91,13 +91,6 @@ object GameEnvironmentStore {
|
||||
return config
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun setGameDirectController(context: Context, scope: String, on: Boolean): GameEnvironment.Config {
|
||||
val config = GameEnvironment.withGameDirectController(read(context), scope, on)
|
||||
save(context, config)
|
||||
return config
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun setGameResolution(context: Context, scope: String, choice: com.droiddeck.launcher.core.GameResolution.Choice?): GameEnvironment.Config {
|
||||
val config = GameEnvironment.withGameResolution(read(context), scope, choice)
|
||||
|
||||
@@ -1249,7 +1249,6 @@ class SessionService : Service() {
|
||||
}
|
||||
|
||||
private fun addControllerEnvironment(guest: MutableList<String>, fakeInputDir: File, sessionDir: File) {
|
||||
DirectControllerSwitch.clear(this)
|
||||
FakeInputWriter.prepareRingSlots(fakeInputDir, 5)
|
||||
val builtinPad = SessionPrefs.builtinPad(this)
|
||||
val hiddenPad = SessionState.mode == MODE_STEAM && !builtinPad &&
|
||||
|
||||
@@ -189,7 +189,7 @@ object StoreLaunchRequests {
|
||||
///
|
||||
/// The message is the only thing that separates a stale sign-in from a title
|
||||
/// that is not installed, so it is kept, minus anything that could carry a
|
||||
/// device path or a token: segments looking like a path are dropped and the
|
||||
/// device path or a token: segments lookng like a path are dropped and the
|
||||
/// rest is folded to plain text.
|
||||
internal fun reasonFor(error: Throwable): String {
|
||||
val text = error.message.orEmpty()
|
||||
|
||||
@@ -414,9 +414,6 @@ class DrawerActions(
|
||||
val unfoldedControls: Boolean? = null,
|
||||
val adaptiveSticks: Boolean? = null,
|
||||
val onAdaptiveSticks: (Boolean) -> Unit = {},
|
||||
/** dd-directcontroller's mode for the running game; null = the game does not use it. */
|
||||
val directController: Boolean? = null,
|
||||
val onDirectController: (Boolean) -> Unit = {},
|
||||
val showFloatingSteamControls: Boolean = false,
|
||||
val oscRearButtons: Boolean = false,
|
||||
val oscTrackpads: Boolean = false,
|
||||
@@ -795,12 +792,10 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
|
||||
val rumbleLabel = stringResource(R.string.ctrl_rumble)
|
||||
val airTriggers = a.airTriggers
|
||||
val airTriggersLabel = stringResource(R.string.air_triggers_title)
|
||||
val directControllerLabel = stringResource(R.string.ctrl_direct_controller)
|
||||
if (a.padType != null || c != null || airTriggers != null || a.directController != null) SettingsGroup(
|
||||
if (a.padType != null || c != null || airTriggers != null) SettingsGroup(
|
||||
stringResource(R.string.input_device_settings), key = "controller-pad", tag = padTag,
|
||||
detail = summary(a.padType?.let { padTypes.labelOf(it) }, c?.let { "$rumbleLabel ${if (it.rumble) on else off}" },
|
||||
airTriggers?.let { "$airTriggersLabel ${if (it.enabled) on else off}" },
|
||||
a.directController?.let { "$directControllerLabel ${if (it) on else off}" }),
|
||||
airTriggers?.let { "$airTriggersLabel ${if (it.enabled) on else off}" }),
|
||||
) {
|
||||
a.padType?.let { type ->
|
||||
ChoiceRow(host, "pad-type", stringResource(R.string.input_virtual_controller), stringResource(R.string.input_virtual_controller_hint),
|
||||
@@ -809,9 +804,6 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
|
||||
c?.let {
|
||||
ToggleRow(host, "rumble", rumbleLabel, null, it.rumble, chipModifier = track("rumble"), onChange = a.onRumble)
|
||||
}
|
||||
a.directController?.let {
|
||||
ToggleRow(host, "direct-controller", directControllerLabel, null, it, chipModifier = track("direct-controller"), onChange = a.onDirectController)
|
||||
}
|
||||
airTriggers?.let {
|
||||
ActionRow(airTriggersLabel, if (it.enabled) on else off, stringResource(R.string.air_triggers_open), onAirTriggers,
|
||||
modifier = track("air-triggers"))
|
||||
|
||||
@@ -1336,7 +1336,6 @@
|
||||
<string name="ctrl_size">حجم الأزرار</string>
|
||||
<string name="ctrl_adaptive">عصي تكيّفية</string>
|
||||
<string name="ctrl_rumble">اهتزاز اللعبة</string>
|
||||
<string name="ctrl_direct_controller">وحدة تحكم مباشرة</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">فتح</string>
|
||||
<string name="air_triggers_use">استخدام Air Triggers</string>
|
||||
|
||||
@@ -1342,7 +1342,6 @@
|
||||
<string name="ctrl_size">Tamaño de botones</string>
|
||||
<string name="ctrl_adaptive">Sticks adaptables</string>
|
||||
<string name="ctrl_rumble">Vibración en juegos</string>
|
||||
<string name="ctrl_direct_controller">Control directo</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Abrir</string>
|
||||
<string name="air_triggers_use">Usar los Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Размер на бутоните</string>
|
||||
<string name="ctrl_adaptive">Адаптивни стикове</string>
|
||||
<string name="ctrl_rumble">Вибрация от играта</string>
|
||||
<string name="ctrl_direct_controller">Директен контролер</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Отвори</string>
|
||||
<string name="air_triggers_use">Използвай Air Triggers</string>
|
||||
|
||||
@@ -1322,7 +1322,6 @@
|
||||
<string name="ctrl_size">Velikost tlačítek</string>
|
||||
<string name="ctrl_adaptive">Adaptivní páčky</string>
|
||||
<string name="ctrl_rumble">Vibrace ve hře</string>
|
||||
<string name="ctrl_direct_controller">Přímý ovladač</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Otevřít</string>
|
||||
<string name="air_triggers_use">Používat Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Knapstørrelse</string>
|
||||
<string name="ctrl_adaptive">Adaptive styrepinde</string>
|
||||
<string name="ctrl_rumble">Spilvibration</string>
|
||||
<string name="ctrl_direct_controller">Direkte controller</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Åbn</string>
|
||||
<string name="air_triggers_use">Brug Air Triggers</string>
|
||||
|
||||
@@ -1300,7 +1300,6 @@
|
||||
<string name="ctrl_size">Tastengröße</string>
|
||||
<string name="ctrl_adaptive">Adaptive Sticks</string>
|
||||
<string name="ctrl_rumble">Spielvibration</string>
|
||||
<string name="ctrl_direct_controller">Direkter Controller</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Öffnen</string>
|
||||
<string name="air_triggers_use">Air Triggers verwenden</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Μέγεθος κουμπιών</string>
|
||||
<string name="ctrl_adaptive">Προσαρμοστικοί μοχλοί</string>
|
||||
<string name="ctrl_rumble">Κραδασμός παιχνιδιού</string>
|
||||
<string name="ctrl_direct_controller">Άμεσο χειριστήριο</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Άνοιγμα</string>
|
||||
<string name="air_triggers_use">Χρήση Air Triggers</string>
|
||||
|
||||
@@ -1315,7 +1315,6 @@
|
||||
<string name="ctrl_size">Tamaño de botones</string>
|
||||
<string name="ctrl_adaptive">Sticks adaptables</string>
|
||||
<string name="ctrl_rumble">Vibración en juegos</string>
|
||||
<string name="ctrl_direct_controller">Mando directo</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Abrir</string>
|
||||
<string name="air_triggers_use">Usar los Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Painikkeiden koko</string>
|
||||
<string name="ctrl_adaptive">Mukautuvat sauvat</string>
|
||||
<string name="ctrl_rumble">Pelin tärinä</string>
|
||||
<string name="ctrl_direct_controller">Suora ohjain</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Avaa</string>
|
||||
<string name="air_triggers_use">Käytä Air Triggereitä</string>
|
||||
|
||||
@@ -1314,7 +1314,6 @@
|
||||
<string name="ctrl_size">Taille des boutons</string>
|
||||
<string name="ctrl_adaptive">Joystick adaptatif</string>
|
||||
<string name="ctrl_rumble">Vibration du jeu</string>
|
||||
<string name="ctrl_direct_controller">Manette directe</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Ouvrir</string>
|
||||
<string name="air_triggers_use">Utiliser les Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">बटन का आकार</string>
|
||||
<string name="ctrl_adaptive">एडैप्टिव स्टिक</string>
|
||||
<string name="ctrl_rumble">गेम वाइब्रेशन</string>
|
||||
<string name="ctrl_direct_controller">डायरेक्ट कंट्रोलर</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">खोलें</string>
|
||||
<string name="air_triggers_use">Air Triggers इस्तेमाल करें</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Gombméret</string>
|
||||
<string name="ctrl_adaptive">Adaptív karok</string>
|
||||
<string name="ctrl_rumble">Játékvibráció</string>
|
||||
<string name="ctrl_direct_controller">Közvetlen kontroller</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Megnyitás</string>
|
||||
<string name="air_triggers_use">Air Triggers használata</string>
|
||||
|
||||
@@ -1302,7 +1302,6 @@
|
||||
<string name="ctrl_size">Ukuran tombol</string>
|
||||
<string name="ctrl_adaptive">Stik adaptif</string>
|
||||
<string name="ctrl_rumble">Getaran gim</string>
|
||||
<string name="ctrl_direct_controller">Pengontrol langsung</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Buka</string>
|
||||
<string name="air_triggers_use">Gunakan Air Triggers</string>
|
||||
|
||||
@@ -1306,7 +1306,6 @@
|
||||
<string name="ctrl_size">Dimensione dei tasti</string>
|
||||
<string name="ctrl_adaptive">Levette adattive</string>
|
||||
<string name="ctrl_rumble">Vibrazione di gioco</string>
|
||||
<string name="ctrl_direct_controller">Controller diretto</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Apri</string>
|
||||
<string name="air_triggers_use">Usa gli Air Triggers</string>
|
||||
|
||||
@@ -1302,7 +1302,6 @@
|
||||
<string name="ctrl_size">ボタンのサイズ</string>
|
||||
<string name="ctrl_adaptive">アダプティブスティック</string>
|
||||
<string name="ctrl_rumble">ゲームの振動</string>
|
||||
<string name="ctrl_direct_controller">ダイレクトコントローラー</string>
|
||||
<string name="air_triggers_title">Redmagic エアトリガー</string>
|
||||
<string name="air_triggers_open">開く</string>
|
||||
<string name="air_triggers_use">エアトリガーを使う</string>
|
||||
|
||||
@@ -1302,7 +1302,6 @@
|
||||
<string name="ctrl_size">버튼 크기</string>
|
||||
<string name="ctrl_adaptive">적응형 스틱</string>
|
||||
<string name="ctrl_rumble">게임 진동</string>
|
||||
<string name="ctrl_direct_controller">다이렉트 컨트롤러</string>
|
||||
<string name="air_triggers_title">Redmagic 에어 트리거</string>
|
||||
<string name="air_triggers_open">열기</string>
|
||||
<string name="air_triggers_use">에어 트리거 사용</string>
|
||||
|
||||
@@ -1302,7 +1302,6 @@
|
||||
<string name="ctrl_size">Saiz butang</string>
|
||||
<string name="ctrl_adaptive">Stik adaptif</string>
|
||||
<string name="ctrl_rumble">Getaran permainan</string>
|
||||
<string name="ctrl_direct_controller">Pengawal terus</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Buka</string>
|
||||
<string name="air_triggers_use">Guna Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Knappestørrelse</string>
|
||||
<string name="ctrl_adaptive">Adaptive stikker</string>
|
||||
<string name="ctrl_rumble">Spillvibrasjon</string>
|
||||
<string name="ctrl_direct_controller">Direkte kontroller</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Åpne</string>
|
||||
<string name="air_triggers_use">Bruk Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Knopgrootte</string>
|
||||
<string name="ctrl_adaptive">Adaptieve sticks</string>
|
||||
<string name="ctrl_rumble">Trillen in games</string>
|
||||
<string name="ctrl_direct_controller">Directe controller</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Openen</string>
|
||||
<string name="air_triggers_use">Air Triggers gebruiken</string>
|
||||
|
||||
@@ -1322,7 +1322,6 @@
|
||||
<string name="ctrl_size">Rozmiar przycisków</string>
|
||||
<string name="ctrl_adaptive">Adaptacyjne gałki</string>
|
||||
<string name="ctrl_rumble">Wibracje gry</string>
|
||||
<string name="ctrl_direct_controller">Bezpośredni kontroler</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Otwórz</string>
|
||||
<string name="air_triggers_use">Używaj Air Triggers</string>
|
||||
|
||||
@@ -1306,7 +1306,6 @@
|
||||
<string name="ctrl_size">Tamanho dos botões</string>
|
||||
<string name="ctrl_adaptive">Analógicos adaptáveis</string>
|
||||
<string name="ctrl_rumble">Vibração do jogo</string>
|
||||
<string name="ctrl_direct_controller">Comando direto</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Abrir</string>
|
||||
<string name="air_triggers_use">Utilizar os Air Triggers</string>
|
||||
|
||||
@@ -1314,7 +1314,6 @@
|
||||
<string name="ctrl_size">Tamanho dos botões</string>
|
||||
<string name="ctrl_adaptive">Analógicos adaptáveis</string>
|
||||
<string name="ctrl_rumble">Vibração do jogo</string>
|
||||
<string name="ctrl_direct_controller">Controle direto</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Abrir</string>
|
||||
<string name="air_triggers_use">Usar os Air Triggers</string>
|
||||
|
||||
@@ -1315,7 +1315,6 @@
|
||||
<string name="ctrl_size">Dimensiunea butoanelor</string>
|
||||
<string name="ctrl_adaptive">Manșe adaptive</string>
|
||||
<string name="ctrl_rumble">Vibrații de joc</string>
|
||||
<string name="ctrl_direct_controller">Controller direct</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Deschide</string>
|
||||
<string name="air_triggers_use">Folosește Air Triggers</string>
|
||||
|
||||
@@ -1322,7 +1322,6 @@
|
||||
<string name="ctrl_size">Размер кнопок</string>
|
||||
<string name="ctrl_adaptive">Адаптивные стики</string>
|
||||
<string name="ctrl_rumble">Вибрация в играх</string>
|
||||
<string name="ctrl_direct_controller">Прямой контроллер</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Открыть</string>
|
||||
<string name="air_triggers_use">Использовать Air Triggers</string>
|
||||
|
||||
@@ -1308,7 +1308,6 @@
|
||||
<string name="ctrl_size">Knappstorlek</string>
|
||||
<string name="ctrl_adaptive">Adaptiva spakar</string>
|
||||
<string name="ctrl_rumble">Spelvibration</string>
|
||||
<string name="ctrl_direct_controller">Direkt handkontroll</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Öppna</string>
|
||||
<string name="air_triggers_use">Använd Air Triggers</string>
|
||||
|
||||
@@ -1302,7 +1302,6 @@
|
||||
<string name="ctrl_size">ขนาดปุ่ม</string>
|
||||
<string name="ctrl_adaptive">สติ๊กแบบปรับอัตโนมัติ</string>
|
||||
<string name="ctrl_rumble">การสั่นของเกม</string>
|
||||
<string name="ctrl_direct_controller">คอนโทรลเลอร์โดยตรง</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">เปิด</string>
|
||||
<string name="air_triggers_use">ใช้ Air Triggers</string>
|
||||
|
||||
@@ -1300,7 +1300,6 @@
|
||||
<string name="ctrl_size">Düğme boyutu</string>
|
||||
<string name="ctrl_adaptive">Uyarlanabilir çubuklar</string>
|
||||
<string name="ctrl_rumble">Oyun titreşimi</string>
|
||||
<string name="ctrl_direct_controller">Doğrudan kumanda</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Aç</string>
|
||||
<string name="air_triggers_use">Air Triggers kullan</string>
|
||||
|
||||
@@ -1322,7 +1322,6 @@
|
||||
<string name="ctrl_size">Розмір кнопок</string>
|
||||
<string name="ctrl_adaptive">Адаптивні стики</string>
|
||||
<string name="ctrl_rumble">Вібрація гри</string>
|
||||
<string name="ctrl_direct_controller">Прямий контролер</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Відкрити</string>
|
||||
<string name="air_triggers_use">Використовувати Air Triggers</string>
|
||||
|
||||
@@ -1302,7 +1302,6 @@
|
||||
<string name="ctrl_size">Kích thước nút</string>
|
||||
<string name="ctrl_adaptive">Cần thích ứng</string>
|
||||
<string name="ctrl_rumble">Rung khi chơi game</string>
|
||||
<string name="ctrl_direct_controller">Tay cầm trực tiếp</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Mở</string>
|
||||
<string name="air_triggers_use">Dùng Air Triggers</string>
|
||||
|
||||
@@ -1385,7 +1385,6 @@
|
||||
<string name="ctrl_size">按钮大小</string>
|
||||
<string name="ctrl_adaptive">自适应摇杆</string>
|
||||
<string name="ctrl_rumble">游戏震动</string>
|
||||
<string name="ctrl_direct_controller">直连手柄</string>
|
||||
<string name="air_triggers_title">红魔肩键</string>
|
||||
<string name="air_triggers_open">打开</string>
|
||||
<string name="air_triggers_use">使用肩键</string>
|
||||
|
||||
@@ -1301,7 +1301,6 @@
|
||||
<string name="ctrl_size">按鍵大小</string>
|
||||
<string name="ctrl_adaptive">自動調整搖桿</string>
|
||||
<string name="ctrl_rumble">遊戲震動</string>
|
||||
<string name="ctrl_direct_controller">直連控制器</string>
|
||||
<string name="air_triggers_title">紅魔肩鍵</string>
|
||||
<string name="air_triggers_open">開啟</string>
|
||||
<string name="air_triggers_use">使用肩鍵</string>
|
||||
|
||||
@@ -1301,7 +1301,6 @@
|
||||
<string name="ctrl_size">按鍵大小</string>
|
||||
<string name="ctrl_adaptive">自適應搖桿</string>
|
||||
<string name="ctrl_rumble">遊戲震動</string>
|
||||
<string name="ctrl_direct_controller">直連控制器</string>
|
||||
<string name="air_triggers_title">紅魔肩鍵</string>
|
||||
<string name="air_triggers_open">開啟</string>
|
||||
<string name="air_triggers_use">使用肩鍵</string>
|
||||
|
||||
@@ -1505,7 +1505,6 @@
|
||||
<string name="ctrl_size">Button size</string>
|
||||
<string name="ctrl_adaptive">Adaptive sticks</string>
|
||||
<string name="ctrl_rumble">Game vibration</string>
|
||||
<string name="ctrl_direct_controller">Direct controller</string>
|
||||
<string name="air_triggers_title">Redmagic Air Triggers</string>
|
||||
<string name="air_triggers_open">Open</string>
|
||||
<string name="air_triggers_use">Use Air Triggers</string>
|
||||
|
||||
@@ -204,7 +204,7 @@ FEX preset or value chosen for the game itself still applies.
|
||||
An Inno Setup installer added as a game runs with the Stability preset's FEX
|
||||
settings (full TSO, full x87 precision, no multiblock). Under the default
|
||||
Performance + TSO preset the 32-bit setup stub corrupts its own paths and stops
|
||||
with Wine's "Path not found." dialog (#1277, #3067). The stub is found by the
|
||||
with Wine's "Path not fpund." dialog (#1277, #3067). The stub is found by the
|
||||
setup loader's offset-table ID in its resources, or by the `Inno` marker that
|
||||
loaders older than 5.1.5 keep at offset 0x30. GOG installs avoid the stub by
|
||||
extracting natively. A FEX preset chosen for the installer's own entry still
|
||||
|
||||
@@ -240,11 +240,6 @@ cp "$WORK/FEX/system32/"*.dll "$T/files/runtime/fex/aarch64-windows/"
|
||||
install -m 755 "$HERE/tool/proton" "$T/proton"
|
||||
install -m 755 "$HERE/tool/launch.sh" "$T/bionic/launch.sh"
|
||||
cp "$HERE/tool/desktop.reg" "$HERE/tool/Xdefaults" "$T/bionic/"
|
||||
# dd-directcontroller: the XInput DLLs launch.sh puts in the prefix of a game set to start without Steam, and the
|
||||
# host test of their ring reader
|
||||
"$HERE/dd-directcontroller/build.sh" host "$WORK/dd-directcontroller-host"
|
||||
"$WORK/dd-directcontroller-host/host_test"
|
||||
"$HERE/dd-directcontroller/build.sh" dlls "$T/bionic/dd-directcontroller"
|
||||
cp "$HERE/tool/toolmanifest.vdf" "$T/"
|
||||
# The name Steam registers the tool under ends in -Proton: Steam maps Windows save folders (WinAppDataLocal, WinMyDocuments
|
||||
# ...) into compatdata/<app>/pfx only for tools whose name contains "proton" (a case-insensitive search in
|
||||
|
||||
@@ -1,272 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# dd-directcontroller: build the XInput DLLs DroidDeck-Bionic puts in a prefix for games set to start without Steam
|
||||
# (launch.sh). Used by tools/bionic-runtime/build.sh.
|
||||
#
|
||||
# build.sh toolchain fetch the pinned llvm-mingw into $LLVM_MINGW (default ~/.cache/...)
|
||||
# build.sh dlls <outdir> <outdir>/{arm64x,i386}/<dll>.dll for every XInput DLL name, each export table
|
||||
# (both views of an ARM64X image), import list and machine type checked
|
||||
# build.sh host <outdir> <outdir>/host_test (native, cc): the ring snapshot reader against a writer
|
||||
#
|
||||
# The PE side uses bylaws/llvm-mingw (its arm64ec target does not predefine __x86_64__, unlike upstream's).
|
||||
# One C source (src/dd_directcontroller.c) is linked once per DLL name with that name's .def file (def/), so each
|
||||
# DLL has exactly the exports and ordinals of the Windows DLL it stands in for. i386 .def files get stdcall
|
||||
# decorations here and the link strips them (--kill-at).
|
||||
#
|
||||
# arm64x (system32 of the arm64ec layer): the source is compiled for ARM64EC and for native ARM64 and both
|
||||
# objects are linked into one ARM64X image (lld: -m arm64xpe, the .def for the EC view, -defarm64native for
|
||||
# the native view; each view gets its own CRT, the native one taken from the toolchain's own aarch64 link
|
||||
# line). An x64 game loads the EC view, a native ARM64 process (Wine's own control.exe, ...) the ARM64 view;
|
||||
# an ARM64EC-only image fails there with c000007b. i386 goes to syswow64 for 32-bit games.
|
||||
#
|
||||
# Every DLL carries a VERSIONINFO resource with the file version of the Wine builtin DLL it replaces, so a
|
||||
# program reading it sees the same number as before.
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
LLVM_MINGW_VER=20250920
|
||||
case "$(uname -m)" in
|
||||
aarch64|arm64)
|
||||
LLVM_MINGW_HOST=aarch64; HOST_SUFFIX=-aarch64
|
||||
LLVM_MINGW_SHA256=bce5cc755c613515fd44e1ee9523123d854103abae147571adb645450036274d ;;
|
||||
*)
|
||||
LLVM_MINGW_HOST=x86_64; HOST_SUFFIX=
|
||||
LLVM_MINGW_SHA256=8dd8c34fc051a50c2fae86015f35057f8aae93fe1e19b34537ef1269a8b4c772 ;;
|
||||
esac
|
||||
LLVM_MINGW_TAR="llvm-mingw-${LLVM_MINGW_VER}-ucrt-ubuntu-22.04-${LLVM_MINGW_HOST}.tar.xz"
|
||||
LLVM_MINGW_URL="https://github.com/bylaws/llvm-mingw/releases/download/${LLVM_MINGW_VER}/${LLVM_MINGW_TAR}"
|
||||
LLVM_MINGW="${LLVM_MINGW:-$HOME/.cache/llvm-mingw-bylaws-${LLVM_MINGW_VER}${HOST_SUFFIX}}"
|
||||
|
||||
DLLS="xinput1_1 xinput1_2 xinput1_3 xinput1_4 xinput9_1_0 xinputuap"
|
||||
ARCHES="arm64x i386"
|
||||
MARKER="dd-directcontroller: "
|
||||
|
||||
say() { printf '== dd-directcontroller: %s\n' "$*"; }
|
||||
die() { printf '::error::dd-directcontroller: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
toolchain() {
|
||||
if [ ! -x "$LLVM_MINGW/bin/arm64ec-w64-mingw32-clang" ]; then
|
||||
say "fetching $LLVM_MINGW_TAR"
|
||||
local tmp; tmp="$(mktemp -d)"
|
||||
curl -fsSL --retry 5 --retry-delay 5 -o "$tmp/t.tar.xz" "$LLVM_MINGW_URL"
|
||||
echo "$LLVM_MINGW_SHA256 $tmp/t.tar.xz" | sha256sum -c -
|
||||
mkdir -p "$LLVM_MINGW"
|
||||
tar -xJf "$tmp/t.tar.xz" -C "$LLVM_MINGW" --strip-components=1
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
export PATH="$LLVM_MINGW/bin:$PATH"
|
||||
for t in i686 arm64ec aarch64; do
|
||||
command -v "$t-w64-mingw32-clang" >/dev/null || die "llvm-mingw has no $t-w64-mingw32-clang"
|
||||
done
|
||||
for t in i686 aarch64; do
|
||||
command -v "$t-w64-mingw32-windres" >/dev/null || die "llvm-mingw has no $t-w64-mingw32-windres"
|
||||
done
|
||||
say "llvm-mingw $LLVM_MINGW_VER: $(arm64ec-w64-mingw32-clang --version | head -1)"
|
||||
}
|
||||
|
||||
windres_for() {
|
||||
case "$1" in
|
||||
i386) echo i686-w64-mingw32-windres ;;
|
||||
arm64x) echo aarch64-w64-mingw32-windres ;;
|
||||
*) die "unknown arch $1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# File version of the Wine builtin each DLL replaces (dlls/<name>/version.rc).
|
||||
DLL_VERSIONS='xinput1_1:9,12,589,0 xinput1_2:9,14,701,0 xinput1_3:9,15,779,0 xinput1_4:6,3,9600,16384 xinput9_1_0:9,10,455,0 xinputuap:10,0,19041,746'
|
||||
|
||||
version_res() { # version_res <arch> <dll> <tmpdir> -> path of a COFF object with the DLL's VERSIONINFO
|
||||
local ver="" kv rc="$3/$2.rc" obj="$3/$2-ver-$1.o"
|
||||
for kv in $DLL_VERSIONS; do [ "${kv%%:*}" = "$2" ] && ver="${kv#*:}"; done
|
||||
[ -n "$ver" ] || die "no version for $2 in DLL_VERSIONS"
|
||||
cat >"$rc" <<EOF
|
||||
1 VERSIONINFO
|
||||
FILEVERSION $ver
|
||||
PRODUCTVERSION $ver
|
||||
FILEFLAGSMASK 0x3f
|
||||
FILEFLAGS 0x0
|
||||
FILEOS 0x40004
|
||||
FILETYPE 0x2
|
||||
FILESUBTYPE 0x0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "DroidDeck"
|
||||
VALUE "FileDescription", "dd-directcontroller controller API (DroidDeck)"
|
||||
VALUE "FileVersion", "${ver//,/.}"
|
||||
VALUE "InternalName", "$2"
|
||||
VALUE "LegalCopyright", "GPL-3.0"
|
||||
VALUE "OriginalFilename", "$2.dll"
|
||||
VALUE "ProductName", "DroidDeck"
|
||||
VALUE "ProductVersion", "${ver//,/.}"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
EOF
|
||||
"$(windres_for "$1")" "$rc" -O coff -o "$obj"
|
||||
echo "$obj"
|
||||
}
|
||||
|
||||
# stdcall argument bytes of every export (i386 decoration).
|
||||
I386_DECOR='DllMain:12 XInputGetState:8 XInputSetState:8 XInputGetStateEx:8 XInputGetCapabilities:12 XInputGetDSoundAudioDeviceGuids:12 XInputGetBatteryInformation:12 XInputGetKeystroke:12 XInputWaitForGuideButton:12 XInputEnable:4 XInputCancelGuideButtonWait:4 XInputPowerOffController:4 XInputGetAudioDeviceIds:20 XInputGetCapabilitiesEx:16'
|
||||
|
||||
def_for() { # def_for <arch> <dll> <tmpdir> -> path of the .def to link with
|
||||
local src="$HERE/def/$2.def"
|
||||
if [ "$1" != i386 ]; then echo "$src"; return; fi
|
||||
awk -v table="$I386_DECOR" 'BEGIN { n = split(table, a, " "); for (i = 1; i <= n; i++) { split(a[i], kv, ":"); m[kv[1]] = kv[2] } }
|
||||
($1 in m) { sub($1, $1 "@" m[$1]) } { print }' "$src" > "$3/$2.def"
|
||||
echo "$3/$2.def"
|
||||
}
|
||||
|
||||
# expected "<ordinal> <name|->" lines of a .def (NONAME exports have no name)
|
||||
def_exports() {
|
||||
awk 'f && NF { ord = ""; for (i = 2; i <= NF; i++) if ($i ~ /^@[0-9]+$/) ord = substr($i, 2);
|
||||
name = $1; for (i = 2; i <= NF; i++) if ($i == "NONAME") name = "-";
|
||||
print (ord == "" ? "?" : ord), name }
|
||||
/^EXPORTS/ { f = 1 }' "$1" | sort
|
||||
}
|
||||
|
||||
# actual "<ordinal> <name|->" lines of a DLL (unused ordinals between the numbered ones have RVA 0 and are
|
||||
# skipped). dll_exports <file> [main|hybrid]: llvm-readobj prints an ARM64X image's native view first, then
|
||||
# its EC view inside "HybridObject {".
|
||||
dll_exports() {
|
||||
llvm-readobj --coff-exports "$1" | awk -v view="${2:-main}" '
|
||||
/HybridObject \{/ { h = 1; next }
|
||||
(view == "main" && h) || (view == "hybrid" && !h) { next }
|
||||
/^ *Export \{/ { o = ""; n = "-"; r = "" }
|
||||
/^ *Ordinal:/ { o = $2 }
|
||||
/^ *Name:/ { if (NF >= 2) n = $2 }
|
||||
/^ *RVA:/ { r = $2 }
|
||||
/^ *\}/ { if (o != "" && r != "" && r != "0x0") print o, n; o = "" }' | sort
|
||||
}
|
||||
|
||||
compare_exports() { # compare_exports <label> <file> <def> <view>
|
||||
local want got
|
||||
want="$(def_exports "$HERE/def/$3.def")"
|
||||
got="$(dll_exports "$2" "$4")"
|
||||
if [ "$want" != "$got" ]; then
|
||||
printf 'want:\n%s\ngot:\n%s\n' "$want" "$got"
|
||||
die "$1 exports differ from def/$3.def"
|
||||
fi
|
||||
}
|
||||
|
||||
check_dll() { # check_dll <arch> <dll name> <file>
|
||||
local arch="$1" name="$2" f="$3" fmts fmt hyb machine lc imports bad res
|
||||
fmts="$(llvm-readobj --file-headers "$f" | sed -n 's/^ *Format: //p')"
|
||||
fmt="$(sed -n 1p <<<"$fmts")"
|
||||
hyb="$(sed -n 2p <<<"$fmts")"
|
||||
case "$arch" in
|
||||
i386) [ "$fmt" = "COFF-i386" ] && [ -z "$hyb" ] || die "$f is $fmt${hyb:+ + $hyb}, want COFF-i386" ;;
|
||||
arm64x)
|
||||
# Native view: an ARM64 PE (what an ARM64 process maps). EC view: ARM64EC (what an x64 process sees
|
||||
# through the ARM64X dynamic relocations). Both need the CHPE metadata.
|
||||
machine="$(python3 -c 'import struct,sys; d=open(sys.argv[1],"rb").read(4096); o=struct.unpack_from("<I",d,0x3c)[0]; print(hex(struct.unpack_from("<H",d,o+4)[0]) if d[o:o+4]==b"PE\0\0" else "?")' "$f")"
|
||||
[ "$machine" = 0xaa64 ] || die "$f PE header machine is $machine, want 0xaa64 (ARM64)"
|
||||
[ "$hyb" = "COFF-ARM64EC" ] || die "$f has no ARM64EC hybrid view (formats: $(echo $fmts))"
|
||||
lc="$(llvm-readobj --coff-load-config "$f")"
|
||||
grep -q 'CHPEMetadata' <<<"$lc" || die "$f has no CHPE metadata"
|
||||
grep -q 'Arm64X' <<<"$lc" || die "$f has no ARM64X dynamic relocations"
|
||||
# One TLS directory serves both views and would list native ARM64 callbacks (see src/notls.c).
|
||||
llvm-readobj --file-headers "$f" | grep -q 'TLSTableRVA: 0x[1-9a-fA-F]' && die "$f has a TLS directory"
|
||||
fmt="$fmt/$hyb/$machine"
|
||||
;;
|
||||
esac
|
||||
compare_exports "$arch/$name.dll" "$f" "$name" main
|
||||
[ "$arch" != arm64x ] || compare_exports "$arch/$name.dll (EC view)" "$f" "$name" hybrid
|
||||
imports="$(llvm-readobj --coff-imports "$f" | sed -n 's/^ *Name: //p' | tr 'A-Z' 'a-z' | sort -u)"
|
||||
bad="$(grep -vxE 'kernel32\.dll|ucrtbase\.dll|msvcrt\.dll|api-ms-win-crt-[a-z0-9-]+\.dll' <<<"$imports" || true)"
|
||||
[ -z "$bad" ] || die "$arch/$name.dll imports $(echo $bad) (only kernel32 and the C runtime are allowed)"
|
||||
grep -aqF "$MARKER" "$f" || die "$arch/$name.dll lacks its '$MARKER' marker (launch.sh and the rumble path look for it)"
|
||||
res="$(llvm-readobj --coff-resources "$f")"
|
||||
grep -q 'Type: VERSIONINFO (ID 16)' <<<"$res" || die "$arch/$name.dll has no VERSIONINFO resource"
|
||||
printf ' %-7s %-15s %6d bytes %-24s imports: %s\n' "$arch" "$name.dll" "$(stat -c %s "$f")" "$fmt" "$(echo $imports)"
|
||||
}
|
||||
|
||||
# The objects and archives the toolchain links into an aarch64 DLL (CRT start-up, mingw/ucrt/kernel32 import
|
||||
# libraries, compiler-rt), as absolute paths: the native view of an ARM64X image needs its own.
|
||||
native_link_inputs() { # native_link_inputs <tmpdir>
|
||||
printf 'int x;\n' > "$1/empty.c"
|
||||
aarch64-w64-mingw32-clang -shared -o "$1/empty.dll" "$1/empty.c" -### 2>&1 | python3 -c '
|
||||
import os, shlex, sys
|
||||
line = [l for l in sys.stdin.read().splitlines() if "ld.lld" in l or "lld-link" in l]
|
||||
if not line:
|
||||
sys.exit("no link line in the -### output")
|
||||
toks = shlex.split(line[-1])
|
||||
dirs = [t[2:] for t in toks if t.startswith("-L")]
|
||||
out = []
|
||||
for t in toks[1:]:
|
||||
if t.startswith("-l"):
|
||||
name = t[2:]
|
||||
hit = next((os.path.join(d, c) for d in dirs for c in ("lib%s.a" % name, "lib%s.dll.a" % name, "%s.lib" % name)
|
||||
if os.path.isfile(os.path.join(d, c))), None)
|
||||
if not hit:
|
||||
sys.exit("cannot resolve -l%s in %s" % (name, dirs))
|
||||
out.append(hit)
|
||||
elif t.endswith((".o", ".a", ".obj", ".lib")) and os.path.isabs(t) and os.path.isfile(t):
|
||||
out.append(t)
|
||||
seen = set()
|
||||
print("\n".join(p for p in out if not (p in seen or seen.add(p))))
|
||||
'
|
||||
}
|
||||
|
||||
# notls-*.o (src/notls.c) come before the CRT so the image gets no TLS directory.
|
||||
link_arm64x() { # link_arm64x <out> <def> <ec obj> <native obj> <native inputs file> <ec notls obj> <native notls obj> <version res obj>
|
||||
local nat=()
|
||||
mapfile -t nat <"$5"
|
||||
arm64ec-w64-mingw32-clang -shared -s -Wl,--no-insert-timestamp -Wl,-marm64xpe "-Wl,--Xlink=-defarm64native:$2" \
|
||||
-o "$1" "$3" "$6" "$4" "$7" "$8" "$2" "${nat[@]}" -lkernel32
|
||||
}
|
||||
|
||||
CFLAGS_COMMON="-std=gnu11 -O2 -Wall -Wextra -Werror -fno-strict-aliasing -I$HERE/src"
|
||||
|
||||
dlls() {
|
||||
local out="${1:?usage: build.sh dlls <outdir>}" tmp arch name def
|
||||
toolchain
|
||||
mkdir -p "$out"; out="$(cd "$out" && pwd)"
|
||||
tmp="$(mktemp -d)"
|
||||
for arch in $ARCHES; do
|
||||
mkdir -p "$out/$arch"
|
||||
if [ "$arch" = arm64x ]; then
|
||||
arm64ec-w64-mingw32-clang $CFLAGS_COMMON -DDDC_HYBRID=1 -c "$HERE/src/dd_directcontroller.c" -o "$tmp/ddc-arm64ec.o"
|
||||
aarch64-w64-mingw32-clang $CFLAGS_COMMON -DDDC_HYBRID=1 -c "$HERE/src/dd_directcontroller.c" -o "$tmp/ddc-aarch64.o"
|
||||
arm64ec-w64-mingw32-clang $CFLAGS_COMMON -c "$HERE/src/notls.c" -o "$tmp/notls-arm64ec.o"
|
||||
aarch64-w64-mingw32-clang $CFLAGS_COMMON -c "$HERE/src/notls.c" -o "$tmp/notls-aarch64.o"
|
||||
native_link_inputs "$tmp" >"$tmp/native-inputs"
|
||||
for name in $DLLS; do
|
||||
link_arm64x "$out/$arch/$name.dll" "$HERE/def/$name.def" "$tmp/ddc-arm64ec.o" "$tmp/ddc-aarch64.o" "$tmp/native-inputs" \
|
||||
"$tmp/notls-arm64ec.o" "$tmp/notls-aarch64.o" "$(version_res "$arch" "$name" "$tmp")"
|
||||
check_dll "$arch" "$name" "$out/$arch/$name.dll"
|
||||
done
|
||||
continue
|
||||
fi
|
||||
# i386: SSE2 so a full fence is mfence
|
||||
i686-w64-mingw32-clang $CFLAGS_COMMON -msse2 -mfpmath=sse -c "$HERE/src/dd_directcontroller.c" -o "$tmp/ddc-i386.o"
|
||||
for name in $DLLS; do
|
||||
def="$(def_for "$arch" "$name" "$tmp")"
|
||||
i686-w64-mingw32-clang -shared -s -Wl,--no-insert-timestamp -Wl,--kill-at -o "$out/$arch/$name.dll" "$tmp/ddc-i386.o" \
|
||||
"$(version_res "$arch" "$name" "$tmp")" "$def" -lkernel32
|
||||
check_dll "$arch" "$name" "$out/$arch/$name.dll"
|
||||
done
|
||||
done
|
||||
rm -rf "$tmp"
|
||||
say "$(ls "$out"/*/*.dll | wc -l) DLLs in $out"
|
||||
}
|
||||
|
||||
host() {
|
||||
local out="${1:?usage: build.sh host <outdir>}"
|
||||
mkdir -p "$out"
|
||||
"${CC:-cc}" -std=gnu11 -O2 -Wall -Wextra -Werror -pthread -I"$HERE/src" -o "$out/host_test" "$HERE/test/host_test.c"
|
||||
say "host_test built for $(uname -m)"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
toolchain) toolchain ;;
|
||||
dlls) dlls "${2:-}" ;;
|
||||
host) host "${2:-}" ;;
|
||||
*) die "usage: $0 toolchain | dlls <outdir> | host <outdir>" ;;
|
||||
esac
|
||||
@@ -1,11 +0,0 @@
|
||||
LIBRARY xinput1_1.dll
|
||||
EXPORTS
|
||||
XInputEnable @1
|
||||
XInputGetCapabilities @2
|
||||
XInputGetDSoundAudioDeviceGuids @3
|
||||
XInputSetState @4
|
||||
XInputGetState @5
|
||||
XInputGetStateEx @100
|
||||
XInputWaitForGuideButton @101
|
||||
XInputCancelGuideButtonWait @102
|
||||
XInputPowerOffController @103
|
||||
@@ -1,11 +0,0 @@
|
||||
LIBRARY xinput1_2.dll
|
||||
EXPORTS
|
||||
XInputEnable @1
|
||||
XInputGetCapabilities @2
|
||||
XInputGetDSoundAudioDeviceGuids @3
|
||||
XInputSetState @4
|
||||
XInputGetState @5
|
||||
XInputGetStateEx @100
|
||||
XInputWaitForGuideButton @101
|
||||
XInputCancelGuideButtonWait @102
|
||||
XInputPowerOffController @103
|
||||
@@ -1,14 +0,0 @@
|
||||
LIBRARY xinput1_3.dll
|
||||
EXPORTS
|
||||
DllMain @1
|
||||
XInputGetState @2
|
||||
XInputSetState @3
|
||||
XInputGetCapabilities @4
|
||||
XInputEnable @5
|
||||
XInputGetDSoundAudioDeviceGuids @6
|
||||
XInputGetBatteryInformation @7
|
||||
XInputGetKeystroke @8
|
||||
XInputGetStateEx @100
|
||||
XInputWaitForGuideButton @101
|
||||
XInputCancelGuideButtonWait @102
|
||||
XInputPowerOffController @103
|
||||
@@ -1,15 +0,0 @@
|
||||
LIBRARY xinput1_4.dll
|
||||
EXPORTS
|
||||
DllMain @1
|
||||
XInputGetState @2
|
||||
XInputSetState @3
|
||||
XInputGetCapabilities @4
|
||||
XInputEnable @5
|
||||
XInputGetBatteryInformation @7
|
||||
XInputGetKeystroke @8
|
||||
XInputGetAudioDeviceIds @10
|
||||
XInputGetStateEx @100
|
||||
XInputWaitForGuideButton @101
|
||||
XInputCancelGuideButtonWait @102
|
||||
XInputPowerOffController @103
|
||||
XInputGetCapabilitiesEx @108
|
||||
@@ -1,10 +0,0 @@
|
||||
LIBRARY xinput9_1_0.dll
|
||||
EXPORTS
|
||||
XInputGetCapabilities @1
|
||||
XInputGetDSoundAudioDeviceGuids @2
|
||||
XInputSetState @3
|
||||
XInputGetState @4
|
||||
XInputGetStateEx @100
|
||||
XInputWaitForGuideButton @101
|
||||
XInputCancelGuideButtonWait @102
|
||||
XInputPowerOffController @103
|
||||
@@ -1,14 +0,0 @@
|
||||
LIBRARY xinputuap.dll
|
||||
EXPORTS
|
||||
DllMain @1
|
||||
XInputEnable @2
|
||||
XInputGetAudioDeviceIds @3
|
||||
XInputGetBatteryInformation @4
|
||||
XInputGetCapabilities @5
|
||||
XInputGetKeystroke @6
|
||||
XInputGetState @7
|
||||
XInputSetState @8
|
||||
XInputGetStateEx @100
|
||||
XInputWaitForGuideButton @101
|
||||
XInputCancelGuideButtonWait @102
|
||||
XInputPowerOffController @103
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* dd-directcontroller: the read side of DroidDeck's controller ring file (one per pad slot), shared by the
|
||||
* XInput DLL and its host test.
|
||||
*
|
||||
* The app (input/FakeInputWriter.java) writes each slot's ring file; fakeinput_steam.cpp reads its events
|
||||
* for Wine's evdev path. The 64-byte header (FakeInputRingHeader, ABI-stable) also carries a snapshot of
|
||||
* the whole pad that the writer updates on every publish, under a sequence counter:
|
||||
*
|
||||
* 0 u32 magic 0x46494252 16 u64 write_seq 40 u32 snapshot buttons (bit = BUTTON_MAP index)
|
||||
* 4 u32 version 2 24 u64 generation 44 i16 snapshot axes[8]
|
||||
* 8 u32 event size 24 32 u64 snapshot_seq 60 u32 resync_seq
|
||||
* 12 u32 capacity 4096
|
||||
*
|
||||
* Snapshot protocol (FakeInputWriter.writeSnapshotLocked): seq + 1 (odd), store fence, buttons and axes,
|
||||
* store fence, seq + 2 (even). A reader takes the state when it saw the same even seq before and after.
|
||||
* Only 32-bit loads are used: on i386 a 64-bit atomic load is a cmpxchg8b, which writes and so faults on a
|
||||
* read-only view; the low halves of seq and generation are enough to see a change.
|
||||
*
|
||||
* Axes: [0] left X, [1] left Y, [2] right X, [3] right Y (evdev sense, -32767..32767, Y positive = down),
|
||||
* [4] right trigger, [5] left trigger (0..255), [6] hat X, [7] hat Y (-1, 0, 1; Y -1 = up).
|
||||
*/
|
||||
#ifndef DD_DIRECTCONTROLLER_RING_H
|
||||
#define DD_DIRECTCONTROLLER_RING_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define DDC_RING_MAGIC 0x46494252u
|
||||
#define DDC_RING_VERSION 2u
|
||||
#define DDC_RING_EVENT_SIZE 24u
|
||||
#define DDC_RING_CAPACITY 4096u
|
||||
#define DDC_RING_HEADER_SIZE 64u
|
||||
|
||||
#define DDC_OFF_MAGIC 0u
|
||||
#define DDC_OFF_VERSION 4u
|
||||
#define DDC_OFF_EVENT_SIZE 8u
|
||||
#define DDC_OFF_CAPACITY 12u
|
||||
#define DDC_OFF_GENERATION 24u /* low half */
|
||||
#define DDC_OFF_SNAP_SEQ 32u /* low half */
|
||||
#define DDC_OFF_SNAP_BUTTONS 40u
|
||||
#define DDC_OFF_SNAP_AXES 44u
|
||||
|
||||
/* Snapshot button bits: FakeInputWriter.BUTTON_MAP index (QAM = DroidDeck's quick-access button). */
|
||||
enum {
|
||||
DDC_B_A, DDC_B_B, DDC_B_X, DDC_B_Y, DDC_B_TL, DDC_B_TR, DDC_B_SELECT, DDC_B_START,
|
||||
DDC_B_THUMBL, DDC_B_THUMBR, DDC_B_MODE, DDC_B_QAM,
|
||||
};
|
||||
|
||||
enum { DDC_A_LX, DDC_A_LY, DDC_A_RX, DDC_A_RY, DDC_A_RT, DDC_A_LT, DDC_A_HATX, DDC_A_HATY };
|
||||
|
||||
/* XInput button bits */
|
||||
#define DDC_XI_DPAD_UP 0x0001u
|
||||
#define DDC_XI_DPAD_DOWN 0x0002u
|
||||
#define DDC_XI_DPAD_LEFT 0x0004u
|
||||
#define DDC_XI_DPAD_RIGHT 0x0008u
|
||||
#define DDC_XI_START 0x0010u
|
||||
#define DDC_XI_BACK 0x0020u
|
||||
#define DDC_XI_LEFT_THUMB 0x0040u
|
||||
#define DDC_XI_RIGHT_THUMB 0x0080u
|
||||
#define DDC_XI_LEFT_SHOULDER 0x0100u
|
||||
#define DDC_XI_RIGHT_SHOULDER 0x0200u
|
||||
#define DDC_XI_GUIDE 0x0400u
|
||||
#define DDC_XI_A 0x1000u
|
||||
#define DDC_XI_B 0x2000u
|
||||
#define DDC_XI_X 0x4000u
|
||||
#define DDC_XI_Y 0x8000u
|
||||
|
||||
typedef struct {
|
||||
uint32_t seq; /* low half of snapshot_seq (even) */
|
||||
uint32_t generation; /* low half */
|
||||
uint32_t buttons;
|
||||
int16_t axes[8];
|
||||
} ddc_snap;
|
||||
|
||||
typedef struct {
|
||||
uint16_t buttons;
|
||||
uint8_t lt, rt;
|
||||
int16_t lx, ly, rx, ry;
|
||||
} ddc_pad;
|
||||
|
||||
static inline uint32_t ddc_ld32(const uint8_t *v, uint32_t off, int order) {
|
||||
return __atomic_load_n((const uint32_t *)(const void *)(v + off), order);
|
||||
}
|
||||
|
||||
/* 1 if the view starts with a version-2 ring header of the size this file reads. */
|
||||
static inline int ddc_valid(const uint8_t *v) {
|
||||
return ddc_ld32(v, DDC_OFF_MAGIC, __ATOMIC_RELAXED) == DDC_RING_MAGIC &&
|
||||
ddc_ld32(v, DDC_OFF_VERSION, __ATOMIC_RELAXED) == DDC_RING_VERSION &&
|
||||
ddc_ld32(v, DDC_OFF_EVENT_SIZE, __ATOMIC_RELAXED) == DDC_RING_EVENT_SIZE &&
|
||||
ddc_ld32(v, DDC_OFF_CAPACITY, __ATOMIC_RELAXED) == DDC_RING_CAPACITY;
|
||||
}
|
||||
|
||||
/* A consistent copy of the snapshot, in at most `attempts` tries; 0 if the writer kept lapping it. */
|
||||
static inline int ddc_snapshot(const uint8_t *v, ddc_snap *out, unsigned attempts) {
|
||||
for (unsigned i = 0; i < attempts; i++) {
|
||||
uint32_t s1 = ddc_ld32(v, DDC_OFF_SNAP_SEQ, __ATOMIC_ACQUIRE);
|
||||
if (s1 & 1u) continue;
|
||||
uint32_t gen = ddc_ld32(v, DDC_OFF_GENERATION, __ATOMIC_RELAXED);
|
||||
uint32_t buttons = ddc_ld32(v, DDC_OFF_SNAP_BUTTONS, __ATOMIC_RELAXED);
|
||||
uint32_t w[4];
|
||||
for (unsigned k = 0; k < 4; k++) w[k] = ddc_ld32(v, DDC_OFF_SNAP_AXES + 4u * k, __ATOMIC_RELAXED);
|
||||
__atomic_thread_fence(__ATOMIC_ACQUIRE);
|
||||
if (ddc_ld32(v, DDC_OFF_SNAP_SEQ, __ATOMIC_RELAXED) != s1) continue;
|
||||
out->seq = s1;
|
||||
out->generation = gen;
|
||||
out->buttons = buttons;
|
||||
for (unsigned k = 0; k < 4; k++) { /* little endian: axis 2k in the low half */
|
||||
out->axes[2 * k] = (int16_t)(uint16_t)(w[k] & 0xffffu);
|
||||
out->axes[2 * k + 1] = (int16_t)(uint16_t)(w[k] >> 16);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int16_t ddc_flip(int16_t v) { /* evdev Y (down = +) to XInput Y (up = +) */
|
||||
return v == INT16_MIN ? INT16_MAX : (int16_t)-v;
|
||||
}
|
||||
|
||||
static inline uint8_t ddc_trigger(int16_t v) {
|
||||
return v <= 0 ? 0 : v >= 255 ? 255 : (uint8_t)v;
|
||||
}
|
||||
|
||||
/* The snapshot as an XInput pad; Guide only when `guide` (XInputGetStateEx). */
|
||||
static inline void ddc_map(const ddc_snap *s, int guide, ddc_pad *p) {
|
||||
static const uint16_t bit[11] = {
|
||||
DDC_XI_A, DDC_XI_B, DDC_XI_X, DDC_XI_Y, DDC_XI_LEFT_SHOULDER, DDC_XI_RIGHT_SHOULDER,
|
||||
DDC_XI_BACK, DDC_XI_START, DDC_XI_LEFT_THUMB, DDC_XI_RIGHT_THUMB, DDC_XI_GUIDE,
|
||||
};
|
||||
uint16_t b = 0;
|
||||
for (unsigned i = 0; i < 11; i++)
|
||||
if (s->buttons & (1u << i)) b |= bit[i];
|
||||
if (!guide) b &= (uint16_t)~DDC_XI_GUIDE;
|
||||
if (s->axes[DDC_A_HATX] < 0) b |= DDC_XI_DPAD_LEFT;
|
||||
if (s->axes[DDC_A_HATX] > 0) b |= DDC_XI_DPAD_RIGHT;
|
||||
if (s->axes[DDC_A_HATY] < 0) b |= DDC_XI_DPAD_UP;
|
||||
if (s->axes[DDC_A_HATY] > 0) b |= DDC_XI_DPAD_DOWN;
|
||||
p->buttons = b;
|
||||
p->lx = s->axes[DDC_A_LX];
|
||||
p->ly = ddc_flip(s->axes[DDC_A_LY]);
|
||||
p->rx = s->axes[DDC_A_RX];
|
||||
p->ry = ddc_flip(s->axes[DDC_A_RY]);
|
||||
p->lt = ddc_trigger(s->axes[DDC_A_LT]);
|
||||
p->rt = ddc_trigger(s->axes[DDC_A_RT]);
|
||||
}
|
||||
|
||||
/* FAKE_EVDEV_MEMFD_PATHS: "<slot>=<unix path>;..." -> take(ctx, slot, path, len) for slots 0..max-1. */
|
||||
#define DDC_DEFINE_PARSE_PATHS(fname, CH) \
|
||||
static void fname(const CH *s, void (*take)(void *, uint32_t, const CH *, size_t), void *ctx, \
|
||||
uint32_t max) { \
|
||||
while (s && *s) { \
|
||||
const CH *e = s; \
|
||||
while (*e && *e != ';') e++; \
|
||||
const CH *q = s; \
|
||||
uint32_t slot = 0; \
|
||||
int digits = 0; \
|
||||
while (q < e && *q >= '0' && *q <= '9' && digits < 3) slot = slot * 10u + (uint32_t)(*q++ - '0'), digits++; \
|
||||
if (digits && q < e && *q == '=' && q + 1 < e && slot < max) take(ctx, slot, q + 1, (size_t)(e - q - 1)); \
|
||||
s = *e ? e + 1 : e; \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Linked into both views of the ARM64X image only (build.sh link_arm64x), ahead of the mingw CRT.
|
||||
*
|
||||
* The CRT's DLL start-up (dllcrt2.o) references __dyn_tls_init_callback, which pulls tlssup.o and
|
||||
* with it _tls_used, the TLS directory. An ARM64X image has one TLS directory for both views (the
|
||||
* linker takes the native view's and emits no ARM64X relocation for it), so its callbacks are the
|
||||
* native ARM64 ones. In an x64 process (the EC view) Wine treats non-EC code as x64 and the emulator
|
||||
* runs those ARM64 bytes as x86 on every thread start: a stray write to the image header (base+0x42)
|
||||
* that the loader catches, but a game's own first-chance exception handler sees first (Cyberpunk
|
||||
* 2077's crash reporter exits on it).
|
||||
*
|
||||
* Defining the symbol here keeps tlssup.o out, so the image has no TLS directory. The CRT checks the
|
||||
* pointer for NULL before calling it; this DLL has no thread-local variables.
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback = NULL;
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* dd-directcontroller host test: the ring snapshot reader (dd_directcontroller_ring.h) against a writer that follows
|
||||
* FakeInputWriter.writeSnapshotLocked, on a shared file mapping (the app and the guest map the same file),
|
||||
* plus the XInput mapping and the FAKE_EVDEV_MEMFD_PATHS parser.
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "dd_directcontroller_ring.h"
|
||||
|
||||
static int failures;
|
||||
#define CHECK(c, ...) do { if (!(c)) { failures++; printf("FAIL %s:%d: ", __FILE__, __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)
|
||||
|
||||
static uint8_t *wmap;
|
||||
static volatile int stop;
|
||||
|
||||
static void put32(uint32_t off, uint32_t v) { __atomic_store_n((uint32_t *)(void *)(wmap + off), v, __ATOMIC_RELAXED); }
|
||||
static void put64(uint32_t off, uint64_t v) { __atomic_store_n((uint64_t *)(void *)(wmap + off), v, __ATOMIC_RELAXED); }
|
||||
|
||||
static void header(void) {
|
||||
put32(DDC_OFF_MAGIC, DDC_RING_MAGIC);
|
||||
put32(DDC_OFF_VERSION, DDC_RING_VERSION);
|
||||
put32(DDC_OFF_EVENT_SIZE, DDC_RING_EVENT_SIZE);
|
||||
put32(DDC_OFF_CAPACITY, DDC_RING_CAPACITY);
|
||||
}
|
||||
|
||||
/* FakeInputWriter.writeSnapshotLocked: seq + 1, fence, fields, fence, seq + 2 */
|
||||
static void publish(uint64_t *seq, uint32_t buttons, const int16_t axes[8]) {
|
||||
put64(DDC_OFF_SNAP_SEQ, *seq + 1);
|
||||
__atomic_thread_fence(__ATOMIC_RELEASE);
|
||||
put32(DDC_OFF_SNAP_BUTTONS, buttons);
|
||||
for (int k = 0; k < 8; k++)
|
||||
__atomic_store_n((int16_t *)(void *)(wmap + DDC_OFF_SNAP_AXES + 2 * k), axes[k], __ATOMIC_RELAXED);
|
||||
__atomic_thread_fence(__ATOMIC_RELEASE);
|
||||
put64(DDC_OFF_SNAP_SEQ, *seq + 2);
|
||||
*seq += 2;
|
||||
}
|
||||
|
||||
/* Every field carries the same counter, so a torn read shows up as fields that differ. */
|
||||
static uint64_t writer_seq;
|
||||
|
||||
static void *writer(void *arg) {
|
||||
(void)arg;
|
||||
uint64_t seq = writer_seq; /* the sequence continues: a reused value would let a stale read pass (ABA) */
|
||||
uint32_t n = 1;
|
||||
while (!stop) {
|
||||
int16_t v = (int16_t)(n & 0x3fff);
|
||||
int16_t axes[8] = {v, v, v, v, v, v, v, v};
|
||||
publish(&seq, (uint32_t)v, axes);
|
||||
n++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void take(void *ctx, uint32_t slot, const char *p, size_t len) {
|
||||
char *out = ctx;
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof buf, "%u:%.*s|", slot, (int)len, p);
|
||||
strcat(out, buf);
|
||||
}
|
||||
DDC_DEFINE_PARSE_PATHS(parse_paths, char)
|
||||
|
||||
int main(void) {
|
||||
char path[] = "/tmp/ddc-ring-XXXXXX";
|
||||
int fd = mkstemp(path);
|
||||
CHECK(fd >= 0, "mkstemp");
|
||||
size_t size = DDC_RING_HEADER_SIZE + DDC_RING_CAPACITY * DDC_RING_EVENT_SIZE;
|
||||
CHECK(ftruncate(fd, (off_t)size) == 0, "ftruncate");
|
||||
wmap = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
const uint8_t *rmap = mmap(NULL, DDC_RING_HEADER_SIZE, PROT_READ, MAP_SHARED, fd, 0);
|
||||
CHECK(wmap != MAP_FAILED && rmap != MAP_FAILED, "mmap");
|
||||
unlink(path);
|
||||
|
||||
CHECK(!ddc_valid(rmap), "an empty file is not a ring");
|
||||
header();
|
||||
CHECK(ddc_valid(rmap), "a version-2 header is a ring");
|
||||
put32(DDC_OFF_VERSION, 1);
|
||||
CHECK(!ddc_valid(rmap), "version 1 is refused");
|
||||
put32(DDC_OFF_VERSION, DDC_RING_VERSION);
|
||||
|
||||
/* mapping */
|
||||
uint64_t seq = 0;
|
||||
int16_t axes[8] = {1000, 2000, -3000, -32767, 255, 128, -1, 1};
|
||||
uint32_t buttons = (1u << DDC_B_A) | (1u << DDC_B_TR) | (1u << DDC_B_START) | (1u << DDC_B_MODE) | (1u << DDC_B_QAM);
|
||||
publish(&seq, buttons, axes);
|
||||
ddc_snap s;
|
||||
CHECK(ddc_snapshot(rmap, &s, 64), "snapshot of a settled ring");
|
||||
CHECK(s.seq == 2, "seq %u", s.seq);
|
||||
ddc_pad p;
|
||||
ddc_map(&s, 0, &p);
|
||||
CHECK(p.buttons == (DDC_XI_A | DDC_XI_RIGHT_SHOULDER | DDC_XI_START | DDC_XI_DPAD_LEFT | DDC_XI_DPAD_DOWN),
|
||||
"buttons 0x%04x (no Guide, no QAM, hat left + down)", p.buttons);
|
||||
CHECK(p.lx == 1000 && p.ly == -2000 && p.rx == -3000 && p.ry == 32767, "sticks %d %d %d %d (Y flipped)", p.lx, p.ly,
|
||||
p.rx, p.ry);
|
||||
CHECK(p.rt == 255 && p.lt == 128, "triggers lt %u rt %u", p.lt, p.rt);
|
||||
ddc_map(&s, 1, &p);
|
||||
CHECK(p.buttons & DDC_XI_GUIDE, "Guide in GetStateEx");
|
||||
int16_t edge[8] = {INT16_MIN, INT16_MIN, 0, 0, -5, 300, 0, -1};
|
||||
publish(&seq, 0, edge);
|
||||
CHECK(ddc_snapshot(rmap, &s, 64), "snapshot");
|
||||
ddc_map(&s, 0, &p);
|
||||
CHECK(p.ly == INT16_MAX && p.lt == 255 && p.rt == 0 && p.buttons == DDC_XI_DPAD_UP, "edges: ly %d lt %u rt %u b 0x%x",
|
||||
p.ly, p.lt, p.rt, p.buttons);
|
||||
|
||||
/* an odd seq (a write in progress) is never taken */
|
||||
put64(DDC_OFF_SNAP_SEQ, seq + 1);
|
||||
CHECK(!ddc_snapshot(rmap, &s, 64), "a snapshot mid-write is refused");
|
||||
put64(DDC_OFF_SNAP_SEQ, seq);
|
||||
|
||||
/* no torn reads against a running writer; the state before its first publish is consistent too */
|
||||
int16_t zero[8] = {0};
|
||||
publish(&seq, 0, zero);
|
||||
writer_seq = seq;
|
||||
pthread_t t;
|
||||
pthread_create(&t, NULL, writer, NULL);
|
||||
unsigned ok = 0, lapped = 0, torn = 0;
|
||||
for (unsigned i = 0; i < 2000000u; i++) {
|
||||
if (!ddc_snapshot(rmap, &s, 64)) { lapped++; continue; }
|
||||
ok++;
|
||||
for (int k = 1; k < 8; k++)
|
||||
if (s.axes[k] != s.axes[0]) { torn++; break; }
|
||||
if ((int16_t)s.buttons != s.axes[0]) torn++;
|
||||
}
|
||||
stop = 1;
|
||||
pthread_join(t, NULL);
|
||||
CHECK(torn == 0, "%u torn snapshots", torn);
|
||||
CHECK(ok > 0, "no snapshot taken");
|
||||
printf("concurrent: %u snapshots, %u lapped, %u torn\n", ok, lapped, torn);
|
||||
|
||||
/* FAKE_EVDEV_MEMFD_PATHS */
|
||||
char got[256] = "";
|
||||
parse_paths("0=/a/r0;1=/a/r1;4=/a/mouse;x=bad;2=;3=/a/r3", take, got, 4);
|
||||
CHECK(!strcmp(got, "0:/a/r0|1:/a/r1|3:/a/r3|"), "parsed '%s' (slot 4 = mouse and malformed entries skipped)", got);
|
||||
|
||||
printf(failures ? "host_test: %d failure(s)\n" : "host_test: OK\n", failures);
|
||||
return failures ? 1 : 0;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
|
||||
ANDROID_*|BOOTCLASSPATH|DEX2OATBOOTCLASSPATH|SYSTEMSERVERCLASSPATH|EXTERNAL_STORAGE|ASEC_MOUNTPOINT) ;;
|
||||
FAKE_*|SDL_*|DD_WIDTH|DD_HEIGHT|DD_VK_DRIVER|WINEDLLOVERRIDES) ;;
|
||||
DISPLAY|GAMESCOPE_WAYLAND_DISPLAY|FEX_*) ;;
|
||||
TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS|DROIDDECK_NO_STEAM|BANNER_AUDIO_DIRECT_*) ;;
|
||||
TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS|BANNER_AUDIO_DIRECT_*) ;;
|
||||
mesa_glthread|vblank_mode|ZINK_*|GALLIUM_HUD|GALLIUM_THREAD) ;;
|
||||
DD_SYNC|DD_FSYNC_FIRST|DD_SYNC_FALLBACK|PROTON_NO_ESYNC|PROTON_NO_FSYNC|PROTON_NO_NTSYNC|WINEESYNC) ;;
|
||||
PROTON_USE_D7VK) ;;
|
||||
@@ -138,13 +138,6 @@ echo "sync ntsync=$WINENTSYNC esync=$WINEESYNC ssbs=${WINE_FORCE_SSBS:-0} tu_deb
|
||||
export WINESTEAMCLIENTPATH64=$ROOTFS/root/.local/share/Steam/androidarm64/libsteamclient.so
|
||||
# The layer sends a game's steamclient(64).dll to lsteamclient (and so to DroidDeck's Steam through the library
|
||||
# above) only with WINE_LSTEAMCLIENT set; without it Valve's Windows steamclient runs alone and SteamAPI_Init fails.
|
||||
# A game set to start without Steam has no Steam client behind lsteamclient, and a steamclient64.dll it brings itself
|
||||
# (a Steam emulator such as gbe_fork's ColdClient loader) would be replaced by it, so the game quit after its splash
|
||||
# screen. Such a game keeps its own; a WINE_LSTEAMCLIENT the player set wins.
|
||||
if [ -z "${WINE_LSTEAMCLIENT:-}" ] && on "${DROIDDECK_NO_STEAM:-}"; then
|
||||
echo "lsteamclient off: started without Steam"
|
||||
export WINE_LSTEAMCLIENT=0
|
||||
fi
|
||||
export WINE_LSTEAMCLIENT=${WINE_LSTEAMCLIENT:-1}
|
||||
# Steam Input data (Valve's Steam Deck layouts with game actions) lives in DroidDeck's /dev/shm; libsteamshm.so
|
||||
# points the Android library's shared memory there (it keeps its own in-process otherwise) and gives it the
|
||||
@@ -426,59 +419,6 @@ elif [ -L "$S/ddraw_.dll" ] || [ -e "$S/ddraw_.dll" ]; then
|
||||
ln -s "$F/lib/wine/i386-windows/ddraw.dll" "$S/ddraw.dll"
|
||||
echo "$(date +%H:%M:%S) D7VK off: Wine's ddraw again"
|
||||
fi
|
||||
|
||||
# dd-directcontroller: a game set to start without Steam reads the controller through dd-directcontroller's XInput DLLs
|
||||
# (bionic/dd-directcontroller), which answer from the pad state DroidDeck keeps in each ring file instead of the queue
|
||||
# of HID reports Wine's xinput reads (a game that reads slower than the pad reports kept moving after the stick
|
||||
# was let go). They go into the prefix as copies, never through the links to this tool's builtins, with Wine's
|
||||
# xinput1_4 beside them as dd-directcontroller-wine-xinput.dll for rumble and pass-through. The mode file next to the
|
||||
# controller folder (DD_DIRECTCONTROLLER_CONTROL, '1' direct / '0' pass-through to Wine's xinput) is read by the DLLs
|
||||
# while the game runs, so DroidDeck can switch it live; it starts as DD_DIRECTCONTROLLER says (0 = pass-through). A game
|
||||
# no longer set to start without Steam gets Wine's links back.
|
||||
DDC=$TOOL/bionic/dd-directcontroller
|
||||
ddc_names="xinput1_1 xinput1_2 xinput1_3 xinput1_4 xinput9_1_0 xinputuap"
|
||||
ddc_put() { # src dst: dst becomes a copy of src; a link there is removed first, so the file it names stays as it was
|
||||
[ ! -L "$2" ] && cmp -s "$1" "$2" && return 0
|
||||
rm -f "$2" && cp "$1" "$2"
|
||||
}
|
||||
ddc_ours() { [ -f "$1" ] && [ ! -L "$1" ] && grep -qF "dd-directcontroller: " "$1"; }
|
||||
DDCW=$COMPAT/pfx/drive_c/windows
|
||||
if on "${DROIDDECK_NO_STEAM:-}" && [ -d "$DDC/arm64x" ] && [ -d "$DDC/i386" ]; then
|
||||
for a in arm64x:system32:aarch64-windows i386:syswow64:i386-windows; do
|
||||
src=$DDC/${a%%:*}; rest=${a#*:}; dir=$DDCW/${rest%%:*}; wine=$F/lib/wine/${rest#*:}
|
||||
[ -d "$dir" ] || continue
|
||||
for n in $ddc_names; do
|
||||
t=$dir/$n.dll
|
||||
# a native DLL that is neither Wine's nor ours (a game's own or a tool's) stays, as link_dir keeps it
|
||||
if [ -f "$t" ] && [ ! -L "$t" ] && ! is_builtin "$t" && ! ddc_ours "$t"; then
|
||||
echo "$(date +%H:%M:%S) dd-directcontroller: kept ${dir##*/}/$n.dll (not Wine's)"
|
||||
continue
|
||||
fi
|
||||
ddc_put "$src/$n.dll" "$t"
|
||||
done
|
||||
ddc_put "$wine/xinput1_4.dll" "$dir/dd-directcontroller-wine-xinput.dll"
|
||||
done
|
||||
export WINEDLLOVERRIDES="$WINEDLLOVERRIDES;xinput1_1,xinput1_2,xinput1_3,xinput1_4,xinput9_1_0,xinputuap=n,b"
|
||||
ddc_mode=1 ddc_name=direct
|
||||
[ "${DD_DIRECTCONTROLLER:-1}" = 0 ] && ddc_mode=0 ddc_name=pass-through
|
||||
if [ -n "${FAKE_EVDEV_DIR:-}" ] && echo "$ddc_mode" > "${FAKE_EVDEV_DIR%/*}/dd-directcontroller.mode"; then
|
||||
export DD_DIRECTCONTROLLER_CONTROL="${FAKE_EVDEV_DIR%/*}/dd-directcontroller.mode"
|
||||
else
|
||||
ddc_name="direct (no mode file)"
|
||||
fi
|
||||
echo "$(date +%H:%M:%S) dd-directcontroller on (starts $ddc_name)"
|
||||
else
|
||||
back=0
|
||||
for a in system32:aarch64-windows syswow64:i386-windows; do
|
||||
dir=$DDCW/${a%%:*}; wine=$F/lib/wine/${a#*:}
|
||||
for n in $ddc_names; do
|
||||
ddc_ours "$dir/$n.dll" || continue
|
||||
rm -f "$dir/$n.dll" && ln -s "$wine/$n.dll" "$dir/$n.dll" && back=$((back + 1))
|
||||
done
|
||||
rm -f "$dir/dd-directcontroller-wine-xinput.dll"
|
||||
done
|
||||
[ $back -gt 0 ] && echo "$(date +%H:%M:%S) dd-directcontroller off: Wine's xinput again"
|
||||
fi
|
||||
# A Windows path (an Xbox game on its own drive letter) starts in the folder Steam gave.
|
||||
case "$EXE" in [A-Za-z]:[\\/]*) ;; *) cd "$(dirname "$EXE")" || exit 1 ;; esac
|
||||
|
||||
|
||||
@@ -1658,16 +1658,6 @@ def system_graphics_launch(command, env):
|
||||
return [str(wrapper), *command], result
|
||||
|
||||
|
||||
AUDIO_STREAMS_PROBE = (
|
||||
'folder=$1; launch=$2; shift 2; n=0; '
|
||||
'for t in "$@"; do '
|
||||
'while [ "$n" -lt "$t" ]; do kill -0 "$launch" 2>/dev/null || exit 0; sleep 1; n=$((n + 1)); done; '
|
||||
'kill -0 "$launch" 2>/dev/null || exit 0; '
|
||||
'{ echo "== $(date +%T)"; pactl list sink-inputs 2>&1 | head -80; } >> "$folder/audio-streams.txt"; '
|
||||
'done'
|
||||
)
|
||||
|
||||
|
||||
def game_logs(command, env, app_id, now=None):
|
||||
"""Detailed graphics logs for one game launch, in the session's log folder: Proton's own log,
|
||||
DXVK's and vkd3d-proton's, and the Vulkan driver's startup messages. The app turns this on
|
||||
@@ -1713,7 +1703,8 @@ def game_logs(command, env, app_id, now=None):
|
||||
pass
|
||||
# Whether the game's sound reaches PulseAudio: the streams 20 s and 60 s in, without waiting.
|
||||
try:
|
||||
subprocess.Popen(["sh", "-c", AUDIO_STREAMS_PROBE, "audio", str(folder), str(os.getpid()), "20", "60"],
|
||||
subprocess.Popen(["sh", "-c", 'for t in 20 40; do sleep $t; { echo "== $(date +%T)"; '
|
||||
'pactl list sink-inputs 2>&1 | head -80; } >> "$1/audio-streams.txt"; done', "audio", str(folder)],
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
except OSError:
|
||||
|
||||
@@ -100,31 +100,6 @@ def tools(root):
|
||||
return found
|
||||
|
||||
|
||||
def startable(root, available):
|
||||
c = compat()
|
||||
sources = dict(c["OWN_TOOLS"])
|
||||
return {name: tool for name, tool in available.items()
|
||||
if name not in sources or c["find_source"](root, sources[name], runnable=True)}
|
||||
|
||||
|
||||
def missing_proton(root):
|
||||
c = compat()
|
||||
for library in c["libraries"](root):
|
||||
text = read_text(os.path.join(library, "steamapps", "appmanifest_%s.acf" % c["PROTON_ARM64_APPID"]))
|
||||
if text is None:
|
||||
continue
|
||||
tokens = c["tokenize"](text)
|
||||
sizes = tuple(c["manifest_number"](tokens, key) // 2 ** 20 for key in ("BytesDownloaded", "BytesToDownload", "BytesToStage"))
|
||||
try:
|
||||
st = os.statvfs(library)
|
||||
free = "%d MB" % (st.f_bavail * st.f_frsize // 2 ** 20)
|
||||
except OSError:
|
||||
free = "unknown"
|
||||
return ("%s has not finished downloading in Steam (%d of %d MB downloaded, %d MB to unpack, %s free in %s); "
|
||||
"keep Steam open until it finishes" % ((c["SOURCES"][0],) + sizes + (free, library)))
|
||||
return "no Proton is installed yet; open Steam and keep it open until it has downloaded %s" % c["SOURCES"][0]
|
||||
|
||||
|
||||
def state_default():
|
||||
try:
|
||||
with open(STATE, encoding="utf-8") as f:
|
||||
@@ -155,8 +130,6 @@ def choose_tool(appid, current, available):
|
||||
for name in (default, c["TOOL"], c["TOOL_11"]):
|
||||
if name in available:
|
||||
return name, "the default ARM64 Proton"
|
||||
if newest:
|
||||
return newest, "the newest DroidDeck-Proton"
|
||||
return (sorted(available)[0], "the only one installed") if available else (None, None)
|
||||
|
||||
|
||||
@@ -542,10 +515,10 @@ def main(argv):
|
||||
target = fixed(program, root, prefix, compatdata)
|
||||
else:
|
||||
target = locate(program, root)
|
||||
available = startable(root, tools(root))
|
||||
available = tools(root)
|
||||
name, why = choose_tool(target.appid, mapping(root), available)
|
||||
if name is None:
|
||||
say(missing_proton(root))
|
||||
say("no Proton is installed yet; open Steam once and it is downloaded for you")
|
||||
return 69
|
||||
folder, command = available[name]
|
||||
os.makedirs(target.compatdata, exist_ok=True)
|
||||
|
||||
@@ -1104,19 +1104,14 @@ def app_manifest(steam_root, app):
|
||||
return None
|
||||
|
||||
|
||||
def manifest_number(tokens, key):
|
||||
quoted = '"%s"' % key.lower()
|
||||
def manifest_flags(tokens):
|
||||
for i in range(len(tokens) - 1):
|
||||
if tokens[i].lower() == quoted:
|
||||
if tokens[i].lower() == '"stateflags"':
|
||||
value = tokens[i + 1].strip('"')
|
||||
return int(value) if value.isdigit() else 0
|
||||
return 0
|
||||
|
||||
|
||||
def manifest_flags(tokens):
|
||||
return manifest_number(tokens, "StateFlags")
|
||||
|
||||
|
||||
def installed_manifest(path):
|
||||
try:
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
|
||||
@@ -106,8 +106,6 @@ class ProtonRunOptionsTest(Temp):
|
||||
self.write("Steam/compatibilitytools.d/droiddeck-proton-arm64/toolmanifest.vdf",
|
||||
'"manifest"\n{\n "commandline" "/droiddeck-proton %verb%"\n}\n')
|
||||
self.write("Steam/compatibilitytools.d/droiddeck-proton-arm64/droiddeck-proton", b"#!/bin/sh\n", 0o755)
|
||||
self.write("Steam/steamapps/common/Proton Experimental (ARM64)/proton", b"#!/bin/sh\n", 0o755)
|
||||
self.write("Steam/steamapps/common/Proton Experimental (ARM64)/files/bin-arm64/wine", b"#!/bin/sh\n", 0o755)
|
||||
self.entry = str(folder / "droiddeck-proton")
|
||||
patcher = mock.patch.dict(RUN, {"EXTRA_LIBRARIES": (), "SYSTEM_TOOLS": (), "STATE": str(self.tmp / "state.json"),
|
||||
"say": lambda message: None})
|
||||
|
||||
@@ -86,139 +86,6 @@ class ToolArguments(unittest.TestCase):
|
||||
self.assertEqual(switches, {name: kept.get(name) for name in switches})
|
||||
self.assertNotIn('OTHER', kept)
|
||||
|
||||
def test_start_without_steam_reaches_wine(self):
|
||||
text = LAUNCH.read_text()
|
||||
block = text[text.index('KEEP="'):text.index('export PATH=/system/bin')]
|
||||
env = dict(PATH=os.environ['PATH'], DROIDDECK_BIONIC_KEEP='PATH', DROIDDECK_NO_STEAM='1')
|
||||
result = subprocess.run(['sh', '-c', block + 'env\n'], env=env, text=True, capture_output=True, check=True)
|
||||
self.assertIn('DROIDDECK_NO_STEAM=1', result.stdout.splitlines())
|
||||
|
||||
|
||||
def lsteamclient(**env):
|
||||
text = LAUNCH.read_text()
|
||||
on = re.search(r'^on\(\) \{.*\}$', text, re.M).group(0)
|
||||
last = 'export WINE_LSTEAMCLIENT=${WINE_LSTEAMCLIENT:-1}\n'
|
||||
block = text[text.index('# A game set to start without Steam'):text.index(last) + len(last)]
|
||||
script = on + '\n' + block + 'echo "value=$WINE_LSTEAMCLIENT"\n'
|
||||
result = subprocess.run(['sh', '-c', script], env=dict(env, PATH=os.environ['PATH']),
|
||||
text=True, capture_output=True, check=True)
|
||||
return result.stdout.splitlines()[-1].split('=', 1)[1]
|
||||
|
||||
|
||||
class SteamBridge(unittest.TestCase):
|
||||
def test_games_with_steam_use_lsteamclient(self):
|
||||
self.assertEqual('1', lsteamclient())
|
||||
self.assertEqual('1', lsteamclient(DROIDDECK_NO_STEAM='0'))
|
||||
|
||||
def test_a_game_started_without_steam_keeps_its_own_steamclient(self):
|
||||
for value in ('1', 'on', 'true', 'yes'):
|
||||
self.assertEqual('0', lsteamclient(DROIDDECK_NO_STEAM=value))
|
||||
|
||||
def test_the_players_value_wins(self):
|
||||
self.assertEqual('1', lsteamclient(DROIDDECK_NO_STEAM='1', WINE_LSTEAMCLIENT='1'))
|
||||
self.assertEqual('0', lsteamclient(WINE_LSTEAMCLIENT='0'))
|
||||
|
||||
|
||||
DDC_NAMES = ('xinput1_1', 'xinput1_2', 'xinput1_3', 'xinput1_4', 'xinput9_1_0', 'xinputuap')
|
||||
|
||||
|
||||
class DirectController(unittest.TestCase):
|
||||
"""launch.sh's dd-directcontroller step on a prefix laid out as prepare_prefix leaves it (links to the tool)."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root)
|
||||
self.tool, self.compat = self.root / 'tool', self.root / 'compat'
|
||||
self.f = self.tool / 'files'
|
||||
self.win = self.compat / 'pfx/drive_c/windows'
|
||||
for ours, wine, pfx in (('arm64x', 'aarch64-windows', 'system32'), ('i386', 'i386-windows', 'syswow64')):
|
||||
(self.tool / 'bionic/dd-directcontroller' / ours).mkdir(parents=True)
|
||||
(self.f / 'lib/wine' / wine).mkdir(parents=True)
|
||||
(self.win / pfx).mkdir(parents=True)
|
||||
for n in DDC_NAMES:
|
||||
(self.tool / 'bionic/dd-directcontroller' / ours / f'{n}.dll').write_bytes(f'MZ dd-directcontroller: {ours} {n}'.encode())
|
||||
builtin = self.f / 'lib/wine' / wine / f'{n}.dll'
|
||||
builtin.write_bytes(f'MZ Wine builtin DLL {wine} {n}'.encode())
|
||||
(self.win / pfx / f'{n}.dll').symlink_to(builtin)
|
||||
|
||||
def run_step(self, **env):
|
||||
text = LAUNCH.read_text()
|
||||
on = re.search(r'^on\(\) \{.*\}$', text, re.M).group(0)
|
||||
on += '\n' + re.search(r'^is_builtin\(\) \{.*\}$', text, re.M).group(0)
|
||||
start = text.index('# dd-directcontroller: a game set to start')
|
||||
end = text.index("dd-directcontroller off: Wine's xinput again\"\nfi\n") + len("dd-directcontroller off: Wine's xinput again\"\nfi\n")
|
||||
script = on + '\n' + text[start:end] + 'echo "overrides=$WINEDLLOVERRIDES"; echo "control=${DD_DIRECTCONTROLLER_CONTROL:-}"\n'
|
||||
(self.root / 'session/dev/input').mkdir(parents=True, exist_ok=True)
|
||||
base = dict(PATH=os.environ['PATH'], TOOL=str(self.tool), COMPAT=str(self.compat), F=str(self.f),
|
||||
WINEDLLOVERRIDES='d3d11=n,b', FAKE_EVDEV_DIR=str(self.root / 'session/dev/input'))
|
||||
result = subprocess.run(['sh', '-c', script], env=dict(base, **env), text=True, capture_output=True, check=True)
|
||||
return result.stdout
|
||||
|
||||
def builtins_untouched(self):
|
||||
for wine in ('aarch64-windows', 'i386-windows'):
|
||||
for n in DDC_NAMES:
|
||||
self.assertEqual(f'MZ Wine builtin DLL {wine} {n}', (self.f / 'lib/wine' / wine / f'{n}.dll').read_text())
|
||||
|
||||
def test_a_game_started_without_steam_gets_the_dlls_as_copies(self):
|
||||
out = self.run_step(DROIDDECK_NO_STEAM='1')
|
||||
for ours, pfx in (('arm64x', 'system32'), ('i386', 'syswow64')):
|
||||
for n in DDC_NAMES:
|
||||
t = self.win / pfx / f'{n}.dll'
|
||||
self.assertFalse(t.is_symlink())
|
||||
self.assertEqual(f'MZ dd-directcontroller: {ours} {n}', t.read_text())
|
||||
self.assertIn('Wine builtin DLL', (self.win / pfx / 'dd-directcontroller-wine-xinput.dll').read_text())
|
||||
self.builtins_untouched()
|
||||
self.assertIn('overrides=d3d11=n,b;xinput1_1,xinput1_2,xinput1_3,xinput1_4,xinput9_1_0,xinputuap=n,b', out)
|
||||
mode = self.root / 'session/dev/dd-directcontroller.mode'
|
||||
self.assertEqual('1', mode.read_text().strip())
|
||||
self.assertIn(f'control={mode}', out)
|
||||
self.assertIn('dd-directcontroller on (starts direct)', out)
|
||||
|
||||
def test_switched_off_puts_wines_links_back(self):
|
||||
self.run_step(DROIDDECK_NO_STEAM='1')
|
||||
out = self.run_step()
|
||||
for wine, pfx in (('aarch64-windows', 'system32'), ('i386-windows', 'syswow64')):
|
||||
for n in DDC_NAMES:
|
||||
t = self.win / pfx / f'{n}.dll'
|
||||
self.assertTrue(t.is_symlink())
|
||||
self.assertEqual(self.f / 'lib/wine' / wine / f'{n}.dll', Path(os.readlink(t)))
|
||||
self.assertFalse((self.win / pfx / 'dd-directcontroller-wine-xinput.dll').exists())
|
||||
self.builtins_untouched()
|
||||
self.assertIn('overrides=d3d11=n,b\n', out)
|
||||
self.assertIn("dd-directcontroller off: Wine's xinput again", out)
|
||||
|
||||
def test_dd_directcontroller_0_starts_in_pass_through(self):
|
||||
out = self.run_step(DROIDDECK_NO_STEAM='1', DD_DIRECTCONTROLLER='0')
|
||||
self.assertFalse((self.win / 'system32/xinput1_3.dll').is_symlink())
|
||||
self.assertEqual('0', (self.root / 'session/dev/dd-directcontroller.mode').read_text().strip())
|
||||
self.assertIn('dd-directcontroller on (starts pass-through)', out)
|
||||
|
||||
def test_without_a_controller_folder_it_stays_direct(self):
|
||||
text = self.run_step(DROIDDECK_NO_STEAM='1', FAKE_EVDEV_DIR='')
|
||||
self.assertIn('control=\n', text)
|
||||
self.assertIn('dd-directcontroller on (starts direct (no mode file))', text)
|
||||
|
||||
def test_a_foreign_native_xinput_is_kept_when_installing(self):
|
||||
t = self.win / 'system32/xinput1_3.dll'
|
||||
t.unlink()
|
||||
t.write_bytes(b'MZ someone else')
|
||||
copy = self.win / 'system32/xinput1_4.dll'
|
||||
copy.unlink()
|
||||
copy.write_bytes(b'MZ Wine builtin DLL copied by Proton')
|
||||
out = self.run_step(DROIDDECK_NO_STEAM='1')
|
||||
self.assertEqual('MZ someone else', t.read_text())
|
||||
self.assertIn("kept system32/xinput1_3.dll (not Wine's)", out)
|
||||
self.assertEqual('MZ dd-directcontroller: arm64x xinput1_4', copy.read_text())
|
||||
self.builtins_untouched()
|
||||
|
||||
def test_a_native_xinput_that_is_not_ours_stays(self):
|
||||
t = self.win / 'system32/xinput1_3.dll'
|
||||
t.unlink()
|
||||
t.write_bytes(b'MZ someone else')
|
||||
out = self.run_step()
|
||||
self.assertEqual('MZ someone else', t.read_text())
|
||||
self.assertNotIn('dd-directcontroller off', out)
|
||||
|
||||
|
||||
class SessionLogs(unittest.TestCase):
|
||||
SESSION = '/data/user/0/com.droiddeck.launcher/files/logs/2026-11-22-09-steam'
|
||||
|
||||
@@ -698,72 +698,7 @@ class ProtonRunTest(Temp):
|
||||
self.assertIsNone(OPEN["game_folder"](str(program)))
|
||||
self.assertEqual(ran, [[OPEN["STEAM_LAUNCH"], "desktop", "413150"]])
|
||||
|
||||
def depot(self, name="Proton 11.0 (ARM64)"):
|
||||
self.write("Steam/steamapps/common/%s/proton" % name, b"#!/bin/sh\n", 0o755)
|
||||
self.write("Steam/steamapps/common/%s/files/bin-arm64/wine" % name, b"#!/bin/sh\n", 0o755)
|
||||
|
||||
def own_build(self, version):
|
||||
folder = "compatibilitytools.d/DroidDeck-Proton %s" % version
|
||||
self.write("Steam/%s/compatibilitytool.vdf" % folder, TOOL_VDF % ("DroidDeck-Proton-" + version, version, "windows"))
|
||||
self.write("Steam/%s/toolmanifest.vdf" % folder, '"manifest"\n{\n "commandline" "/proton %verb%"\n}\n')
|
||||
self.write("Steam/%s/proton" % folder, b"#!/bin/sh\n", 0o755)
|
||||
return "DroidDeck-Proton-" + version
|
||||
|
||||
def test_a_wrapper_without_its_depot_gives_way_to_an_installed_proton(self):
|
||||
newest = [self.own_build(v) for v in ("11-12.2", "11-12.3")][-1]
|
||||
available = RUN["startable"](str(self.root), RUN["tools"](str(self.root)))
|
||||
self.assertEqual(sorted(available), ["DroidDeck-Proton-11-12.2", newest])
|
||||
current = RUN["mapping"](str(self.root))
|
||||
self.assertEqual(RUN["choose_tool"]("70", current, available), (newest, "the newest DroidDeck-Proton"))
|
||||
self.assertEqual(RUN["choose_tool"]("413150", current, available), (newest, "the newest DroidDeck-Proton"))
|
||||
self.assertEqual(RUN["choose_tool"]("70", {"0": "DroidDeck-Proton-11-12.2"}, available),
|
||||
("DroidDeck-Proton-11-12.2", "Steam's default"))
|
||||
|
||||
def test_a_wrapper_with_its_depot_is_still_steams_choice(self):
|
||||
self.own_build("11-12.3")
|
||||
self.depot()
|
||||
available = RUN["startable"](str(self.root), RUN["tools"](str(self.root)))
|
||||
self.assertIn("droiddeck-proton-arm64", available)
|
||||
self.assertIn("droiddeck-proton-11-arm64", available)
|
||||
current = RUN["mapping"](str(self.root))
|
||||
self.assertEqual(RUN["choose_tool"]("70", current, available), ("droiddeck-proton-arm64", "Steam's default"))
|
||||
self.assertEqual(RUN["choose_tool"]("413150", current, available), ("droiddeck-proton-11-arm64", "Steam's choice for this title"))
|
||||
|
||||
def test_each_wrapper_needs_its_own_depot(self):
|
||||
self.depot("Proton Experimental (ARM64)")
|
||||
available = RUN["startable"](str(self.root), RUN["tools"](str(self.root)))
|
||||
self.assertEqual(sorted(available), ["droiddeck-proton-arm64"])
|
||||
|
||||
def test_an_unfinished_depot_is_not_started(self):
|
||||
self.write("Steam/steamapps/common/Proton 11.0 (ARM64)/files/bin-arm64/wine", b"#!/bin/sh\n", 0o755)
|
||||
self.assertEqual(RUN["startable"](str(self.root), RUN["tools"](str(self.root))), {})
|
||||
|
||||
def test_with_no_runnable_proton_the_launch_stops_with_the_download_state(self):
|
||||
program = self.game("413150", "Stardew Valley", "Stardew Valley.exe")
|
||||
self.write("Steam/steamapps/appmanifest_4427310.acf", '"AppState"\n{\n "appid" "4427310"\n'
|
||||
' "BytesToDownload" "288773824"\n "BytesDownloaded" "37081024"\n "BytesToStage" "1370855407"\n}\n')
|
||||
said = []
|
||||
with mock.patch.dict(os.environ, {"STEAM_COMPAT_CLIENT_INSTALL_PATH": str(self.root)}), \
|
||||
mock.patch.object(RUN["os"], "execve") as execve, mock.patch.dict(RUN, {"say": said.append}):
|
||||
code = RUN["main"]([str(program)])
|
||||
self.assertEqual(code, 69)
|
||||
execve.assert_not_called()
|
||||
self.assertRegex(said[-1], r"^Proton Experimental \(ARM64\) has not finished downloading in Steam "
|
||||
r"\(35 of 275 MB downloaded, 1307 MB to unpack, \d+ MB free in ")
|
||||
self.assertFalse((self.root / "steamapps/compatdata/413150").exists())
|
||||
|
||||
def test_with_no_proton_at_all_the_launch_says_what_to_download(self):
|
||||
program = self.game("413150", "Stardew Valley", "Stardew Valley.exe")
|
||||
said = []
|
||||
with mock.patch.dict(os.environ, {"STEAM_COMPAT_CLIENT_INSTALL_PATH": str(self.root)}), \
|
||||
mock.patch.object(RUN["os"], "execve") as execve, mock.patch.dict(RUN, {"say": said.append}):
|
||||
self.assertEqual(RUN["main"]([str(program)]), 69)
|
||||
execve.assert_not_called()
|
||||
self.assertEqual(said[-1], "no Proton is installed yet; open Steam and keep it open until it has downloaded "
|
||||
"Proton Experimental (ARM64)")
|
||||
|
||||
def test_the_tool_is_started_as_steam_starts_it(self):
|
||||
self.depot()
|
||||
program = self.game("413150", "Stardew Valley", "Stardew Valley.exe")
|
||||
calls = []
|
||||
with mock.patch.dict(os.environ, {"STEAM_COMPAT_CLIENT_INSTALL_PATH": str(self.root)}), \
|
||||
@@ -778,7 +713,6 @@ class ProtonRunTest(Temp):
|
||||
self.assertTrue((self.root / "steamapps/compatdata/413150").is_dir())
|
||||
|
||||
def run_main(self, argv):
|
||||
self.depot()
|
||||
calls, dirs = [], []
|
||||
with mock.patch.dict(os.environ, {"STEAM_COMPAT_CLIENT_INSTALL_PATH": str(self.root)}), \
|
||||
mock.patch.object(RUN["os"], "execve", lambda *a: calls.append(a)), \
|
||||
|
||||
@@ -221,6 +221,21 @@ class DroidDeckProtonDefaultTest(unittest.TestCase):
|
||||
{"default": X86["name"], "written": X86["name"], "source": "update"}, [("0", X86["name"])], [VALVE, X86])
|
||||
self.assertEqual((default, mapping), (TOOL, {"0": TOOL}))
|
||||
|
||||
def test_titles_an_older_app_moved_to_the_x86_64_build_return_to_arm64(self):
|
||||
arm = dict(NEW, name="DroidDeck-Proton-11-14.2", display="DroidDeck-Proton 11-14.2", dir="DroidDeck-Proton 11-14.2")
|
||||
unflagged = {k: v for k, v in X86.items() if k != "x86_64"}
|
||||
left = {"default": X86["name"], "written": X86["name"], "source": "update", "owned": ["2596113170"],
|
||||
"own_builds": [arm["name"], X86["name"]], "tools": [VALVE, unflagged],
|
||||
"auto": {"42": X86["name"], "2596113170": X86["name"]}}
|
||||
mapping = [("0", X86["name"]), ("42", X86["name"]), ("2596113170", X86["name"]), ("44", X86["name"]), ("45", GE["name"])]
|
||||
default, mapping, state = self.run_default(left, mapping, [VALVE, X86, GE], ["42", "44", "45"])
|
||||
self.assertEqual(default, TOOL)
|
||||
self.assertEqual(mapping, {"0": TOOL, "42": TOOL, "2596113170": TOOL, "44": X86["name"], "45": GE["name"]})
|
||||
default, mapping, state = self.run_default(state, [(app, name) for app, name in mapping.items()], [VALVE, arm, X86, GE],
|
||||
["42", "44", "45"])
|
||||
self.assertEqual(default, arm["name"])
|
||||
self.assertEqual(mapping, {"0": arm["name"], "42": arm["name"], "2596113170": arm["name"], "44": X86["name"], "45": GE["name"]})
|
||||
|
||||
def test_an_x86_64_default_the_user_picked_is_kept(self):
|
||||
for source in ("app", "steam"):
|
||||
default, mapping, _ = self.run_default(
|
||||
|
||||
@@ -13,7 +13,6 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
from unittest import mock
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -2500,65 +2499,6 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertIn("exe: first.exe", (Path(first["PROTON_LOG_DIR"]) / "launch.txt").read_text())
|
||||
self.assertIn("exe: second.exe", (Path(second["PROTON_LOG_DIR"]) / "launch.txt").read_text())
|
||||
|
||||
def test_audio_probe_watches_this_launch(self):
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch("subprocess.Popen") as popen:
|
||||
env = {"DD_GAME_LOGS": "1", "DD_DEBUG_DIR": tmp}
|
||||
result = MODULE["game_logs"](["/proton", "waitforexitandrun", "game.exe"], env, "42", now=0)
|
||||
self.assertEqual(popen.call_args.args[0], [
|
||||
"sh", "-c", MODULE["AUDIO_STREAMS_PROBE"], "audio", result["PROTON_LOG_DIR"], str(os.getpid()), "20", "60",
|
||||
])
|
||||
|
||||
def test_audio_probe_ends_with_the_game_and_keeps_its_samples_while_it_runs(self):
|
||||
probe = ["sh", "-c", MODULE["AUDIO_STREAMS_PROBE"], "audio"]
|
||||
|
||||
def samples(folder):
|
||||
path = Path(folder) / "audio-streams.txt"
|
||||
return sum(line.startswith("== ") for line in path.read_text().splitlines()) if path.exists() else 0
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "60"])
|
||||
try:
|
||||
subprocess.run(probe + [tmp, str(game.pid), "1", "2"], timeout=15, check=True)
|
||||
self.assertEqual(samples(tmp), 2)
|
||||
finally:
|
||||
game.kill()
|
||||
game.wait()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "60"])
|
||||
running = subprocess.Popen(probe + [tmp, str(game.pid), "1", "600"])
|
||||
try:
|
||||
deadline = time.monotonic() + 15
|
||||
while samples(tmp) < 1 and time.monotonic() < deadline:
|
||||
time.sleep(0.1)
|
||||
self.assertEqual(samples(tmp), 1)
|
||||
game.kill()
|
||||
game.wait()
|
||||
self.assertEqual(running.wait(timeout=10), 0)
|
||||
self.assertEqual(samples(tmp), 1)
|
||||
finally:
|
||||
game.kill()
|
||||
game.wait()
|
||||
running.kill()
|
||||
running.wait()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
ended = subprocess.Popen(["true"])
|
||||
ended.wait()
|
||||
subprocess.run(probe + [tmp, str(ended.pid), "20", "60"], timeout=10, check=True)
|
||||
self.assertEqual(samples(tmp), 0)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "0.5"])
|
||||
running = subprocess.Popen(probe + [tmp, str(game.pid), "1"])
|
||||
try:
|
||||
game.wait()
|
||||
self.assertEqual(running.wait(timeout=10), 0)
|
||||
self.assertEqual(samples(tmp), 0)
|
||||
finally:
|
||||
running.kill()
|
||||
running.wait()
|
||||
|
||||
def test_open_driver_pairs_report_the_drivers_own_vkd3d_caps(self):
|
||||
apply = MODULE["apply_config"]
|
||||
config = {"version": 1, "shared": {"VKD3D_FEATURE_LEVEL": "12_2", "VKD3D_SHADER_MODEL": "6_9"},
|
||||
|
||||
Reference in new issue
Block a user