mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
Fix: Remote Play gets the Steam Deck, Steam Deck Controller, Stream Controller, and touch controls (#2033)
* fix: Remote Play gets the Steam Deck controller Steam's Remote Play client reads the controller itself from its own streaming_client process. The input preload only exposed the virtual Deck controller (and the DualShock 4 / DualSense pads that share its code) to the process named steam, so in Steam Deck controller mode streaming_client was refused /dev/hidraw16 and the stream got no input: streaming_clien: deck: /dev/hidraw16 refused: not the Steam client streaming_client now sees the same Deck, DualShock 4 and DualSense pads as Steam. Each opener gets its own report stream from the read-only ring, so the two processes do not compete for input. The Steam Controller paths stay Steam-only: the paired controller's feature and output slot is serialised only within one process. Fixes #1860 * fix: Remote Play also gets the Steam Controller and touch controls streaming_client now opens the Steam Controller pads (the app's emulated one and a paired controller) and Steam's touch controller, like the Steam Deck pad. A paired controller's feature request and output slots, and the touch controller's state, are shared with the app and written under a seqlock that expects one writer. Their writers now also take a flock on a lock file in the hook directory, so Steam and streaming_client take turns. touch_state() was a template holding its own static mutex, so each caller had a separate one; it now shares a single mutex. The pad type and touch plug watchers run in streaming_client too, so it gets the udev events for mode switches and replugs; those only reach the process that injects them. Poking /dev watchers and moving event0 on the shared filesystem stay with Steam, so they happen once. * fix: the shared slot lock fails safe and never waits forever If the lock file cannot be opened or locked, ProcessSlotLock used to carry on unlocked. Steam alone is still a single writer then, exactly as before streaming_client could open these devices, so it carries on; streaming_client now leaves the paired controller's feature and output slots and the touch state alone instead (feature reads fail with EIO). The first failure is logged. The wait for the lock is now bounded: a session freeze can stop the process holding it, and writers wait with controller_mutex held, so an unbounded flock could stall all input in the other process. Feature reads wait up to their 500 ms reply timeout, outputs 100 ms and touch state 20 ms. When the deadline passes the lock is held by the other process, so neither proceeds; the operation is skipped and logged. * fix: Steam no longer turns motion off under its Remote Play client Steam and streaming_client both set the Deck pad's IMU mode, and both wrote the one word Android reads to decide whether to feed the gyro. Steam keeps toggling its own mode during a stream, so it could switch motion off while the Remote Play layout needed it, and the client never re-sent an unchanged mode. Each process now has its own word. Android reads motion while either wants it, and ignores the Remote Play word once that process is gone. * fix: Remote Play decides motion while Steam has set no mode Until Steam published its IMU mode, Android reported the mode as unknown without reading the Remote Play client's word, so a Remote Play request to stop motion had no effect. The word that has been set now decides, and the mode stays unknown only while neither process has set one. The rule moves into ImuModes so it can be tested on the JVM. --------- Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
1 parent
a4558c841a
commit
5dd973587f
5 files changed
+376
-24
No files matched your search
@@ -82,6 +82,8 @@ public class FakeInputWriter {
|
||||
private static final int PAD_TYPE_OFFSET = IMU_OFFSET + 44;
|
||||
private static final int PAD_TYPE_SET = 0x80000000;
|
||||
private static final int LATENCY_OFFSET = IMU_OFFSET + 48;
|
||||
private static final int REMOTE_IMU_MODE_OFFSET = IMU_OFFSET + 52;
|
||||
private static final int REMOTE_IMU_PID_OFFSET = IMU_OFFSET + 56;
|
||||
public static final int LATENCY_CONTROLLER = 1;
|
||||
public static final int LATENCY_TOUCH = 2;
|
||||
private static volatile int latency = 0;
|
||||
@@ -231,6 +233,8 @@ public class FakeInputWriter {
|
||||
}
|
||||
data.putInt(IMU_OFFSET, 0);
|
||||
data.putInt(IMU_MODE_OFFSET, 0);
|
||||
data.putInt(REMOTE_IMU_MODE_OFFSET, 0);
|
||||
data.putInt(REMOTE_IMU_PID_OFFSET, 0);
|
||||
data.putLong(IMU_SEQ_OFFSET, 0L);
|
||||
for (int i = 0; i < 12; i++) {
|
||||
data.putShort(IMU_ACCEL_OFFSET + (i * 2), (short) 0);
|
||||
@@ -494,8 +498,11 @@ public class FakeInputWriter {
|
||||
if (ringSlot == null) return -1;
|
||||
synchronized (ringSlot) {
|
||||
ByteBuffer ring = ringSlot.data;
|
||||
int value = ring == null ? 0 : ring.getInt(IMU_MODE_OFFSET);
|
||||
return value < 0 ? value & 0xffff : -1;
|
||||
if (ring == null) return 0;
|
||||
int remote = ring.getInt(REMOTE_IMU_MODE_OFFSET);
|
||||
int pid = ring.getInt(REMOTE_IMU_PID_OFFSET);
|
||||
return ImuModes.combine(ring.getInt(IMU_MODE_OFFSET), remote,
|
||||
remote < 0 && pid > 0 && new File("/proc/" + pid).exists());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.droiddeck.launcher.input;
|
||||
|
||||
final class ImuModes {
|
||||
private ImuModes() {}
|
||||
|
||||
// Steam and its Remote Play client each keep their own mode word, with the top bit set once written. Motion is
|
||||
// read while either process wants it, and a word that has not been set leaves the choice to the other one.
|
||||
// -1 means neither has set a mode yet.
|
||||
static int combine(int steam, int remote, boolean remoteRunning) {
|
||||
boolean remoteSet = remote < 0 && remoteRunning;
|
||||
if (steam >= 0 && !remoteSet) return -1;
|
||||
return ((steam < 0 ? steam : 0) | (remoteSet ? remote : 0)) & 0xffff;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user