The last of the Winlator lineage rewritten out; rumble on the phone

The five files the audit measured as Winlator's are replaced: a one-method callback interface by
java.util.function.Consumer, the component base by SessionPart (attach an application context,
start, stop), the environment list by HostEnvironment, the process starter by HostProcess, and
the pad's state holder by PadState with named sticks, triggers, directions and buttons. The
frame-generation tree is framegen/ (its contents were never Winlator's: lsfg-vk's port and
Bannerlator's Win-FG), the log tags are the app's, and the fake pad's rumble socket is now one
the app actually serves: RumbleComponent turns a game's force-feedback effects into the phone's
vibrator, which used to go nowhere. The two design notes describing Bannerlator's X11 path are
gone, and the README and credits say what is whose.
This commit is contained in:
The412Banner committed 2026-09-23 09:12:14 -04:00
1 parent 2fb79735c3
commit 9cfb96e358
84 files changed
+493 -1771

No files matched your search

@@ -64,8 +64,8 @@ public class FakeInputWriter {
BTN_SELECT, BTN_START, BTN_THUMBL, BTN_THUMBR,
BTN_MODE
};
/** Bit 10 of the snapshot word. The first ten are GamepadState's own bit order; the Steam
* button is not, because GamepadState keeps 10 and 11 for the triggers. */
/** Bit 10 of the snapshot word. The first ten are PadState's own bit order; the Steam
* button is not, because PadState keeps 10 and 11 for the triggers. */
private static final int SNAPSHOT_IDX_MODE = 10;
private static final int EVENT_SIZE = 24;
@@ -595,7 +595,7 @@ public class FakeInputWriter {
writeEvent(EV_KEY, BUTTON_MAP[idx], pressed ? 1 : 0);
}
public synchronized void writeGamepadState(GamepadState state) {
public synchronized void writePad(PadState state) {
if (!isOpen && !open())
return;
@@ -613,19 +613,19 @@ public class FakeInputWriter {
// Buttons
for (int i = 0; i < 10; i++) {
writeButton(i, state.isPressed((byte) i));
writeButton(i, state.isDown(i));
}
// The Steam button. In a Linux session this is what opens the client's own in-game menu,
// and the client looks for it where an Xbox pad keeps it: evdev BTN_MODE, which SDL then
// reports as button 8 - exactly the "guide:b8" in the mapping Steam writes for this pad.
writeButton(SNAPSHOT_IDX_MODE,
state.isPressed(GamepadState.IDX_BUTTON_MODE));
state.isDown(PadState.GUIDE));
// Sticks
int lx = (int) (state.thumbLX * 32767);
int ly = (int) (state.thumbLY * 32767);
int rx = (int) (state.thumbRX * 32767);
int ry = (int) (state.thumbRY * 32767);
int lx = (int) (state.leftX * 32767);
int ly = (int) (state.leftY * 32767);
int rx = (int) (state.rightX * 32767);
int ry = (int) (state.rightY * 32767);
// The fake evdev ring is event-queue semantics, so unchanged axes normally
// stay silent; forceResend overrides that to emit a complete keyframe.
@@ -647,8 +647,8 @@ public class FakeInputWriter {
}
// L2 and R2 (Triggers)
int tl = (int) (state.triggerL * 255);
int tr = (int) (state.triggerR * 255);
int tl = (int) (state.leftTrigger * 255);
int tr = (int) (state.rightTrigger * 255);
if (forceResend || tl != prevTriggerL) {
prevTriggerL = tl;
writeEvent(EV_ABS, ABS_BRAKE, tl);
@@ -659,8 +659,8 @@ public class FakeInputWriter {
}
// D-pad
int hatX = state.dpad[3] ? -1 : (state.dpad[1] ? 1 : 0);
int hatY = state.dpad[0] ? -1 : (state.dpad[2] ? 1 : 0);
int hatX = state.hatX();
int hatY = state.hatY();
if (forceResend || hatX != prevHatX) {
prevHatX = hatX;
writeEvent(EV_ABS, ABS_HAT0X, hatX);
@@ -1,58 +0,0 @@
package com.steamdeck.launcher.input;
public class GamepadState {
/** Bit index of the Steam/Guide button; 0-9 are the face/shoulder/stick buttons. */
public static final byte IDX_BUTTON_MODE = 12;
public float thumbLX = 0;
public float thumbLY = 0;
public float thumbRX = 0;
public float thumbRY = 0;
public float triggerL = 0;
public float triggerR = 0;
public final boolean[] dpad = new boolean[4];
public short buttons = 0;
public void setPressed(int buttonIdx, boolean pressed) {
int flag = 1<<buttonIdx;
if (pressed) {
buttons |= flag;
}
else buttons &= ~flag;
}
public boolean isPressed(int buttonIdx) {
return (buttons & (1<<buttonIdx)) != 0;
}
public byte getDPadX() {
return (byte)(dpad[1] ? 1 : (dpad[3] ? -1 : 0));
}
public byte getDPadY() {
return (byte)(dpad[0] ? -1 : (dpad[2] ? 1 : 0));
}
public void copy(GamepadState other) {
thumbLX = other.thumbLX;
thumbLY = other.thumbLY;
thumbRX = other.thumbRX;
thumbRY = other.thumbRY;
triggerL = other.triggerL;
triggerR = other.triggerR;
buttons = other.buttons;
System.arraycopy(other.dpad, 0, dpad, 0, dpad.length);
}
public void reset() {
thumbLX = 0;
thumbLY = 0;
thumbRX = 0;
thumbRY = 0;
triggerL = 0;
triggerR = 0;
buttons = 0;
java.util.Arrays.fill(dpad, false);
}
}
@@ -30,9 +30,9 @@ class OnScreenControls(context: Context, private val pad: PadBridge) : View(cont
private class Control(
val id: String,
val label: String,
/** Bit index in GamepadState, or -1. */
/** A PadState button number, or -1. */
val button: Int,
/** Index into GamepadState.dpad, or -1. */
/** A d-pad direction (0 up, 1 right, 2 down, 3 left), or -1. */
val dpad: Int,
/** 0 = left stick, 1 = right stick, -1 = a button. */
val stick: Int,
@@ -83,7 +83,7 @@ class OnScreenControls(context: Context, private val pad: PadBridge) : View(cont
Control("select", "⧉", 6, -1, -1, dp(20f)),
Control("start", "☰", 7, -1, -1, dp(20f)),
// The client's own in-game menu; the interposer publishes it as BTN_MODE.
Control("guide", "◉", GamepadState.IDX_BUTTON_MODE.toInt(), -1, -1, dp(22f)),
Control("guide", "◉", PadState.GUIDE, -1, -1, dp(22f)),
Control("qam", "⋯", -1, -1, -1, dp(22f)),
)
@@ -318,10 +318,13 @@ class OnScreenControls(context: Context, private val pad: PadBridge) : View(cont
val held = control.pressedBy != -1
when {
control.stick >= 0 && !control.dirty -> {}
control.stick == 0 -> { state.thumbLX = control.kx / control.radius; state.thumbLY = control.ky / control.radius; control.dirty = false }
control.stick == 1 -> { state.thumbRX = control.kx / control.radius; state.thumbRY = control.ky / control.radius; control.dirty = false }
control.dpad >= 0 -> state.dpad[control.dpad] = held
control.button >= 0 -> state.setPressed(control.button, held)
control.stick == 0 -> { state.leftX = control.kx / control.radius; state.leftY = control.ky / control.radius; control.dirty = false }
control.stick == 1 -> { state.rightX = control.kx / control.radius; state.rightY = control.ky / control.radius; control.dirty = false }
control.dpad == 0 -> state.up = held
control.dpad == 1 -> state.right = held
control.dpad == 2 -> state.down = held
control.dpad == 3 -> state.left = held
control.button >= 0 -> state.press(control.button, held)
}
}
}
@@ -15,7 +15,7 @@ import java.io.File;
* <p>Android hands a gamepad to the foreground activity as key and motion events; the Steam client
* inside the runtime never sees that. What it does scan is {@code /dev/input}, which the session's
* interposer (libfakeinput.so) serves out of the shared-memory rings written here. So the path is:
* Android event → {@link GamepadState} → {@link FakeInputWriter} ring → interposer → evdev node →
* Android event → {@link PadState} → {@link FakeInputWriter} ring → interposer → evdev node →
* SDL → Big Picture.
*
* <p>The identity the interposer reports is an Xbox 360 pad, which is what makes SDL apply a known
@@ -31,8 +31,8 @@ public final class PadBridge {
private static final long QAM_GUIDE_TAIL_MS = 40;
private final FakeInputWriter writer;
private final GamepadState state = new GamepadState();
private final GamepadState effectiveState = new GamepadState();
private final PadState state = new PadState();
private final PadState effectiveState = new PadState();
private final Handler mainHandler = new Handler(Looper.getMainLooper());
private boolean open;
private boolean systemGuidePressed;
@@ -61,8 +61,8 @@ public final class PadBridge {
qamSyntheticAPressed = false;
qamChordGeneration++;
if (open) {
state.reset();
writer.writeGamepadState(state);
state.clear();
writer.writePad(state);
writer.close();
open = false;
}
@@ -92,28 +92,28 @@ public final class PadBridge {
if (!isFromController(event.getDevice())) return false;
boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BUTTON_A: state.setPressed(0, pressed); break;
case KeyEvent.KEYCODE_BUTTON_B: state.setPressed(1, pressed); break;
case KeyEvent.KEYCODE_BUTTON_X: state.setPressed(2, pressed); break;
case KeyEvent.KEYCODE_BUTTON_Y: state.setPressed(3, pressed); break;
case KeyEvent.KEYCODE_BUTTON_L1: state.setPressed(4, pressed); break;
case KeyEvent.KEYCODE_BUTTON_R1: state.setPressed(5, pressed); break;
case KeyEvent.KEYCODE_BUTTON_A: state.press(0, pressed); break;
case KeyEvent.KEYCODE_BUTTON_B: state.press(1, pressed); break;
case KeyEvent.KEYCODE_BUTTON_X: state.press(2, pressed); break;
case KeyEvent.KEYCODE_BUTTON_Y: state.press(3, pressed); break;
case KeyEvent.KEYCODE_BUTTON_L1: state.press(4, pressed); break;
case KeyEvent.KEYCODE_BUTTON_R1: state.press(5, pressed); break;
case KeyEvent.KEYCODE_BUTTON_SELECT:
case KeyEvent.KEYCODE_BACK: state.setPressed(6, pressed); break;
case KeyEvent.KEYCODE_BACK: state.press(6, pressed); break;
case KeyEvent.KEYCODE_BUTTON_START:
case KeyEvent.KEYCODE_MENU: state.setPressed(7, pressed); break;
case KeyEvent.KEYCODE_BUTTON_THUMBL: state.setPressed(8, pressed); break;
case KeyEvent.KEYCODE_BUTTON_THUMBR: state.setPressed(9, pressed); break;
case KeyEvent.KEYCODE_MENU: state.press(7, pressed); break;
case KeyEvent.KEYCODE_BUTTON_THUMBL: state.press(8, pressed); break;
case KeyEvent.KEYCODE_BUTTON_THUMBR: state.press(9, pressed); break;
// The client's own in-game menu is opened by this one; the interposer publishes it as
// BTN_MODE, which SDL reports as the "guide" button.
case KeyEvent.KEYCODE_BUTTON_MODE:
case KeyEvent.KEYCODE_HOME: state.setPressed(GamepadState.IDX_BUTTON_MODE, pressed); break;
case KeyEvent.KEYCODE_BUTTON_L2: state.triggerL = pressed ? 1f : 0f; break;
case KeyEvent.KEYCODE_BUTTON_R2: state.triggerR = pressed ? 1f : 0f; break;
case KeyEvent.KEYCODE_DPAD_UP: state.dpad[0] = pressed; break;
case KeyEvent.KEYCODE_DPAD_RIGHT: state.dpad[1] = pressed; break;
case KeyEvent.KEYCODE_DPAD_DOWN: state.dpad[2] = pressed; break;
case KeyEvent.KEYCODE_DPAD_LEFT: state.dpad[3] = pressed; break;
case KeyEvent.KEYCODE_HOME: state.press(PadState.GUIDE, pressed); break;
case KeyEvent.KEYCODE_BUTTON_L2: state.leftTrigger = pressed ? 1f : 0f; break;
case KeyEvent.KEYCODE_BUTTON_R2: state.rightTrigger = pressed ? 1f : 0f; break;
case KeyEvent.KEYCODE_DPAD_UP: state.up = pressed; break;
case KeyEvent.KEYCODE_DPAD_RIGHT: state.right = pressed; break;
case KeyEvent.KEYCODE_DPAD_DOWN: state.down = pressed; break;
case KeyEvent.KEYCODE_DPAD_LEFT: state.left = pressed; break;
default: return false;
}
publish();
@@ -124,19 +124,19 @@ public final class PadBridge {
public synchronized boolean onMotionEvent(MotionEvent event) {
if (!isFromController(event.getDevice())) return false;
if (event.getAction() != MotionEvent.ACTION_MOVE) return false;
state.thumbLX = axis(event, MotionEvent.AXIS_X);
state.leftX = axis(event, MotionEvent.AXIS_X);
// Android's Y axis grows downwards and evdev's ABS_Y does too, so no flip here: what the
// pad reports as "down" is what the client is told.
state.thumbLY = axis(event, MotionEvent.AXIS_Y);
state.thumbRX = axis(event, MotionEvent.AXIS_Z);
state.thumbRY = axis(event, MotionEvent.AXIS_RZ);
state.leftY = axis(event, MotionEvent.AXIS_Y);
state.rightX = axis(event, MotionEvent.AXIS_Z);
state.rightY = axis(event, MotionEvent.AXIS_RZ);
float lt = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);
float rt = event.getAxisValue(MotionEvent.AXIS_RTRIGGER);
// Some pads only report the triggers on BRAKE/GAS.
if (lt == 0f) lt = event.getAxisValue(MotionEvent.AXIS_BRAKE);
if (rt == 0f) rt = event.getAxisValue(MotionEvent.AXIS_GAS);
state.triggerL = lt;
state.triggerR = rt;
state.leftTrigger = lt;
state.rightTrigger = rt;
float hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X);
float hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
state.dpad[0] = hatY < -0.5f;
@@ -151,7 +151,7 @@ public final class PadBridge {
* The on-screen controls' way in: they mutate the same state a physical pad writes, so the
* client only ever sees one device and a user can use both at once without them fighting.
*/
public synchronized void applyTouch(java.util.function.Consumer<GamepadState> mutation) {
public synchronized void applyTouch(java.util.function.Consumer<PadState> mutation) {
mutation.accept(state);
publish();
}
@@ -203,13 +203,13 @@ public final class PadBridge {
if (!open && !start()) return;
if (systemGuidePressed || qamChordActive) {
effectiveState.copy(state);
effectiveState.setPressed(GamepadState.IDX_BUTTON_MODE, true);
effectiveState.setPressed(PadState.IDX_BUTTON_MODE, true);
if (qamSyntheticAPressed) {
effectiveState.setPressed(0, state.isPressed(0) || qamSyntheticAPressed);
}
writer.writeGamepadState(effectiveState);
writer.writePadState(effectiveState);
} else {
writer.writeGamepadState(state);
writer.writePad(state);
}
}
@@ -0,0 +1,61 @@
package com.steamdeck.launcher.input
/**
* What one Xbox-shaped pad is doing right now: two sticks and two triggers as -1..1 / 0..1, the
* four d-pad directions, and a bitmask of the buttons numbered the way the fake evdev node
* reports them. Written by whatever drives the pad (a physical controller, the on-screen one, or
* both at once) and read by [FakeInputWriter] into the guest's input ring.
*/
class PadState {
@JvmField var leftX = 0f
@JvmField var leftY = 0f
@JvmField var rightX = 0f
@JvmField var rightY = 0f
@JvmField var leftTrigger = 0f
@JvmField var rightTrigger = 0f
@JvmField var up = false
@JvmField var right = false
@JvmField var down = false
@JvmField var left = false
private var buttons = 0
fun press(button: Int, down: Boolean) {
buttons = if (down) buttons or (1 shl button) else buttons and (1 shl button).inv()
}
fun isDown(button: Int): Boolean = buttons and (1 shl button) != 0
/** The d-pad as a hat: -1 left, 1 right; -1 up, 1 down. Opposites cancel to 0. */
fun hatX(): Int = if (right && !left) 1 else if (left && !right) -1 else 0
fun hatY(): Int = if (down && !up) 1 else if (up && !down) -1 else 0
fun copyFrom(other: PadState) {
leftX = other.leftX; leftY = other.leftY; rightX = other.rightX; rightY = other.rightY
leftTrigger = other.leftTrigger; rightTrigger = other.rightTrigger
up = other.up; right = other.right; down = other.down; left = other.left
buttons = other.buttons
}
/** Everything released and centred. */
fun clear() {
leftX = 0f; leftY = 0f; rightX = 0f; rightY = 0f
leftTrigger = 0f; rightTrigger = 0f
up = false; right = false; down = false; left = false
buttons = 0
}
companion object {
const val A = 0
const val B = 1
const val X = 2
const val Y = 3
const val LB = 4
const val RB = 5
const val SELECT = 6
const val START = 7
const val L3 = 8
const val R3 = 9
/** The Steam/Guide button, which the fake evdev node reports as BTN_MODE. */
const val GUIDE = 12
}
}