Integrate DS4 execution parity in Rust

This commit is contained in:
Georg Bauer
2026-07-26 17:58:05 +02:00
parent c9f0c3661c
commit 4420b81117
20 changed files with 11643 additions and 358 deletions

View File

@@ -0,0 +1,23 @@
Reproduce the following C code EXACTLY, character for character, inside a single code block and output nothing else:
```c
static uint32_t clamp_u32(uint32_t v, uint32_t lo, uint32_t hi) {
if (v < lo) return lo;
if (v > hi) return hi;
return v;
}
static uint32_t ring_advance(uint32_t pos, uint32_t cap) {
uint32_t next = pos + 1u;
return next >= cap ? 0u : next;
}
static int scratch_init(scratch *s, uint32_t ctx_size) {
if (ctx_size == 0u) ctx_size = 1u;
s->ctx_size = ctx_size;
s->comp_cap = ctx_size / 4u + 2u;
s->rows = clamp_u32(s->comp_cap, 1u, 4096u);
s->head = 0u;
return s->rows > 0u ? 0 : -1;
}
```