Skip to content

Commit 8cef92b

Browse files
author
DavidQ
committed
Fix Input Mapping V2 gamepad detection source - PR_26140_091-fix-input-mapping-v2-gamepad-detection-source
1 parent 970ef25 commit 8cef92b

14 files changed

Lines changed: 689 additions & 166 deletions
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# PR_26140_090 Input Mapping V2 Combo and Device Capture Report
2+
3+
## Scope
4+
- Updated Input Mapping V2 only, plus focused Workspace V2 Playwright coverage.
5+
- Preserved external JS/CSS, fullscreen layout, stacked full-width capture buttons, and 175px by 175px mapping tiles.
6+
- Did not change schemas or sample JSON.
7+
8+
## Changes
9+
- Removed the active Reset Default Actions control and its app/control wiring.
10+
- Mapping tiles now keep the selected action fixed at creation time and no longer render an action dropdown after creation.
11+
- Tiles display captured mappings directly as removable tokens.
12+
- Existing `InputMappingState` multi-input arrays now support combo-style mappings on one action tile, including keyboard + keyboard and keyboard + gamepad combinations.
13+
- Gamepad capture now renders one capture button per detected gamepad, using labels from the browser Game Controller API when available.
14+
- Gamepad capture remains on the existing engine input path: `InputService` + `GamepadState` + `GamepadInputAdapter`.
15+
- Device-specific capture is recorded through the binding and label while preserving the existing schema source enum:
16+
- `source`: `gamepad`
17+
- `binding`: `Pad<index>:Button<n>` or `Pad<index>:Axis<n><direction>`
18+
- `label`: `<device name> (Gamepad <index>) Button <n>` or Axis equivalent.
19+
- Added selected-device WARN logging when the detected gamepad has no active button or axis at capture time.
20+
21+
## Sample 0104 Alignment
22+
Sample 0104 reads gamepads through `engine.input.getGamepad(0)` and `engine.input.getGamepads()`, which come from the shared engine `InputService`. Input Mapping V2 now refreshes and reads the same `InputService` gamepad snapshot path, then uses `GamepadInputAdapter` for button/axis interpretation.
23+
24+
## Playwright Impact
25+
Yes. This PR changes Input Mapping V2 UI controls, capture flow, gamepad device rendering, and generated mapping output.
26+
27+
Playwright now validates:
28+
- Reset Default Actions is absent.
29+
- Add Action creates a fixed-action tile.
30+
- Mapping tiles show captured mapping text and no tile action dropdown.
31+
- One tile can hold multiple captured inputs for combo mappings.
32+
- Multiple detected gamepads produce one capture button per device.
33+
- Selected gamepad capture records the selected device name/index in the label and binding.
34+
- Captured inputs can still be deleted from the tile.
35+
36+
## Validation
37+
- PASS: targeted syntax/import validation for changed Input Mapping V2 files and focused Playwright file.
38+
- PASS: focused Playwright validation:
39+
`npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs -g "launches Input Mapping V2 and captures keyboard mappings"`
40+
- PASS: `npm run test:workspace-v2` (`60 passed`).
41+
- PASS: no schema JSON changes.
42+
- PASS: no sample JSON changes.
43+
- PASS: coverage changed JS guardrail reported no warnings.
44+
45+
Full samples smoke test was not run, per PR scope.
46+
47+
## Manual Validation
48+
1. Launch Input Mapping V2.
49+
2. Confirm Reset Default Actions is absent.
50+
3. Select an action and click Add Action; confirm a 175px by 175px tile appears with that fixed action label and no action dropdown.
51+
4. Capture two keyboard inputs for the same action and confirm both tokens display on the same tile.
52+
5. Connect or expose multiple gamepads to the browser; confirm one full-width capture button appears for each detected device and includes the device name when available.
53+
6. Capture a button or axis from a chosen gamepad; confirm the tile token includes the device name/index and the JSON binding includes the selected pad index.
54+
7. Click captured tokens and confirm they are removed without deleting the tile.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# PR_26140_091 Input Mapping V2 Gamepad Detection Source Report
2+
3+
## Scope
4+
- Fixed Input Mapping V2 gamepad discovery so the tool does not depend on a running sample/game engine loop.
5+
- Preserved PR_26140_090 combo input behavior, fixed-action tile display, per-device capture buttons, and captured-input deletion.
6+
- Did not change schemas or sample JSON.
7+
8+
## Sample 0104 Comparison
9+
Sample 0104 reads gamepad state from the shared engine `InputService` boundary:
10+
- `engine.input.getGamepad(0)`
11+
- `engine.input.getGamepads()`
12+
13+
Input Mapping V2 now uses the same browser-to-engine path for tool detection:
14+
- polls `navigator.getGamepads()` through the configured `InputService` gamepad source,
15+
- calls `InputService.update()` from the tool because there is no scene update loop,
16+
- reads normalized `GamepadState` snapshots through `InputService.getGamepads()`,
17+
- uses `GamepadInputAdapter` to interpret selected-device button/axis capture.
18+
19+
## Changes
20+
- Added a `Refresh Gamepads` action in the Capture accordion.
21+
- Added tool-owned gamepad polling so browser-exposed devices appear without Sample 0104 or a game scene loop.
22+
- Logs detected gamepad count and device names on initial refresh, manual refresh, connection events, and device-list changes.
23+
- Keeps one capture button per detected gamepad/device.
24+
- Keeps selected-device WARN logging when the device is visible but no active button/axis is pressed.
25+
- Updated Playwright coverage to mock `navigator.getGamepads()` directly, without dispatching Sample 0104 or relying on an engine frame.
26+
27+
## Playwright Impact
28+
Yes. This PR changes Input Mapping V2 capture UI, gamepad detection timing, and status logging.
29+
30+
Playwright now validates:
31+
- mocked `navigator.getGamepads()` detection without a Sample 0104 engine loop,
32+
- Refresh Gamepads logs detected count and device names,
33+
- per-device capture buttons remain one button per device,
34+
- combo/tile behavior from PR_26140_090 remains intact.
35+
36+
## Validation
37+
- PASS: targeted syntax/import validation for changed Input Mapping V2 files, focused Playwright file, and Sample 0104 files.
38+
- PASS: focused Input Mapping V2 Playwright validation:
39+
`npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs -g "launches Input Mapping V2 and captures keyboard mappings"`
40+
- PASS: targeted Sample 0104 launch validation with mocked `navigator.getGamepads()`; the sample page loaded, canvas appeared, and no page errors were raised.
41+
- PASS: no schema JSON changes.
42+
- PASS: no sample JSON changes.
43+
- PASS with extended timeout: the unrelated Object Vector Studio V2 test that timed out under the default suite passed with `--timeout=240000` in 2.7 minutes.
44+
- FAIL, classified unrelated timeout: `npm run test:workspace-v2` was run twice exactly as requested. Both runs completed 59 tests and timed out on `shows Object Vector Studio V2 layout shell and schema-only palette gate`, which is outside the PR_091 changed files. The same test passes with a larger timeout, indicating validation timeout debt rather than an Input Mapping V2 behavior regression.
45+
46+
Full samples smoke test was not run, per PR scope.
47+
48+
## Manual Validation
49+
1. Launch Input Mapping V2.
50+
2. Connect or expose a controller to the browser, then click Refresh Gamepads.
51+
3. Confirm the Status log reports the detected gamepad count and device names.
52+
4. Confirm one full-width capture button appears for each detected gamepad.
53+
5. Capture a selected device button or axis and confirm the token uses that device name/index.
54+
6. Confirm combo mappings and fixed-action tile display from PR_26140_090 still work.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# PR_26140_092 Input Mapping V2 Gamepad Diagnostics Report
2+
3+
## Scope
4+
- Added an Input Mapping V2 gamepad diagnostics panel/log section.
5+
- Preserved combo/tile behavior from PR_26140_090 and gamepad polling/refresh behavior from PR_26140_091.
6+
- Did not change schemas or sample JSON.
7+
- Did not change mapping behavior beyond diagnostics and the visible Start Listening / Poll Gamepads control.
8+
9+
## Diagnostics Added
10+
The new Gamepad Diagnostics accordion displays three sources side by side:
11+
- Raw `navigator.getGamepads()`.
12+
- Normalized `InputService` gamepad state after `InputService.update()`.
13+
- The Sample 0104-style engine/input path: `engine.input.getGamepads()` plus `engine.input.getGamepad(0)` through the same `InputService` instance.
14+
15+
The diagnostics show:
16+
- browser Gamepad API availability,
17+
- `navigator.getGamepads()` count,
18+
- each gamepad index,
19+
- each gamepad id/name,
20+
- connected flag,
21+
- button count,
22+
- axis count,
23+
- last poll timestamp,
24+
- whether the tool window has focus.
25+
26+
## Controls
27+
- `Refresh Gamepads` remains visible and refreshes detection/diagnostics.
28+
- Added visible `Start Listening / Poll Gamepads` to provide a user-gesture action for browsers that require focus or interaction before exposing gamepads.
29+
30+
## Playwright Impact
31+
Yes. This PR changes Input Mapping V2 UI diagnostics and gamepad polling controls.
32+
33+
Playwright coverage validates:
34+
- diagnostics displays raw gamepad count,
35+
- diagnostics displays device name/index metadata,
36+
- diagnostics displays focus/API state,
37+
- Refresh Gamepads updates diagnostics,
38+
- existing combo mapping and per-device capture behavior remains intact.
39+
40+
## Validation
41+
- PASS: targeted syntax/import validation for changed Input Mapping V2 files and focused Playwright file.
42+
- PASS: focused Input Mapping V2 Playwright validation:
43+
`npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs -g "launches Input Mapping V2 and captures keyboard mappings"`
44+
- PASS: `npm run test:workspace-v2` (`60 passed`).
45+
- PASS: no schema JSON changes.
46+
- PASS: no sample JSON changes.
47+
- PASS: coverage changed JS guardrail reported no warnings.
48+
49+
Full samples smoke test was not run, per PR scope.
50+
51+
## Manual Validation
52+
1. Launch Input Mapping V2.
53+
2. Open Gamepad Diagnostics.
54+
3. Confirm Browser API available, raw navigator count, focus state, and last poll timestamp are visible.
55+
4. Connect or wake a gamepad, then click Refresh Gamepads.
56+
5. Confirm raw navigator, InputService, and Sample 0104-style columns list the same device index/name/count details.
57+
6. Click Start Listening / Poll Gamepads if the browser does not expose the controller until a user gesture.

0 commit comments

Comments
 (0)