Desktop programs: controller seen by every emulator, Player 1 profiles, big-core pinning

- The pad keeps Steam Input's virtual-gamepad identity only in Steam sessions.
  SDL ignores a Steam virtual gamepad unless run under Steam, so on the desktop
  and from the rail every SDL emulator saw no controller at all; there it is a
  plain Xbox 360 pad now, which SDL and evdev map by themselves.
- bannerlator-pad-defaults writes Player 1 on the controller for emulators that
  have no profile yet (RPCS3 first: without one it takes the keyboard). Run at
  desktop start and before a program from the rail; never overwrites.
- The desktop and everything started from it, and a program from the rail, run
  on the game cores when chosen, else every core but the slowest cluster
  (program_cores); BL_PIN_CORES=0 turns it off. Game cores reach every mode.
This commit is contained in:
The412Banner committed 2026-09-23 22:06:47 -04:00
1 parent 3e8bcf6e97
commit a6bab67508
5 files changed
+125 -7

No files matched your search

@@ -38,6 +38,7 @@ object SessionFiles {
"usr/local/bin/bannerlator-desktop-games" to "usr/local/bin/bannerlator-desktop-games",
"usr/local/bin/bannerlator-steam-shim" to "usr/local/bin/bannerlator-steam-shim",
"usr/local/bin/bannerlator-steam-shortcuts" to "usr/local/bin/bannerlator-steam-shortcuts",
"usr/local/bin/bannerlator-pad-defaults" to "usr/local/bin/bannerlator-pad-defaults",
// The SteamOS helpers the client calls in Deck mode: the two Armada found it needs, plus
// the three under /usr/bin, all no-ops that answer "nothing to do" (see each file).
"usr/bin/steamos-update" to "usr/bin/steamos-update",
@@ -321,13 +321,13 @@ class SessionService : Service() {
// on, even naming every core: it exists to undo the pin Steam applies to its own interface
// renderer, and the scheduler's default is exactly what that pin takes away. A game's is
// sent only when it is a real restriction - a game has no pin of its own to undo.
if (SessionState.mode == MODE_STEAM) {
if (SessionPrefs.clientCpusOverride(this)) {
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
}
CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(this))
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
if (SessionState.mode == MODE_STEAM && SessionPrefs.clientCpusOverride(this)) {
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
}
// The game cores also pin the desktop and a program from the rail; without a choice the
// session script picks every core but the slowest cluster for those (program_cores).
CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(this))
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
// PulseAudio always: the client is a native Linux program and has no other way to make a
// sound - its menus, its music and its voice chat all go through here. DirectAudio is not
@@ -398,7 +398,11 @@ class SessionService : Service() {
// identity gets the standard layout without the user configuring the pad by hand.
guest.add("FAKE_EVDEV_IDENTITY=xbox360")
guest.add("FAKE_EVDEV_VIBRATION=1")
guest.add("FAKE_EVDEV_STEAM_VIRTUAL=1")
// Steam Input's virtual-gamepad identity is for games the client starts, which are
// meant to see that pad. Everywhere else (the desktop, a program from the rail) it
// hides the pad: SDL ignores a Steam virtual gamepad unless it runs under Steam, so
// every SDL emulator came up with no controller. There it is a plain Xbox 360 pad.
if (SessionState.mode == MODE_STEAM) guest.add("FAKE_EVDEV_STEAM_VIRTUAL=1")
guest.add("SDL_JOYSTICK_DISABLE_UDEV=1")
guest.add("SDL_HIDAPI_JOYSTICK_DISABLE_UDEV=1")
guest.add("SDL_JOYSTICK_HIDAPI=0")
+2
View File
@@ -101,6 +101,8 @@ export BL_DESKTOP=1
ln -sf /usr/local/bin/bannerlator-steam-launch /usr/local/bin/steamdeck-steam 2>/dev/null
ln -sf /usr/local/bin/bannerlator-steam-shim /usr/local/bin/steam 2>/dev/null
python3 /usr/local/bin/bannerlator-desktop-games 2>&1 | sed 's/^/[games] /'
# Player 1 on the controller in every emulator that has no profile of its own yet.
python3 /usr/local/bin/bannerlator-pad-defaults 2>&1 | sed 's/^/[pads] /'
# Games and emulators from the menu run through droiddeck-gpu (their own gamescope on the app's
# compositor) while the desktop is on pixman, where they could not draw with the GPU.
# BL_DESKTOP_GPU=on/off overrides; each entry keeps "Run in a desktop window" either way.
@@ -0,0 +1,77 @@
#!/usr/bin/python3
# Player 1 on the session's controller, for every emulator that would otherwise start on the
# keyboard. The session's pad is an Xbox 360 controller (libfakeinput's identity outside Steam) that
# SDL maps by itself; what an emulator lacks is a profile that points Player 1 at it. One is
# written only where the emulator has none yet - a profile the user made is never touched.
# Run at every desktop start and before every program from the rail.
import os
HOME = os.environ.get("HOME", "/root")
CONFIG = os.environ.get("XDG_CONFIG_HOME", os.path.join(HOME, ".config"))
def seed(path, text, what):
if os.path.exists(path):
return False
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path + ".tmp", "w", encoding="utf-8") as f:
f.write(text)
os.replace(path + ".tmp", path)
print(f"bannerlator-pad-defaults: {what}: Player 1 on the controller ({path})")
return True
# RPCS3: its global input configuration (rpcs3::utils::get_input_config_dir() + "Default.yml").
# Without one it adds the keyboard pad handler (pad_config.cpp, cfg_input::load). SDL handler
# names from rpcs3/Input/sdl_pad_handler.cpp (button_list, init_config); the device is
# "<SDL gamepad name> <n>" (sdl_pad_handler::enumerate_devices).
RPCS3_PLAYER1 = """Player 1 Input:
Handler: SDL
Device: Xbox 360 Controller 1
Config:
Left Stick Left: LS X-
Left Stick Down: LS Y-
Left Stick Right: LS X+
Left Stick Up: LS Y+
Right Stick Left: RS X-
Right Stick Down: RS Y-
Right Stick Right: RS X+
Right Stick Up: RS Y+
Start: Start
Select: Back
PS Button: Guide
Square: West
Cross: South
Circle: East
Triangle: North
Left: Left
Down: Down
Right: Right
Up: Up
R1: RB
R2: RT
R3: RS
L1: LB
L2: LT
L3: LS
Left Stick Deadzone: 8000
Right Stick Deadzone: 8000
Left Stick Anti-Deadzone: 4259
Right Stick Anti-Deadzone: 4259
Left Trigger Threshold: 0
Right Trigger Threshold: 0
Color Value B: 20
LED battery indicator brightness: 10
Buddy Device: ""
"""
def rpcs3():
seed(os.path.join(CONFIG, "rpcs3/input_configs/global/Default.yml"), RPCS3_PLAYER1, "RPCS3")
for step in (rpcs3,):
try:
step()
except OSError as e:
print(f"bannerlator-pad-defaults: {step.__name__}: {e}")
@@ -79,6 +79,28 @@ export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
# The cores a program runs on outside Steam (the desktop and everything started from it, a
# program from the rail): the user's game cores when set (BL_GAME_CPUS), else every core but the
# slowest cluster - Android is free to park an emulator's threads on the little cores, and those
# are what compile shaders and recompile PPU/SPU code. BL_PIN_CORES=0 leaves the scheduler alone.
program_cores() {
[ "${BL_PIN_CORES:-1}" = 0 ] && return 0
command -v taskset >/dev/null 2>&1 || return 0
if [ -n "${BL_GAME_CPUS:-}" ]; then echo "$BL_GAME_CPUS"; return 0; fi
local f n max min= list=
for f in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/cpuinfo_max_freq; do
max=$(cat "$f" 2>/dev/null) || continue
[ -z "$min" ] || [ "$max" -lt "$min" ] && min=$max
done
[ -n "$min" ] || return 0
for f in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/cpuinfo_max_freq; do
max=$(cat "$f" 2>/dev/null) || continue
n=${f#/sys/devices/system/cpu/cpu}; n=${n%%/*}
[ "$max" -gt "$min" ] && list="$list${list:+,}$n"
done
echo "$list"
}
if [ -z "${BL_INSIDE:-}" ]; then
# The compositor may still be starting, and a socket left by an earlier session is not
# a compositor: probe until a connection succeeds.
@@ -91,6 +113,11 @@ if [ -z "${BL_INSIDE:-}" ]; then
if [ "$mode" = lxqt ]; then
step "starting the desktop"
[ -x /usr/local/bin/droiddeck-desktop ] || { echo "== the desktop package is not installed"; exit 66; }
cores=$(program_cores)
if [ -n "$cores" ]; then
echo "== desktop cores: $cores (the desktop and every program started from it)"
exec taskset -c "$cores" /usr/local/bin/droiddeck-desktop
fi
exec /usr/local/bin/droiddeck-desktop
fi
width=${BL_WIDTH:-1280}
@@ -162,6 +189,13 @@ case $mode in
run)
target=${1:?program path}
shift
cores=$(program_cores)
if [ -n "$cores" ]; then
echo "== program cores: $cores"
taskset -cp "$cores" $$ >/dev/null 2>&1 || true
fi
# Player 1 on the controller in an emulator that has no profile of its own yet.
python3 /usr/local/bin/bannerlator-pad-defaults 2>&1 || true
case ${target,,} in
*.appimage)
export APPIMAGE_EXTRACT_AND_RUN=1