diff --git a/app/src/main/cpp/fakeinput_steam.cpp b/app/src/main/cpp/fakeinput_steam.cpp index 300d6be6e2..ee54f5b660 100644 --- a/app/src/main/cpp/fakeinput_steam.cpp +++ b/app/src/main/cpp/fakeinput_steam.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -197,6 +198,7 @@ static constexpr size_t kSnapshotButtonCount = namespace Logger { void init(); +void log(const char *message, ...); } static void controller_fork_prepare(); @@ -288,6 +290,68 @@ static bool fake_vibration_enabled() { return config().vibration_enabled; } static bool fake_xbox360_identity() { return config().xbox360_identity; } static bool fake_uinput_enabled() { return config().uinput_enabled; } +static bool process_is_steam_client(); + +// Steam and its Remote Play client write the same shared slots; the caller's mutex serialises its own threads. +// Without the lock Steam stays the only writer, as before streaming_client could open these devices. The wait +// is bounded because a session freeze can stop the holder, and callers wait with controller_mutex held. +class ProcessSlotLock { +public: + ProcessSlotLock(int &fd, const char *name, int timeout_ms) : fd_(fd) { + int saved_errno = errno; + if (fd_ < 0) { + std::string path = std::string(fake_hook_dir()) + "/." + name + ".lock"; + fd_ = fd = static_cast(syscall(SYS_openat, AT_FDCWD, path.c_str(), O_CREAT | O_RDWR | O_CLOEXEC, 0600)); + } + int error = fd_ < 0 ? errno : 0; + if (fd_ >= 0) { + struct timespec start, now, pause = {0, 1000 * 1000}; + clock_gettime(CLOCK_MONOTONIC, &start); + for (;;) { + if (flock(fd_, LOCK_EX | LOCK_NB) == 0) { + locked_ = true; + break; + } + if (errno == EINTR) continue; + if (errno != EWOULDBLOCK) { + error = errno; + break; + } + clock_gettime(CLOCK_MONOTONIC, &now); + if ((now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec - start.tv_nsec) / 1000000 >= timeout_ms) { + busy_ = true; + break; + } + nanosleep(&pause, nullptr); + } + } + if (busy_) { + static std::atomic waits; + unsigned n = ++waits; + if ((n & (n - 1)) == 0) Logger::log("lock: %s still held after %d ms, skipped (x%u)\n", name, timeout_ms, n); + } else if (!locked_) { + static std::atomic noted{false}; + if (!noted.exchange(true)) + Logger::log("lock: %s not taken (%s)%s\n", name, strerror(error), + process_is_steam_client() ? "" : "; this process leaves the shared slots alone"); + } + errno = saved_errno; + } + ~ProcessSlotLock() { + int saved_errno = errno; + if (locked_) flock(fd_, LOCK_UN); + errno = saved_errno; + } + bool may_write() const { return locked_ || (!busy_ && process_is_steam_client()); } + ProcessSlotLock(const ProcessSlotLock &) = delete; + ProcessSlotLock &operator=(const ProcessSlotLock &) = delete; + +private: + int fd_; + bool locked_ = false; + bool busy_ = false; +}; + static bool ring_paths_loaded = false; static int next_ff_id = 0; @@ -1214,10 +1278,13 @@ struct DeckImu { uint32_t controls; uint32_t pad_type; uint32_t latency; + uint32_t remote_imu_mode; + uint32_t remote_imu_pid; }; static_assert(offsetof(DeckImu, pad_type) == FAKE_INPUT_RING_PAD_TYPE_OFFSET, "DeckImu::pad_type matches FakeInputWriter and the ring reader"); static_assert(offsetof(DeckImu, latency) == 48, "DeckImu::latency matches FakeInputWriter"); +static_assert(offsetof(DeckImu, remote_imu_mode) == 52, "DeckImu::remote_imu_mode matches FakeInputWriter"); static constexpr uint32_t LATENCY_CONTROLLER = 1, LATENCY_TOUCH = 2; static constexpr int LOW_LATENCY_REPORT_INTERVAL_US = 1000; static constexpr uint32_t DECK_EXTRA_L4 = 1, DECK_EXTRA_R4 = 2, DECK_EXTRA_L5 = 4, @@ -1424,6 +1491,25 @@ __attribute__((visibility("hidden"))) static bool process_is_steam_client() { return known == 1; } +// Steam's Remote Play client reads the controller itself, in its own streaming_client process. +__attribute__((visibility("hidden"))) static bool process_reads_pads() { + static int known; + if (known == 0) { + bool reader = process_is_steam_client(); + if (!reader) { + char exe[PATH_MAX]; + ssize_t length = readlink("/proc/self/exe", exe, sizeof(exe) - 1); + if (length > 0) { + exe[length] = '\0'; + const char *name = strrchr(exe, '/'); + reader = !strcmp(name ? name + 1 : exe, "streaming_client"); + } + } + known = reader ? 1 : -1; + } + return known == 1; +} + __attribute__((constructor)) static void log_client_start() { config(); if (process_is_steam_client()) @@ -1468,7 +1554,7 @@ __attribute__((visibility("hidden"))) static bool is_withdrawn_pad_path(const ch free(fake); return !exposed; } - return number == 0 || !process_is_steam_client(); + return number == 0 || !process_reads_pads(); } static bool fake_pad_withdrawn(const FakeController &fake) { @@ -1683,7 +1769,7 @@ __attribute__((visibility("hidden"))) static void *sony_report_thread(void *arg) __attribute__((visibility("hidden"))) static int open_deck_hidraw(int flags, uint8_t sony = 0) { const char *path = sony == 4 ? DS4_HIDRAW_PATH : sony == 5 ? DUALSENSE_HIDRAW_PATH : DECK_HIDRAW_PATH; static auto my_open = reinterpret_cast(dlsym(RTLD_NEXT, "open")); - if (!process_is_steam_client()) { + if (!process_reads_pads()) { Logger::log("deck: %s refused: not the Steam client\n", path); errno = ENOENT; return -1; @@ -1892,7 +1978,7 @@ __attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg) __attribute__((visibility("hidden"))) static int open_triton_hidraw(int flags, bool emulated) { static auto my_open = reinterpret_cast(dlsym(RTLD_NEXT, "open")); - if (!process_is_steam_client()) { + if (!process_reads_pads()) { errno = ENOENT; return -1; } @@ -2033,15 +2119,19 @@ __attribute__((visibility("hidden"))) static bool touch_plugged() { } __attribute__((visibility("hidden"))) static bool is_touch_hidraw_path(const char *pathname) { - return pathname && !strcmp(pathname, TOUCH_HIDRAW_PATH) && process_is_steam_client() && touch_ring(); + return pathname && !strcmp(pathname, TOUCH_HIDRAW_PATH) && process_reads_pads() && touch_ring(); } +static std::mutex touch_state_mutex; +static int touch_state_lock_fd = -1; + template __attribute__((visibility("hidden"))) static void touch_state(F &&write) { TouchRingFile *ring = touch_ring(); if (!ring) return; - static std::mutex mutex; - std::lock_guard guard(mutex); + std::lock_guard guard(touch_state_mutex); + ProcessSlotLock slot(touch_state_lock_fd, "touch-state", 20); + if (!slot.may_write()) return; __atomic_fetch_add(&ring->state_seq, 1, __ATOMIC_ACQ_REL); write(*ring); __atomic_fetch_add(&ring->state_seq, 1, __ATOMIC_ACQ_REL); @@ -2293,9 +2383,10 @@ __attribute__((visibility("hidden"))) static void *pad_type_thread(void *) { struct timespec settle = {0, 300 * 1000 * 1000}; nanosleep(&settle, nullptr); int added = pad_type_uevent(now, "add"); - if (was != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(was)); - if (now != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(now)); - if (was == PAD_TYPE_XBOX || now == PAD_TYPE_XBOX) { + bool shared = process_is_steam_client(); + if (shared && was != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(was)); + if (shared && now != PAD_TYPE_XBOX) poke_hidraw_watchers(pad_type_minor(now)); + if (shared && (was == PAD_TYPE_XBOX || now == PAD_TYPE_XBOX)) { std::string node = std::string(fake_hook_dir()) + "/event0"; std::string aside = std::string(fake_hook_dir()) + "/.event0-switching"; if (rename(node.c_str(), aside.c_str()) == 0) { @@ -2314,7 +2405,7 @@ __attribute__((visibility("hidden"))) static void *pad_type_thread(void *) { __attribute__((constructor)) static void start_pad_type_watch() { config(); - if (!process_is_steam_client() || !fake_deck_enabled()) return; + if (!process_reads_pads() || !fake_deck_enabled()) return; pthread_t thread; if (pthread_create(&thread, nullptr, pad_type_thread, nullptr) == 0) pthread_detach(thread); } @@ -2335,7 +2426,7 @@ __attribute__((visibility("hidden"))) static void *touch_plug_thread(void *) { __attribute__((constructor)) static void start_touch_controller() { config(); - if (!process_is_steam_client() || !touch_ring()) return; + if (!process_reads_pads() || !touch_ring()) return; pthread_t thread; if (pthread_create(&thread, nullptr, touch_plug_thread, nullptr) == 0) pthread_detach(thread); } @@ -2442,8 +2533,13 @@ __attribute__((visibility("hidden"))) static void publish_imu_mode(const DeckHid std::string path = get_ring_path_for_slot(0); int fd = path.empty() ? -1 : my_open(path.c_str(), O_WRONLY | O_CLOEXEC); if (fd < 0) return; - uint32_t value = 0x80000000u | static_cast(mode); - if (pwrite(fd, &value, sizeof(value), FAKE_INPUT_RING_SIZE + offsetof(DeckImu, imu_mode)) != sizeof(value)) + // Steam and its Remote Play client each keep their own word, so one turning motion off does not starve the + // other; Android reads motion while either wants it. The pid lets it ignore a Remote Play client that has gone. + uint32_t value[2] = {0x80000000u | static_cast(mode), static_cast(getpid())}; + bool steam = process_is_steam_client(); + size_t length = steam ? sizeof(value[0]) : sizeof(value); + off_t offset = FAKE_INPUT_RING_SIZE + (steam ? offsetof(DeckImu, imu_mode) : offsetof(DeckImu, remote_imu_mode)); + if (pwrite(fd, value, length, offset) != static_cast(length)) Logger::log("deck: imu mode not published (%s)\n", strerror(errno)); syscall(SYS_close, fd); } @@ -2648,7 +2744,10 @@ __attribute__((visibility("hidden"))) static void triton_queue_output(DeckHidraw auto *shared = reinterpret_cast(reinterpret_cast(triton.ring) + TRITON_SHARED_OFFSET); if (__atomic_load_n(&shared->magic, __ATOMIC_ACQUIRE) != TRITON_SHARED_MAGIC) return; static std::mutex one_at_a_time; + static int lock_fd = -1; std::lock_guard guard(one_at_a_time); + ProcessSlotLock slot(lock_fd, "triton-output", TRITON_OUTPUT_TIMEOUT_MS * 2); + if (!slot.may_write()) return; for (int waited = 0; static_cast(__atomic_load_n(&shared->output_seq, __ATOMIC_ACQUIRE)) != __atomic_load_n(&shared->output_ack, __ATOMIC_ACQUIRE) && @@ -2680,7 +2779,13 @@ __attribute__((visibility("hidden"))) static int triton_get_feature(DeckHidraw & } auto *shared = reinterpret_cast(reinterpret_cast(triton.ring) + TRITON_SHARED_OFFSET); static std::mutex one_at_a_time; + static int lock_fd = -1; std::lock_guard guard(one_at_a_time); + ProcessSlotLock slot(lock_fd, "triton-feature", TRITON_FEATURE_TIMEOUT_MS); + if (!slot.may_write()) { + errno = EIO; + return -1; + } uint8_t report_id = report[0]; __atomic_store_n(&shared->get_report_id, report_id, __ATOMIC_RELAXED); uint64_t request = __atomic_add_fetch(&shared->get_request, 1, __ATOMIC_RELEASE); @@ -2868,7 +2973,7 @@ __attribute__((visibility("hidden"))) static int ioctl_triton(DeckHidraw &triton __attribute__((visibility("hidden"))) static std::string note_sys_failure(int dirfd, const char *pathname) { int saved_errno = errno; std::string path; - if (saved_errno == ENOENT || !pathname || !process_is_steam_client()) { + if (saved_errno == ENOENT || !pathname || !process_reads_pads()) { errno = saved_errno; return path; } @@ -2907,7 +3012,7 @@ __attribute__((visibility("hidden"))) static std::string note_sys_failure(int di __attribute__((visibility("hidden"))) static std::string deck_listing_for(const char *path) { const char *listing = deck_listing_dir(); - if (!path || !listing || errno != EACCES || !fake_deck_enabled() || !process_is_steam_client()) return {}; + if (!path || !listing || errno != EACCES || !fake_deck_enabled() || !process_reads_pads()) return {}; std::string p(path); while (p.size() > 1 && p.back() == '/') p.pop_back(); int which = p == "/sys" ? 0 : p == "/sys/class" ? 1 : p == "/sys/bus" ? 2 : -1; @@ -2976,7 +3081,7 @@ EXPORT int statx(int dirfd, const char *path, int flags, unsigned mask, struct s constexpr unsigned unique_mount_id = 0x4000; if (result == 0 && (mask & STATX_MNT_ID) && !(buf->stx_mask & (STATX_MNT_ID | unique_mount_id)) && fake_deck_enabled() && - process_is_steam_client() && deck_device_library(__builtin_return_address(0))) { + process_reads_pads() && deck_device_library(__builtin_return_address(0))) { bool recovered = deck_mount_id_from_fdinfo(dirfd, path, flags, buf); static std::atomic noted_success{false}, noted_failure{false}; if (!(recovered ? noted_success : noted_failure).exchange(true)) @@ -3165,7 +3270,7 @@ template static int fake_stat_path(const char *pathname, S *statbuf, Real real) { if (is_withdrawn_pad_path(pathname) || ((is_deck_hidraw_path(pathname) || is_triton_hidraw_path(pathname) || is_triton_pad_path(pathname) || - sony_pad_path(pathname)) && !process_is_steam_client())) { + sony_pad_path(pathname)) && !process_reads_pads())) { errno = ENOENT; return -1; } @@ -3290,9 +3395,9 @@ EXPORT int fstat(int fd, struct stat *buf) { EXPORT int access(const char *pathname, int mode) { static auto my_access = reinterpret_cast(dlsym(RTLD_NEXT, "access")); if (fake_uinput_enabled() && is_uinput_path(pathname)) return 0; - if (is_deck_hidraw_path(pathname) && process_is_steam_client()) return 0; + if (is_deck_hidraw_path(pathname) && process_reads_pads()) return 0; if ((is_triton_hidraw_path(pathname) || is_triton_pad_path(pathname) || sony_pad_path(pathname)) && - process_is_steam_client()) + process_reads_pads()) return 0; if (is_touch_hidraw_path(pathname)) return 0; if (is_withdrawn_pad_path(pathname) || is_deck_hidraw_path(pathname) || is_triton_hidraw_path(pathname) || @@ -3331,9 +3436,9 @@ EXPORT int access(const char *pathname, int mode) { EXPORT int faccessat(int dirfd, const char *pathname, int mode, int flags) { static auto my_faccessat = reinterpret_cast(dlsym(RTLD_NEXT, "faccessat")); if (fake_uinput_enabled() && is_uinput_path(pathname)) return 0; - if (is_deck_hidraw_path(pathname) && process_is_steam_client()) return 0; + if (is_deck_hidraw_path(pathname) && process_reads_pads()) return 0; if ((is_triton_hidraw_path(pathname) || is_triton_pad_path(pathname) || sony_pad_path(pathname)) && - process_is_steam_client()) + process_reads_pads()) return 0; if (is_touch_hidraw_path(pathname)) return 0; if (is_withdrawn_pad_path(pathname) || is_deck_hidraw_path(pathname) || is_triton_hidraw_path(pathname) || @@ -3400,7 +3505,7 @@ EXPORT int inotify_add_watch(int fd, const char *pathname, uint32_t mask) { pathname = fake_path; } else if (!strcmp(pathname, "/dev/input")) { pathname = fake_hook_dir(); - } else if (!strcmp(pathname, "/dev") && fake_deck_enabled() && process_is_steam_client()) { + } else if (!strcmp(pathname, "/dev") && fake_deck_enabled() && process_reads_pads()) { std::string events = hidraw_event_dir(); mkdir(events.c_str(), 0700); my_inotify_add_watch(fd, events.c_str(), mask); diff --git a/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java b/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java index 8cbe135e7a..4675546d61 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java +++ b/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java @@ -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()); } } diff --git a/app/src/main/java/com/droiddeck/launcher/input/ImuModes.java b/app/src/main/java/com/droiddeck/launcher/input/ImuModes.java new file mode 100644 index 0000000000..1c208db274 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/ImuModes.java @@ -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; + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/input/FakeInputImuModeTest.kt b/app/src/test/java/com/droiddeck/launcher/input/FakeInputImuModeTest.kt new file mode 100644 index 0000000000..32ed42f1ff --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/input/FakeInputImuModeTest.kt @@ -0,0 +1,37 @@ +package com.droiddeck.launcher.input + +import org.junit.Assert.assertEquals +import org.junit.Test + +class FakeInputImuModeTest { + private fun set(mode: Int) = Int.MIN_VALUE or mode + + @Test fun motionIsUnknownUntilEitherProcessSetsAMode() { + assertEquals(-1, ImuModes.combine(0, 0, GONE)) + } + + @Test fun motionFollowsSteamAloneBeforeRemotePlayStarts() { + assertEquals(0x18, ImuModes.combine(set(0x18), 0, GONE)) + assertEquals(0, ImuModes.combine(set(0), 0, GONE)) + } + + @Test fun motionStaysOnWhileEitherProcessWantsIt() { + assertEquals(0x18, ImuModes.combine(set(0), set(0x18), RUNNING)) + assertEquals(0x18, ImuModes.combine(set(0x18), set(0), RUNNING)) + } + + @Test fun remotePlayDecidesWhileSteamHasSetNoMode() { + assertEquals(0, ImuModes.combine(0, set(0), RUNNING)) + assertEquals(0x18, ImuModes.combine(0, set(0x18), RUNNING)) + } + + @Test fun aRemotePlayClientThatHasGoneIsIgnored() { + assertEquals(0, ImuModes.combine(set(0), set(0x18), GONE)) + assertEquals(-1, ImuModes.combine(0, set(0x18), GONE)) + } + + private companion object { + const val RUNNING = true + const val GONE = false + } +} diff --git a/tools/tests/test_fakeinput_ring.py b/tools/tests/test_fakeinput_ring.py index 86afc9939a..b032f8ea76 100644 --- a/tools/tests/test_fakeinput_ring.py +++ b/tools/tests/test_fakeinput_ring.py @@ -1,3 +1,5 @@ +import fcntl +import mmap import os from pathlib import Path import shutil @@ -5,6 +7,8 @@ import struct import subprocess import sys import tempfile +import threading +import time import unittest SOURCE = Path(__file__).resolve().parents[2] / "app/src/main/cpp/fakeinput_steam.cpp" @@ -14,6 +18,14 @@ HEADER = 64 EVENT = 24 CAPACITY = 4096 DESCRIPTION = 1824 +RING_SIZE = HEADER + CAPACITY * EVENT +DECK_IMU = 64 +TRITON_BLOCK = 256 +TRITON_MAGIC = 0x4E525454 +TOUCH_MAGIC = 0x31484354 +TOUCH_RING_SIZE = 256 +PAD_TYPE_DECK = 0 +PAD_TYPE_STEAM = 1 READER = r""" #include #include @@ -215,6 +227,72 @@ int main(int argc, char **argv) return 0; } """ +HIDRAW_PROBE = r""" +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int fd = open(argv[1], O_RDONLY | O_NONBLOCK); + if (fd < 0) { + puts(errno == ENOENT ? "refused" : "failed"); + return 0; + } + struct hidraw_devinfo info; + if (ioctl(fd, HIDIOCGRAWINFO, &info) < 0) + return 1; + struct pollfd ready = {fd, POLLIN, 0}; + unsigned char report[64]; + if (poll(&ready, 1, 2000) != 1 || read(fd, report, sizeof(report)) <= 0) + return 2; + printf("%04hx:%04hx report %02x\n", info.vendor, info.product, report[0]); + return 0; +} +""" +FEATURE_PROBE = r""" +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + unsigned char id = (unsigned char)strtoul(argv[1], NULL, 0); + int fd = open("/dev/hidraw18", O_RDWR); + if (fd < 0) + return 1; + int count = argc > 2 ? atoi(argv[2]) : 200, wrong = 0; + for (int i = 0; i < count; i++) { + unsigned char report[64] = {id}; + if (ioctl(fd, HIDIOCGFEATURE(sizeof(report)), report) < 0 || report[0] != id || report[1] != id) + wrong++; + } + printf("%d wrong\n", wrong); + return 0; +} +""" +IMU_MODE_PROBE = r""" +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + unsigned mode = (unsigned)strtoul(argv[1], NULL, 0); + int fd = open("/dev/hidraw16", O_RDWR); + if (fd < 0) + return 1; + unsigned char report[65] = {0x00, 0x87, 3, 48, mode & 0xff, mode >> 8}; + return ioctl(fd, HIDIOCSFEATURE(sizeof(report)), report) < 0; +} +""" OVERLAY_READ = r""" #include #include @@ -348,6 +426,117 @@ class FakeinputRingTest(unittest.TestCase): self.assertEqual(run.returncode, 0, run.stderr) self.assertEqual(run.stdout, "JSIOCGNAME -1 EINVAL\n28de:11ff Microsoft X-Box 360 pad 0\n") + def pad_ring(self, pad_type, triton_connected=False): + hooks, ring = self.ring(virtual=False) + data = bytearray(ring.read_bytes()) + bytearray(DECK_IMU + TRITON_BLOCK) + struct.pack_into("