feat: the built-in pad can be a Steam Controller to Steam (#545)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-11 03:24:22 +00:00
1 parent d7f89fc32b
commit 8d34b37b7d
15 files changed
+281 -28

No files matched your search

+209 -6
View File
@@ -1268,6 +1268,7 @@ struct DeckHidraw {
uint8_t pending_feature = 0;
bool touch = false; // Steam's touch controller (below), not the Deck
bool triton = false; // The paired 2025 Steam Controller, with native BLE report IDs
bool emulated = false; // That Steam Controller made from the app's own pad (FAKE_EVDEV_TRITON_PAD)
};
// What the Deck has and an Xbox pad does not, after the ring's events: motion (PadMotion) and the
@@ -1392,6 +1393,14 @@ static bool fake_deck_enabled() {
return enabled == 1;
}
// The app's own pad as the Steam Controller, in the Deck's place: hidraw18 then streams reports
// built from ring slot 0 as the Deck's are, and answers its feature reports itself.
static bool fake_triton_pad() {
static int enabled = -1;
if (enabled < 0) enabled = getenv("FAKE_EVDEV_TRITON_PAD") && atoi(getenv("FAKE_EVDEV_TRITON_PAD")) ? 1 : 0;
return enabled == 1;
}
static bool fake_triton_enabled() {
static int enabled = -1;
if (enabled < 0)
@@ -1426,7 +1435,7 @@ __attribute__((constructor)) static void log_client_start() {
}
__attribute__((visibility("hidden"))) static bool is_deck_hidraw_path(const char *pathname) {
return pathname && fake_deck_enabled() && !strcmp(pathname, DECK_HIDRAW_PATH);
return pathname && fake_deck_enabled() && !fake_triton_pad() && !strcmp(pathname, DECK_HIDRAW_PATH);
}
__attribute__((visibility("hidden"))) static bool is_triton_hidraw_path(const char *pathname) {
@@ -1651,6 +1660,111 @@ __attribute__((visibility("hidden"))) static void *triton_report_thread(void *ar
return nullptr;
}
// Button bits of the Triton state report (SDL, SDL_hidapi_steam_triton.c). SDL reads MENU as Back
// and VIEW as Start, the reverse of the Deck's names.
static constexpr uint32_t TRITON_A = 0x00000001, TRITON_B = 0x00000002, TRITON_X = 0x00000004,
TRITON_Y = 0x00000008, TRITON_QAM = 0x00000010, TRITON_R3 = 0x00000020,
TRITON_VIEW = 0x00000040, TRITON_R4 = 0x00000080, TRITON_R5 = 0x00000100,
TRITON_R = 0x00000200, TRITON_DOWN = 0x00000400, TRITON_RIGHT = 0x00000800,
TRITON_LEFT = 0x00001000, TRITON_UP = 0x00002000, TRITON_MENU = 0x00004000,
TRITON_L3 = 0x00008000, TRITON_STEAM = 0x00010000, TRITON_L4 = 0x00020000,
TRITON_L5 = 0x00040000, TRITON_L = 0x00080000,
TRITON_RSTICK_TOUCH = 0x00100000, TRITON_RPAD_TOUCH = 0x00200000,
TRITON_RPAD_CLICK = 0x00400000, TRITON_RTRIGGER_CLICK = 0x00800000,
TRITON_LSTICK_TOUCH = 0x01000000, TRITON_LPAD_TOUCH = 0x02000000,
TRITON_LPAD_CLICK = 0x04000000, TRITON_LTRIGGER_CLICK = 0x08000000,
TRITON_RGRIP_TOUCH = 0x10000000, TRITON_LGRIP_TOUCH = 0x20000000;
// The pad is built in, so it is the wired controller: 28de:1302 on USB, state report 0x42 (the
// same layout as the Bluetooth 0x45), where the paired one is 28de:1303 on Bluetooth.
static constexpr uint8_t TRITON_STATE_WIRED = 0x42;
static constexpr int16_t TRITON_WIRED_PRODUCT = 0x1302;
// A stick counts as touched once it leaves its centre: the pad has no capacitive caps to ask.
static constexpr int32_t TRITON_STICK_TOUCH = 2000;
// The Triton BLE state report (SDL, controller_structs.h: TritonMTUNoQuat_t) from the ring's
// snapshot and the Deck block, which already hold the trackpads, back buttons and motion in the
// units both controllers share. A handheld is held whenever it is played, so both grips read as
// touched: Steam's grip-sense activators (gyro while held, say) then simply stay on.
__attribute__((visibility("hidden"))) static void
build_triton_report(uint8_t *report, uint32_t packet, uint32_t buttons, const int32_t *axes,
const DeckExtras &extras) {
memset(report, 0, TRITON_STATE_BYTES);
report[0] = static_cast<uint8_t>(packet);
static const uint32_t kButtonBits[11] = {TRITON_A, TRITON_B, TRITON_X, TRITON_Y,
TRITON_L, TRITON_R, TRITON_MENU, TRITON_VIEW,
TRITON_L3, TRITON_R3, TRITON_STEAM};
uint32_t bits = TRITON_LGRIP_TOUCH | TRITON_RGRIP_TOUCH;
for (int i = 0; i < 11; i++)
if (buttons & (1u << i)) bits |= kButtonBits[i];
if (buttons & SNAPSHOT_QAM_BIT) bits |= TRITON_QAM;
if (axes[7] < 0) bits |= TRITON_UP;
if (axes[7] > 0) bits |= TRITON_DOWN;
if (axes[6] < 0) bits |= TRITON_LEFT;
if (axes[6] > 0) bits |= TRITON_RIGHT;
int32_t left_trigger = axes[5], right_trigger = axes[4]; // ABS_BRAKE, ABS_GAS: 0..255
if (left_trigger >= 250) bits |= TRITON_LTRIGGER_CLICK;
if (right_trigger >= 250) bits |= TRITON_RTRIGGER_CLICK;
if (abs(axes[0]) > TRITON_STICK_TOUCH || abs(axes[1]) > TRITON_STICK_TOUCH) bits |= TRITON_LSTICK_TOUCH;
if (abs(axes[2]) > TRITON_STICK_TOUCH || abs(axes[3]) > TRITON_STICK_TOUCH) bits |= TRITON_RSTICK_TOUCH;
uint32_t controls = extras.controls;
if (controls & DECK_EXTRA_L4) bits |= TRITON_L4;
if (controls & DECK_EXTRA_R4) bits |= TRITON_R4;
if (controls & DECK_EXTRA_L5) bits |= TRITON_L5;
if (controls & DECK_EXTRA_R5) bits |= TRITON_R5;
if (controls & DECK_EXTRA_LPAD_TOUCH) bits |= TRITON_LPAD_TOUCH;
if (controls & DECK_EXTRA_RPAD_TOUCH) bits |= TRITON_RPAD_TOUCH;
if (controls & DECK_EXTRA_LPAD_CLICK) bits |= TRITON_LPAD_CLICK;
if (controls & DECK_EXTRA_RPAD_CLICK) bits |= TRITON_RPAD_CLICK;
put32(report + 1, bits);
put16(report + 5, std::min(32767, left_trigger * 32767 / 255));
put16(report + 7, std::min(32767, right_trigger * 32767 / 255));
auto stick = [](int32_t value) { return std::max(-32767, std::min(32767, value)); };
put16(report + 9, stick(axes[0]));
put16(report + 11, stick(-axes[1]));
put16(report + 13, stick(axes[2]));
put16(report + 15, stick(-axes[3]));
put16(report + 17, extras.pads[0]);
put16(report + 19, extras.pads[1]);
put16(report + 21, extras.pressure[0]);
put16(report + 23, extras.pads[2]);
put16(report + 25, extras.pads[3]);
put16(report + 27, extras.pressure[1]);
put32(report + 29, packet * TRITON_REPORT_INTERVAL_US); // IMU timestamp, microseconds
for (int i = 0; i < 3; i++) {
put16(report + 33 + i * 2, extras.accel[i]);
put16(report + 39 + i * 2, extras.gyro[i]);
}
}
__attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg) {
auto *holder = static_cast<std::shared_ptr<DeckHidraw> *>(arg);
std::shared_ptr<DeckHidraw> self = *holder;
delete holder;
uint32_t packet = 0;
SnapshotState snap;
uint32_t buttons = 0;
int32_t axes[8] = {};
DeckExtras extras;
for (;;) {
if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) {
buttons = snap.buttons;
memcpy(axes, snap.axes, sizeof(axes));
}
read_deck_extras(*self, extras);
uint8_t report[TRITON_REPORT_ID_BYTES + TRITON_STATE_BYTES];
report[0] = TRITON_STATE_WIRED;
build_triton_report(report + 1, ++packet, buttons, axes, extras);
if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 &&
errno != EAGAIN && errno != EWOULDBLOCK)
break;
struct timespec interval = {0, TRITON_REPORT_INTERVAL_US * 1000L};
nanosleep(&interval, nullptr);
}
syscall(SYS_close, self->peer);
munmap(self->ring, self->mapping_size);
return nullptr;
}
__attribute__((visibility("hidden"))) static int open_triton_hidraw(int flags) {
static auto my_open = reinterpret_cast<int (*)(const char *, int, ...)>(dlsym(RTLD_NEXT, "open"));
if (!process_is_steam_client()) {
@@ -1694,6 +1808,7 @@ __attribute__((visibility("hidden"))) static int open_triton_hidraw(int flags) {
triton->ring = static_cast<FakeInputRingHeader *>(mapping);
triton->mapping_size = mapping_size;
triton->triton = true;
triton->emulated = fake_triton_pad();
{
std::lock_guard<std::recursive_mutex> guard(controller_mutex());
deck_map()[pair[0]] = triton;
@@ -1701,7 +1816,7 @@ __attribute__((visibility("hidden"))) static int open_triton_hidraw(int flags) {
}
pthread_t thread;
auto *thread_arg = new std::shared_ptr<DeckHidraw>(triton);
if (pthread_create(&thread, nullptr, triton_report_thread, thread_arg) != 0) {
if (pthread_create(&thread, nullptr, triton->emulated ? triton_pad_thread : triton_report_thread, thread_arg) != 0) {
delete thread_arg;
std::lock_guard<std::recursive_mutex> guard(controller_mutex());
deck_map().erase(pair[0]);
@@ -1713,7 +1828,8 @@ __attribute__((visibility("hidden"))) static int open_triton_hidraw(int flags) {
return -1;
}
pthread_detach(thread);
Logger::log("triton: %s opened as fd %d (28de:1303)\n", TRITON_HIDRAW_PATH, pair[0]);
Logger::log("triton: %s opened as fd %d (%s)\n", TRITON_HIDRAW_PATH, pair[0],
triton->emulated ? "28de:1302, the app's pad" : "28de:1303");
return pair[0];
}
@@ -2311,6 +2427,85 @@ __attribute__((visibility("hidden"))) static int triton_get_feature(DeckHidraw &
return -1;
}
// The emulated controller's feature reports: report ID 1, then the Valve message (type, length,
// payload), answered here as the Deck's are. The identity is the one a 2025 Steam Controller gave
// on device (HWID 72, its firmware timestamp), with this library's serial.
static constexpr uint32_t TRITON_HWID = 72;
static constexpr uint32_t TRITON_FW_TIMESTAMP = 0x6AC686B3;
__attribute__((visibility("hidden"))) static int triton_pad_feature(DeckHidraw &triton, uint8_t *buf, size_t size, bool set) {
if (!buf || size < 2) {
errno = EINVAL;
return -1;
}
if (set) {
triton.pending_feature = buf[1];
if (buf[1] == DECK_SET_SETTINGS_VALUES && size >= 3) {
int imu_mode = deck_imu_mode_change(buf, size);
if (imu_mode >= 0) publish_imu_mode(triton, imu_mode);
}
log_deck_feature("set", buf[1]);
return static_cast<int>(size);
}
uint8_t reply[65] = {};
reply[0] = buf[0];
reply[1] = triton.pending_feature;
switch (triton.pending_feature) {
case DECK_GET_ATTRIBUTES_VALUES: {
// (attribute, 32-bit value) pairs: product id, capabilities, firmware timestamp, hardware id.
static const uint8_t kIds[] = {0x01, 0x02, 0x04, 0x09, 0x0a, 0x0b};
const uint32_t values[] = {static_cast<uint32_t>(TRITON_WIRED_PRODUCT), 0, TRITON_FW_TIMESTAMP, TRITON_HWID, 0, 4000};
reply[2] = sizeof(kIds) * 5;
for (size_t i = 0; i < sizeof(kIds); i++) {
reply[3 + i * 5] = kIds[i];
put32(reply + 4 + i * 5, values[i]);
}
break;
}
case DECK_GET_STRING_ATTRIBUTE:
reply[2] = 0x14;
reply[3] = 0x01; // the unit serial
memcpy(reply + 4, TRITON_SERIAL, strlen(TRITON_SERIAL));
break;
case DECK_GET_CHIP_ID:
reply[2] = 0x11;
memcpy(reply + 4, "DROIDDECKCHIP02", 15);
break;
default:
break;
}
log_deck_feature("read", triton.pending_feature);
size_t length = std::min(size, sizeof(reply));
memcpy(buf, reply, length);
return static_cast<int>(length);
}
// The emulated controller's haptic output reports (SDL, controller_structs.h) on the handheld's
// own motor: rumble as asked, the trackpad pulses and effects as short ticks.
__attribute__((visibility("hidden"))) static void triton_pad_output(const uint8_t *data, size_t size) {
if (!data || size < 2) return;
switch (data[0]) {
case 0x80: // ID_OUT_REPORT_HAPTIC_RUMBLE: type, intensity, left {speed, gain}, right {speed, gain}
if (size >= 10) {
int left = data[4] | data[5] << 8, right = data[7] | data[8] << 8;
// SDL repeats a held rumble every 40 ms, so each report lasts a little longer than that.
send_vibration(left, right, left || right ? 100 : 0, 0);
}
break;
case 0x81: // ID_OUT_REPORT_HAPTIC_PULSE: side, on_us, off_us, repeat count
if (size >= 8) {
int on_ms = (data[2] | data[3] << 8) / 1000, repeat = data[6] | data[7] << 8;
send_vibration(0, 40000, std::max(8, std::min(200, on_ms * std::max(1, repeat))), 0);
}
break;
case 0x82: case 0x83: case 0x84: case 0x85: // command, tone, sweep, script
send_vibration(0, 30000, 15, 0);
break;
default:
break;
}
}
__attribute__((visibility("hidden"))) static int ioctl_triton(DeckHidraw &triton, ioctl_request_t op, void *argp) {
if (_IOC_TYPE(op) != 'H') {
errno = ENOTTY;
@@ -2325,6 +2520,8 @@ __attribute__((visibility("hidden"))) static int ioctl_triton(DeckHidraw &triton
uint32_t size;
memcpy(&size, descriptor, sizeof(size));
memcpy(descriptor + 4, kTritonReportDescriptor, std::min<size_t>(size, sizeof(kTritonReportDescriptor)));
// The wired controller's state report (SteamDeckPad's TRITON_WIRED_REPORT_DESCRIPTOR).
if (triton.emulated && size > 15) descriptor[4 + 15] = TRITON_STATE_WIRED;
return 0;
}
case 0x03: {
@@ -2332,12 +2529,13 @@ __attribute__((visibility("hidden"))) static int ioctl_triton(DeckHidraw &triton
uint32_t bustype;
int16_t vendor;
int16_t product;
} info = {BUS_BLUETOOTH, static_cast<int16_t>(0x28de), static_cast<int16_t>(0x1303)};
} info = {triton.emulated ? static_cast<uint32_t>(BUS_USB) : static_cast<uint32_t>(BUS_BLUETOOTH),
static_cast<int16_t>(0x28de), triton.emulated ? TRITON_WIRED_PRODUCT : static_cast<int16_t>(0x1303)};
memcpy(argp, &info, sizeof(info));
return 0;
}
case 0x04: return copy_ioctl_string(op, argp, TRITON_NAME);
case 0x05: return copy_ioctl_string(op, argp, "bluetooth-droiddeck-1");
case 0x05: return copy_ioctl_string(op, argp, triton.emulated ? "usb-droiddeck-3/input0" : "bluetooth-droiddeck-1");
case 0x08: return copy_ioctl_string(op, argp, TRITON_SERIAL);
case 0x06: {
// The client's feature reports are the report ID and 64 bytes; the last is padding the BLE
@@ -2347,10 +2545,13 @@ __attribute__((visibility("hidden"))) static int ioctl_triton(DeckHidraw &triton
errno = EINVAL;
return -1;
}
if (triton.emulated) return triton_pad_feature(triton, static_cast<uint8_t *>(argp), size, true);
triton_queue_output(triton, static_cast<const uint8_t *>(argp), std::min<size_t>(size, 64), true);
return static_cast<int>(size);
}
case 0x07: return triton_get_feature(triton, static_cast<uint8_t *>(argp), _IOC_SIZE(op));
case 0x07:
if (triton.emulated) return triton_pad_feature(triton, static_cast<uint8_t *>(argp), _IOC_SIZE(op), false);
return triton_get_feature(triton, static_cast<uint8_t *>(argp), _IOC_SIZE(op));
default:
errno = EINVAL;
return -1;
@@ -3279,6 +3480,7 @@ EXPORT ssize_t write(int fd, const void *buf, size_t count) {
if (made != uinput_map().end()) return write_uinput(*made->second, buf, count);
if (deck_map().count(fd)) {
if (deck_map()[fd]->touch) touch_output(static_cast<const uint8_t *>(buf), count);
else if (deck_map()[fd]->emulated) triton_pad_output(static_cast<const uint8_t *>(buf), count);
else if (deck_map()[fd]->triton) triton_queue_output(*deck_map()[fd], static_cast<const uint8_t *>(buf), count, false);
return static_cast<ssize_t>(count);
}
@@ -3310,6 +3512,7 @@ EXPORT ssize_t writev(int fd, const struct iovec *iov, int iovcnt) {
auto device = deck_map()[fd];
for (int i = 0; i < iovcnt; i++) {
if (device->touch) touch_output(static_cast<const uint8_t *>(iov[i].iov_base), iov[i].iov_len);
else if (device->emulated) triton_pad_output(static_cast<const uint8_t *>(iov[i].iov_base), iov[i].iov_len);
else if (device->triton) triton_queue_output(*device, static_cast<const uint8_t *>(iov[i].iov_base), iov[i].iov_len, false);
total += static_cast<ssize_t>(iov[i].iov_len);
}
@@ -395,7 +395,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
SessionState.padBridge = bridge
// A paired Steam Controller is read over Bluetooth LE, out of lizard mode, as Steam Link reads it.
SteamControllerBle.listener = { uiHandler.post { updatePadMotion(); updateOnScreenControls() } }
steamController = SteamControllerBle(this).also { it.start() }
// Not when the pad itself is the Steam Controller: that device is then the pad's.
if (SessionPrefs.steamController(this) != SessionPrefs.CONTROLLER_STEAM)
steamController = SteamControllerBle(this).also { it.start() }
padMotion = com.droiddeck.launcher.input.PadMotion(this) {
@Suppress("DEPRECATION")
(if (Build.VERSION.SDK_INT >= 30) display else windowManager.defaultDisplay)?.rotation ?: android.view.Surface.ROTATION_0
@@ -19,6 +19,7 @@ object SessionPrefs {
const val CONTROLLER_DECK = "deck"
const val CONTROLLER_XBOX360 = "xbox360"
const val CONTROLLER_STEAM = "steamcontroller"
const val OSC_AUTO = "auto"
const val OSC_ALWAYS = "always"
const val OSC_STEAM_QAM = "steam-qam"
@@ -449,7 +450,8 @@ object SessionPrefs {
/**
* What the pad is to the Steam client: [CONTROLLER_DECK], a Steam Deck controller (Quick Access
* button, gyro, Steam Input's full treatment - SteamDeckPad), or [CONTROLLER_XBOX360], the plain
* button, gyro, Steam Input's full treatment - SteamDeckPad), [CONTROLLER_STEAM], a 2025 Steam
* Controller (the same, plus grip sense and its own haptics), or [CONTROLLER_XBOX360], the plain
* Xbox 360 pad of earlier versions (QAM by the Guide+A chord).
*/
fun steamController(context: Context): String =
@@ -744,14 +744,18 @@ class SessionService : Service() {
// with the Deck asked for the pad's own nodes are withdrawn - no controller at all.
val wantsDeck = uinput && SessionState.mode == MODE_STEAM &&
SessionState.steamUi != "desktop" &&
SessionPrefs.steamController(this) == SessionPrefs.CONTROLLER_DECK &&
SessionPrefs.steamController(this) != SessionPrefs.CONTROLLER_XBOX360 &&
!File(Environment.getExternalStorageDirectory(), NO_DECK_PAD_SWITCH).exists()
// The pad itself as a Steam Controller: the same machinery as the Deck (sysfs, withdrawn
// evdev nodes, Steam Input's virtual pad for games), with the Triton node in the Deck's place.
val padAsTriton = wantsDeck && SessionPrefs.steamController(this) == SessionPrefs.CONTROLLER_STEAM
// Steam's touch controller rides on the Deck's sysfs and is offered only beside it.
val wantsTouch = wantsDeck && !File(Environment.getExternalStorageDirectory(), NO_STEAM_TOUCH_SWITCH).exists()
// A paired Triton is exposed as a second native Steam Controller HID, with its original
// report IDs and output path. The handheld's own pad remains the Deck target.
val wantsTriton = wantsDeck && SteamControllerBle.hasPairedController(this)
deckBinds = if (wantsDeck) SteamDeckPad.prepare(this, fakeInputDir.parentFile!!.parentFile!!, wantsTouch, wantsTriton) else emptyList()
// With the pad as the Steam Controller, that node is the pad's and a paired one is not bridged.
val wantsTriton = padAsTriton || (wantsDeck && SteamControllerBle.hasPairedController(this))
deckBinds = if (wantsDeck) SteamDeckPad.prepare(this, fakeInputDir.parentFile!!.parentFile!!, wantsTouch, wantsTriton, deck = !padAsTriton) else emptyList()
SessionState.deckPad = deckBinds.isNotEmpty()
if (wantsDeck && !SessionState.deckPad) Log.w(TAG, "deck pad: not available this session; the pad stays an Xbox 360 controller")
logControllersAtStart()
@@ -762,6 +766,7 @@ class SessionService : Service() {
if (SessionState.deckPad) {
guest.add("FAKE_EVDEV_DECK=1")
if (wantsTriton) guest.add("FAKE_EVDEV_TRITON=1")
if (padAsTriton) guest.add("FAKE_EVDEV_TRITON_PAD=1")
// Steam's touch controller (SteamTouchDevice): the file the app and libfakeinput share.
if (wantsTouch) com.droiddeck.launcher.input.SteamTouchDevice.prepare(fakeInputDir)?.let {
guest.add("FAKE_TOUCHCTL_RING=" + it.path)
@@ -49,8 +49,12 @@ object SteamDeckPad {
private const val TRITON_MINOR = 18
private const val TRITON_NODE = "hidraw$TRITON_MINOR"
private const val TRITON_HID = "$GUEST_DEVICES/bluetooth/0005:28DE:1303.0003"
private const val TRITON_HIDRAW = "$TRITON_HID/hidraw/$TRITON_NODE"
private const val TRITON_SERIAL = "DROIDDECKSC01"
// The handheld's own pad as the Steam Controller (SessionPrefs.CONTROLLER_STEAM): the same node,
// as the wired controller (28de:1302) on a USB device of its own, since it is built in.
private const val TRITON_USB = "$GUEST_DEVICES/usb3"
private const val TRITON_INTERFACE = "$TRITON_USB/3-1:1.0"
private const val TRITON_WIRED_HID = "$TRITON_INTERFACE/0003:28DE:1302.0004"
// Steam's touch controller (SteamTouchDevice), a second device beside the Deck's: 0000:11fb,
// "Mobile Touch Control", on a USB device of its own. Must match libfakeinput (TOUCH_*).
@@ -93,11 +97,14 @@ object SteamDeckPad {
0xc0,
).map { it.toByte() }.toByteArray()
/** The wired controller's: its 0x42 state report in place of the Bluetooth 0x45. */
private val TRITON_WIRED_REPORT_DESCRIPTOR = TRITON_REPORT_DESCRIPTOR.copyOf().also { it[15] = 0x42 }
/** Where [prepare] puts the stand-in listings; bound into the guest at the same path. */
fun listingDir(sessionRoot: File) = File(sessionRoot, "sys/deck/listing")
/** Writes the tree and returns the `host:guest` binds for it, or none if it could not be made. */
fun prepare(context: Context, sessionRoot: File, touch: Boolean = false, triton: Boolean = false): List<String> {
fun prepare(context: Context, sessionRoot: File, touch: Boolean = false, triton: Boolean = false, deck: Boolean = true): List<String> {
val base = File(sessionRoot, "sys/deck")
val devices = File(base, "devices")
val hidrawClass = File(base, "class-hidraw")
@@ -137,7 +144,8 @@ object SteamDeckPad {
link(File(dir(HIDRAW), "device"), HID)
hidrawClass.mkdirs()
link(File(hidrawClass, NODE), HIDRAW)
// Without the Deck (the pad is the Steam Controller), its device is never listed.
if (deck) link(File(hidrawClass, NODE), HIDRAW)
// Only the names matter: libudev reads a listing for the subsystems to descend into and
// then opens /sys/class/hidraw itself, which is the bind above.
@@ -147,7 +155,9 @@ object SteamDeckPad {
link(File(context.cacheDir, "drm/sys/$MAJOR:$MINOR"), HIDRAW)
val udevData = File(LinuxRuntime.rootDir(context), "run/udev/data").apply { mkdirs() }
File(udevData, "c$MAJOR:$MINOR").writeText("I:1\nE:ID_INPUT=1\nE:ID_INPUT_JOYSTICK=1\n")
File(udevData, "c$MAJOR:$MINOR").apply {
if (deck) writeText("I:1\nE:ID_INPUT=1\nE:ID_INPUT_JOYSTICK=1\n") else delete()
}
if (touch) {
write(TOUCH_USB, "uevent", "DEVTYPE=usb_device\nPRODUCT=0/11fb/0\nTYPE=0/0/0\nBUSNUM=002\nDEVNUM=002\n")
@@ -178,19 +188,40 @@ object SteamDeckPad {
}
if (triton) {
write(TRITON_HID, "uevent", "DRIVER=hid-generic\nHID_ID=0005:000028DE:00001303\n" +
"HID_NAME=Valve Software Steam Controller\nHID_PHYS=bluetooth-droiddeck-1\n" +
"HID_UNIQ=$TRITON_SERIAL\nMODALIAS=hid:b0005g0001v000028DEp00001303\n")
File(dir(TRITON_HID), "report_descriptor").writeBytes(TRITON_REPORT_DESCRIPTOR)
link(File(dir(TRITON_HID), "subsystem"), "/sys/bus/hid")
write(TRITON_HIDRAW, "uevent", "MAJOR=$MAJOR\nMINOR=$TRITON_MINOR\nDEVNAME=$TRITON_NODE\n")
write(TRITON_HIDRAW, "dev", "$MAJOR:$TRITON_MINOR\n")
link(File(dir(TRITON_HIDRAW), "subsystem"), "/sys/class/hidraw")
link(File(dir(TRITON_HIDRAW), "device"), TRITON_HID)
link(File(hidrawClass, TRITON_NODE), TRITON_HIDRAW)
link(File(context.cacheDir, "drm/sys/$MAJOR:$TRITON_MINOR"), TRITON_HIDRAW)
// Without the Deck the node is the pad's own, so the wired controller; else the paired one.
val wired = !deck
val hid = if (wired) TRITON_WIRED_HID else TRITON_HID
val product = if (wired) "1302" else "1303"
val bus = if (wired) "0003" else "0005"
if (wired) {
write(TRITON_USB, "uevent", "DEVTYPE=usb_device\nPRODUCT=28de/1302/100\nTYPE=0/0/0\nBUSNUM=003\nDEVNUM=002\n")
write(TRITON_USB, "idVendor", "28de\n")
write(TRITON_USB, "idProduct", "1302\n")
write(TRITON_USB, "bcdDevice", "0100\n")
write(TRITON_USB, "manufacturer", "Valve Software\n")
write(TRITON_USB, "product", "Steam Controller\n")
write(TRITON_USB, "serial", "$TRITON_SERIAL\n")
link(File(dir(TRITON_USB), "subsystem"), "/sys/bus/usb")
write(TRITON_INTERFACE, "uevent", "DEVTYPE=usb_interface\nPRODUCT=28de/1302/100\nINTERFACE=3/0/0\n")
write(TRITON_INTERFACE, "bInterfaceNumber", "00\n")
write(TRITON_INTERFACE, "bInterfaceClass", "03\n")
link(File(dir(TRITON_INTERFACE), "subsystem"), "/sys/bus/usb")
}
write(hid, "uevent", "DRIVER=hid-generic\nHID_ID=$bus:000028DE:0000$product\n" +
"HID_NAME=Valve Software Steam Controller\n" +
"HID_PHYS=${if (wired) "usb-droiddeck-3/input0" else "bluetooth-droiddeck-1"}\n" +
"HID_UNIQ=$TRITON_SERIAL\nMODALIAS=hid:b${bus}g0001v000028DEp0000$product\n")
File(dir(hid), "report_descriptor").writeBytes(if (wired) TRITON_WIRED_REPORT_DESCRIPTOR else TRITON_REPORT_DESCRIPTOR)
link(File(dir(hid), "subsystem"), "/sys/bus/hid")
val hidraw = "$hid/hidraw/$TRITON_NODE"
write(hidraw, "uevent", "MAJOR=$MAJOR\nMINOR=$TRITON_MINOR\nDEVNAME=$TRITON_NODE\n")
write(hidraw, "dev", "$MAJOR:$TRITON_MINOR\n")
link(File(dir(hidraw), "subsystem"), "/sys/class/hidraw")
link(File(dir(hidraw), "device"), hid)
link(File(hidrawClass, TRITON_NODE), hidraw)
link(File(context.cacheDir, "drm/sys/$MAJOR:$TRITON_MINOR"), hidraw)
File(udevData, "c$MAJOR:$TRITON_MINOR").writeText("I:1\nE:ID_INPUT=1\nE:ID_INPUT_JOYSTICK=1\n")
Log.i(TAG, "steam controller: /dev/$TRITON_NODE described as Triton (28de:1303)")
Log.i(TAG, "steam controller: /dev/$TRITON_NODE described as Triton (28de:$product)")
}
Log.i(TAG, "deck pad: /dev/$NODE described as a Steam Deck controller (28de:1205)")
@@ -263,6 +263,7 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) {
host, "controller", stringResource(R.string.mode_controller), stringResource(R.string.mode_controller_hint),
listOf(
SessionPrefs.CONTROLLER_DECK to stringResource(R.string.mode_controller_deck),
SessionPrefs.CONTROLLER_STEAM to stringResource(R.string.mode_controller_steam),
SessionPrefs.CONTROLLER_XBOX360 to stringResource(R.string.mode_controller_x360),
), s.steamController,
note = stringResource(R.string.mode_controller_note),
+1
View File
@@ -254,6 +254,7 @@
<string name="mode_controller">Mando</string>
<string name="mode_controller_hint">Cómo ve Steam tu mando. Se aplica en la próxima sesión.</string>
<string name="mode_controller_deck">Mando de Steam Deck</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Mando Xbox 360</string>
<string name="mode_controller_note">Deck: botón de Quick Access y giroscopio. Xbox 360: abre Quick Access con Guide+A.</string>
<string name="mode_back">Atrás</string>
+1
View File
@@ -232,6 +232,7 @@
<string name="mode_controller">Manette</string>
<string name="mode_controller_hint">Comment Steam reconnaît votre manette. Prendra effet à la prochaine session.</string>
<string name="mode_controller_deck">Manette Steam Deck</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Manette Xbox 360</string>
<string name="mode_controller_note">Deck : fournit un bouton d\'accès rapide et un gyroscope. Xbox 360 : utilisez Guide+A pour ouvrir l\'accès rapide.</string>
<string name="mode_back">Retour</string>
+1
View File
@@ -254,6 +254,7 @@
<string name="mode_controller">コントローラー</string>
<string name="mode_controller_hint">Steamがコントローラーを認識する方法。次回のセッションで有効になります。</string>
<string name="mode_controller_deck">Steam Deckコントローラー</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Xbox 360コントローラー</string>
<string name="mode_controller_note">Deck:クイックアクセスボタンとジャイロを提供します。Xbox 360:Guide+Aでクイックアクセスを開きます。</string>
<string name="mode_back">戻る</string>
+1
View File
@@ -254,6 +254,7 @@
<string name="mode_controller">컨트롤러</string>
<string name="mode_controller_hint">Steam이 컨트롤러를 인식하는 방식입니다. 다음 세션에 적용됩니다.</string>
<string name="mode_controller_deck">Steam Deck 컨트롤러</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Xbox 360 컨트롤러</string>
<string name="mode_controller_note">Deck: 빠른 액세스 버튼과 자이로스코프를 제공합니다. Xbox 360: Guide+A로 빠른 액세스를 엽니다.</string>
<string name="mode_back">뒤로</string>
+1
View File
@@ -254,6 +254,7 @@
<string name="mode_controller">Контроллер</string>
<string name="mode_controller_hint">Как Steam распознает ваш контроллер. Вступит в силу в следующей сессии.</string>
<string name="mode_controller_deck">Контроллер Steam Deck</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Контроллер Xbox 360</string>
<string name="mode_controller_note">Deck: кнопка быстрого доступа и гироскоп. Xbox 360: используйте Guide+A для быстрого доступа.</string>
<string name="mode_back">Назад</string>
@@ -254,6 +254,7 @@
<string name="mode_controller">手柄</string>
<string name="mode_controller_hint">决定 Steam 把你的手柄识别为哪种类型,将在下次会话生效。</string>
<string name="mode_controller_deck">Steam Deck 手柄</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Xbox 360 手柄</string>
<string name="mode_controller_note">Deck:快捷访问按钮与陀螺仪。Xbox 360:用 Guide+A 打开快捷访问。</string>
<string name="mode_back">返回</string>
@@ -254,6 +254,7 @@
<string name="mode_controller">控制器</string>
<string name="mode_controller_hint">Steam 如何識別你的控制器。下次會話生效。</string>
<string name="mode_controller_deck">Steam Deck 控制器</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Xbox 360 控制器</string>
<string name="mode_controller_note">Deck:提供快速存取按鈕和陀螺儀。Xbox 360:按 Guide+A 開啟快速存取。</string>
<string name="mode_back">返回</string>
@@ -254,6 +254,7 @@
<string name="mode_controller">控制器</string>
<string name="mode_controller_hint">Steam 辨識你的控制器的方式。下次工作階段生效。</string>
<string name="mode_controller_deck">Steam Deck 控制器</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Xbox 360 控制器</string>
<string name="mode_controller_note">Deck:提供快速存取按鈕和陀螺儀。Xbox 360:使用 Guide+A 開啟快速存取。</string>
<string name="mode_back">返回</string>
+2 -1
View File
@@ -262,8 +262,9 @@
<string name="mode_controller">Controller</string>
<string name="mode_controller_hint">How Steam sees your controller. Applies next session.</string>
<string name="mode_controller_deck">Steam Deck controller</string>
<string name="mode_controller_steam">Steam Controller</string>
<string name="mode_controller_x360">Xbox 360 controller</string>
<string name="mode_controller_note">Deck: Quick Access button and gyro. Xbox 360: open Quick Access with Guide+A.</string>
<string name="mode_controller_note">Deck: Quick Access button and gyro. Steam Controller: the same, with grip sense on the back buttons. Xbox 360: open Quick Access with Guide+A.</string>
<string name="mode_back">Back</string>
<string name="back_menu_then_qam">Menu → QAM</string>
<string name="back_qam_then_menu">QAM → Menu</string>