Skip to content

Fix/unipad keyled ownership tracking#9

Open
GauravM512 wants to merge 3 commits into
anthonyhfm:mainfrom
GauravM512:fix/unipad-keyled-ownership-tracking
Open

Fix/unipad keyled ownership tracking#9
GauravM512 wants to merge 3 commits into
anthonyhfm:mainfrom
GauravM512:fix/unipad-keyled-ownership-tracking

Conversation

@GauravM512

Copy link
Copy Markdown
Contributor

Description

This fixes an issue where multiple parallel KeyLED files could interfere with each other in Unipad conversions.

In Unipad, each pad keeps track of a single active LED "owner". When an animation takes ownership of a pad, any older animation that was previously controlling that pad can no longer turn it off. If it later sends an Off event, that event is ignored. This is what allows overlapping animations to coexist without unexpectedly clearing each other's colors.

Amethyst wasn't following this behavior. Since all KeyframesChainDevice signals were being emitted on the same layer, an Off event from one file would remove the shared signal entry and unintentionally clear the output from other files using the same pad.

This PR introduces an optional UnipadOwnershipTracker that mirrors Unipad's KeyLED handling. The tracker is enabled only for Unipad conversions through KeyframesChainDeviceState.useOwnershipTracking, so the change is isolated and doesn't affect other converters.

Example:

  • KeyLED A turns a pad On → owner = A
  • KeyLED B turns the same pad On → owner = B
  • KeyLED A sends Off → ignored (A is no longer the owner)
  • KeyLED B sends Off → pad is cleared

This matches Unipad's behavior and prevents one animation from accidentally turning off another.

A comparison video is included below. Left: current/default behavior. Right: behavior with this fix applied (matches Unipad).
Using Shape of You Unipack.

References

This implementation mirrors Unipad's LED ownership behavior:

  • LedRunner.kt (btnLed ownership check when processing Off events)
  • LedRunner.kt (Led.equal() comparison used to verify ownership)
  • UniPack.kt (ledGet() / ledPush() ownership storage and updates)

Source: [Unipad Android Repository]

unipad.led.ownership.mp4

@GauravM512

Copy link
Copy Markdown
Contributor Author

Here's a preview of final frame fading fix(0d3d9af)
Preserves the final frame where it is not supposed to fade same as Unipad/Unitor behavior

Left: current/default behavior. Right: behavior with this fix applied

lastframe.fix.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant