Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install native gamepad dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libudev-dev

- name: Setup Rust
run: |
rustup toolchain install stable --profile minimal
Expand All @@ -36,8 +41,8 @@ jobs:
- name: Install wasm-bindgen
run: cargo install wasm-bindgen-cli --version 0.2.127 --locked

- name: Test touch gestures
run: node --test tests/touch.test.mjs
- name: Test browser controls
run: node --test tests/touch.test.mjs tests/gamepad.test.mjs

- name: Check formatting
run: cargo fmt --all --check
Expand Down
116 changes: 116 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ bevy_egui = { version = "0.40", optional = true }
egui_plot = { version = "0.35", optional = true }
rfd = { version = "0.15", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy_gilrs = { version = "0.19", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
wasm-bindgen = "=0.2.127"
Expand All @@ -47,6 +50,8 @@ protoc-bin-vendored = "3.2.0"

[features]
sector = [
"bevy/gamepad",
"dep:bevy_gilrs",
"bevy/bevy_state",
"bevy_pixels",
"image"
Expand Down
18 changes: 12 additions & 6 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ When two adjacent portal-connected sectors both use `no_ceiling`, the renderer s

The automap shares the world data and projection helpers with the renderer. It supports:

- rotating full map
- rotating visible-only map
- north-up full map
- north-up visible-only map
- relative full map, rotating with the player
- absolute full map, north-up

The cycle is Off → Relative → Absolute → Off. Walls behind the player remain visible; map drawing does not perform view-frustum clipping.

Portal edges are deduplicated so a shared portal is only drawn once.
Its frustum overlay and map-space projection now use the same per-frame render metrics as the main renderer, so wide or tall windows show the correct current view cone instead of a fixed 4:3 frustum.
Expand Down Expand Up @@ -237,7 +237,7 @@ The project leans on fast unit tests instead of heavy end-to-end harnesses:
- map tests verify validation rules and asset expectations
- physics tests cover collision, stepping, jumping, crouching, and portal transitions
- renderer tests cover filling behavior, portal continuity, shading, and outline behavior, including the shipped E1M1 outdoor clipping failure at baseline, wide, and tall buffer sizes
- automap tests cover visible/full modes and portal edge handling
- automap tests cover full-map modes and portal edge handling

This keeps feedback quick while still protecting the important visual and gameplay invariants.

Expand Down Expand Up @@ -269,6 +269,12 @@ The working conventions tied to the current design are:

## Browser touch input

`wasm/touch.mjs` tracks at most two pointer contacts with independent movement/look owners, assigned to the left or right half at contact start. Left displacement drives movement with a 16 CSS pixel dead zone. Right movement accumulates horizontal look, scaled to viewport width. Double taps require a short, stationary first tap followed by a nearby contact within 300 ms. Left double-tap holds crouch, right double-tap queues one jump. A stationary two-finger tap within 250 ms queues an automap cycle, including when both fingers start on the same half. Movement, cancellation, or a third finger invalidates that gesture. Pointer capture preserves contact ownership across the center seam. Cancellation, lost capture, resize, blur, and page hiding clear held controls.
`wasm/touch.mjs` tracks at most two pointer contacts with independent movement/look owners. The first contact chooses its role from its starting half; a second contact gets the opposite role regardless of position. A surviving contact keeps its role, and a replacement fills the other role. Left displacement drives movement with a 16 CSS pixel dead zone. Right movement accumulates horizontal look, scaled to viewport width at 480 look units per full-width swipe (50% faster than the original touch controls). Double taps require a short, stationary first tap followed by a nearby contact within 300 ms. Left double-tap holds crouch, right double-tap queues one jump. A stationary two-finger tap within 250 ms queues an automap cycle, including when both fingers start on the same half. Movement, cancellation, or a third finger invalidates that gesture. Pointer capture preserves contact ownership across the center seam. Cancellation, lost capture, resize, blur, and page hiding clear held controls.

`src/bin/sector/touch.rs` samples browser state in `PreUpdate`, before fixed simulation. Jump edges stay queued until one fixed tick consumes them. Touch activates simulation without pointer lock and uses the existing player physics. Only keyboard Space taps feed the flight toggle. Native builds use empty touch state. Gesture processing is bounded to two contacts and does no work per rendered pixel.

## Gamepad input

`src/bin/sector/controller.rs` consumes a common snapshot from native Bevy gamepad components or the browser Gamepad API bridge in `wasm/gamepad.mjs`. Native builds install Gilrs with its controller mapping database; browser builds poll directly, including a fallback for eight-button, two-axis SNES USB pads. The native backend is excluded from WASM. One active controller owns input; an idle controller can yield to another controller with input.

Snapshots are sampled after Bevy input processing in `PreUpdate`. The shared state applies a radial 20% movement dead zone and a rescaled turn dead zone. Analog movement adds to keyboard/touch input and caps combined speed, including diagonals. Stick and bumper turning use elapsed time at 2.5 radians per second. Jump and automap edges remain queued until consumed once; only keyboard Space feeds the flight toggle. D-pad left/right turns and bumpers strafe by default. Y swaps horizontal D-pad and bumper roles without changing stick bindings. Focus loss and disconnect clear held state and crouch toggles while retaining the chosen D-pad layout. Refocusing requires neutral input before accepting held controls again.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,18 @@ Unless you explicitly state otherwise, any contribution intentionally submitted

### Phone controls

Touch controls have no buttons. On the left half, drag up/down to walk forward/backward and left/right to strafe. Keep holding to move, release to stop. On the right half, swipe horizontally to look, or double-tap to jump. Double-tap the left half and hold the second tap to crouch; drag that held finger to walk while crouched. Release to stand when headroom allows. A quick stationary two-finger tap anywhere cycles the automap. Both thumbs work together in portrait and landscape. Touch jumping never toggles flight.
Touch controls have no buttons. Your first finger chooses a role: starting on the left controls movement; starting on the right controls looking. A second finger takes the other role anywhere on screen, even on the same half. Roles stay fixed until each finger lifts. For movement, drag up/down to walk forward/backward and left/right to strafe. Keep holding to move, release to stop. For looking, swipe horizontally to look, or double-tap to jump. Double-tap with the movement finger and hold the second tap to crouch; drag that held finger to walk while crouched. Release to stand when headroom allows. A quick stationary two-finger tap anywhere cycles the automap: Off → Relative → Absolute → Off. Both thumbs work together in portrait and landscape. Touch jumping never toggles flight.

A short hint appears on touch devices and disappears after your first interaction. Turning the phone or leaving the page clears held gestures. Desktop keyboard and mouse controls remain available.

Run the fast gesture regression tests with `node --test tests/touch.test.mjs`.

### Gamepad controls

Native and browser play support gamepads without mouse capture. Press a controller button or move a stick to start. Left stick walks and strafes with analog speed; right stick turns horizontally. A jumps, B holds crouch, left-stick click toggles crouch, and Select cycles the automap. Jump never toggles flight.

Stickless controllers use D-pad up/down to walk, left/right to turn, and L/R bumpers to strafe. Press Y to swap the horizontal bindings: D-pad left/right strafes and bumpers turn. Up/down and the sticks keep their original roles. Y toggles once per press and the selected layout lasts until Y is pressed again or the runtime restarts.

Native input uses platform controller mappings. Browsers support standard-mapped controllers and a common unmapped eight-button USB SNES profile: Y, B, A, X, L, R, Select, Start at button indices 0 through 7, with D-pad axes 0 and 1. USB adapters with other raw layouts need a matching profile. Release controls after returning from another window; focus loss and disconnect clear held movement, crouch and queued actions.

Run browser input tests with `node --test tests/touch.test.mjs tests/gamepad.test.mjs`.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Runtime and gameplay

- Test controller feel on physical modern and USB SNES pads; add browser profiles for other unmapped adapters as needed.

- Tune touch sensitivity and gesture thresholds from physical iOS/Android playtesting.

- Add interactive doors, lifts, and other moving sector boundaries instead of baking them open into maps.
Expand Down
Loading
Loading