Commit 7939d12
committed
Profile switch: apply per-slot HM profile slug + transition MapTo without reset window
Two adjacent bugs in InputService.ApplyProfile, the runtime profile-
switch path:
1. SlotProfileIds was never applied. Switching profiles re-set
SlotCreated, SlotControllerTypes, ExtendedConfigs, MidiConfigs,
slot orders, and DSU/web/overlay state, but never touched
_mainVm.Pads[i].ProfileId. The HM profile slug stuck at whatever
the previous profile last set, so a slot configured for
xbox-one-s-bt in Profile A stayed on xbox-one-s-bt after
switching to Profile B even when B explicitly saved
xbox-series-xs-bt for that slot. Step 5's per-slot diff at
InputManager.Step5.VirtualDevices.cs:514-527 was already wired to
destroy + recreate slots whose desired SlotProfileIds[i] differs
from the live HMaestroVirtualController.ProfileId, but it never
fired because the desired array wasn't being updated. Add the
apply inside the topology loop, gated on willCreate so destroyed
slots don't pick up stale slugs.
2. Device-assignment apply used a reset-then-rebuild shape: every
us.MapTo set to -1, then reapply from profile.Entries. The lock
spans both phases but Step 5's IsSlotActive / HasAnyDeviceMapped
reads don't take that lock — they iterate UserSettings.Items
under a separate sync. So the polling thread can observe the
reset window and fall into the immediate-destroy path at
Step5:590-600 (slot inactive AND no devices mapped → destroy
now, no grace counter, no inactivity timeout). Slots whose
mapping is identical between old and new profile still get
destroyed and recreated, including kernel-slot reallocation and
the bubble-up cascade. Replace with a single-pass transition:
build the desired final assignment map from profile.Entries
first, then transition each UserSetting directly old→new MapTo
(or →-1 for entries dropped from the new profile). The "find an
unassigned UserSetting" gate switches from MapTo<0 (which
required the reset) to "not yet consumed by a prior entry in
this same apply pass." A device mapped to multiple slots in the
new profile still claims one UserSetting per entry.
Net behavior: switching profiles now correctly switches HM identity
on every slot whose stored profile slug differs, with pointer-
survival on slots that share the same slug (Step 5's existing diff
handles this — no new logic). Slots whose device mapping is
unchanged across profiles transition without any teardown at all,
where v3.0.1 would tear them down spuriously.1 parent 8dedb6b commit 7939d12
1 file changed
Lines changed: 55 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3575 | 3575 | | |
3576 | 3576 | | |
3577 | 3577 | | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
3578 | 3593 | | |
3579 | 3594 | | |
3580 | 3595 | | |
3581 | | - | |
3582 | | - | |
3583 | | - | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
3584 | 3611 | | |
3585 | 3612 | | |
3586 | | - | |
3587 | | - | |
| 3613 | + | |
| 3614 | + | |
3588 | 3615 | | |
3589 | 3616 | | |
3590 | 3617 | | |
3591 | 3618 | | |
3592 | 3619 | | |
3593 | 3620 | | |
3594 | | - | |
3595 | 3621 | | |
3596 | 3622 | | |
3597 | 3623 | | |
3598 | 3624 | | |
3599 | | - | |
3600 | | - | |
3601 | | - | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
3602 | 3631 | | |
3603 | | - | |
| 3632 | + | |
3604 | 3633 | | |
3605 | 3634 | | |
3606 | 3635 | | |
3607 | 3636 | | |
3608 | | - | |
| 3637 | + | |
3609 | 3638 | | |
3610 | 3639 | | |
3611 | | - | |
3612 | 3640 | | |
3613 | 3641 | | |
3614 | 3642 | | |
| |||
3619 | 3647 | | |
3620 | 3648 | | |
3621 | 3649 | | |
3622 | | - | |
3623 | | - | |
3624 | | - | |
3625 | | - | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
3626 | 3665 | | |
3627 | 3666 | | |
3628 | 3667 | | |
| |||
0 commit comments