diff --git a/Packages/com.thenathannator.plasticband/CHANGELOG.md b/Packages/com.thenathannator.plasticband/CHANGELOG.md index d0473b7..df9e208 100644 --- a/Packages/com.thenathannator.plasticband/CHANGELOG.md +++ b/Packages/com.thenathannator.plasticband/CHANGELOG.md @@ -19,6 +19,7 @@ Dates are relative to UTC. - Fixed Pro Keyboard `GetKeyMask` returning an inverted mask (i.e. bit 24 was key 1 rather than bit 0). - Fixed Santroller guitars not having the correct default state value set. - Fixed various input control extensions not working on devices that use the new state translation infrastructure. +- Fixed yellow/green pad/cymbal velocities on XInput 4-lane drumkits being inverted. ### Removed diff --git a/Packages/com.thenathannator.plasticband/PlasticBand/Devices/FourLaneDrumkit/XInputFourLaneDrumkit.cs b/Packages/com.thenathannator.plasticband/PlasticBand/Devices/FourLaneDrumkit/XInputFourLaneDrumkit.cs index bc3400e..f3496d1 100644 --- a/Packages/com.thenathannator.plasticband/PlasticBand/Devices/FourLaneDrumkit/XInputFourLaneDrumkit.cs +++ b/Packages/com.thenathannator.plasticband/PlasticBand/Devices/FourLaneDrumkit/XInputFourLaneDrumkit.cs @@ -118,51 +118,57 @@ public bool dpadRight byte IFourLaneDrumkitState_Flags.redPadVelocity { - get => GetVelocity(redVelocity); - set => SetVelocity(ref redVelocity, value); + get => GetVelocity_Positive(redVelocity); + set => SetVelocity_Positive(ref redVelocity, value); } byte IFourLaneDrumkitState_Flags.yellowPadVelocity { - get => GetVelocity(yellowVelocity); - set => SetVelocity(ref yellowVelocity, value); + get => GetVelocity_Negative(yellowVelocity); + set => SetVelocity_Negative(ref yellowVelocity, value); } byte IFourLaneDrumkitState_Flags.bluePadVelocity { - get => GetVelocity(blueVelocity); - set => SetVelocity(ref blueVelocity, value); + get => GetVelocity_Positive(blueVelocity); + set => SetVelocity_Positive(ref blueVelocity, value); } byte IFourLaneDrumkitState_Flags.greenPadVelocity { - get => GetVelocity(greenVelocity); - set => SetVelocity(ref greenVelocity, value); + get => GetVelocity_Negative(greenVelocity); + set => SetVelocity_Negative(ref greenVelocity, value); } byte IFourLaneDrumkitState_Flags.yellowCymbalVelocity { - get => GetVelocity(yellowVelocity); - set => SetVelocity(ref yellowVelocity, value); + get => GetVelocity_Negative(yellowVelocity); + set => SetVelocity_Negative(ref yellowVelocity, value); } byte IFourLaneDrumkitState_Flags.blueCymbalVelocity { - get => GetVelocity(blueVelocity); - set => SetVelocity(ref blueVelocity, value); + get => GetVelocity_Positive(blueVelocity); + set => SetVelocity_Positive(ref blueVelocity, value); } byte IFourLaneDrumkitState_Flags.greenCymbalVelocity { - get => GetVelocity(greenVelocity); - set => SetVelocity(ref greenVelocity, value); + get => GetVelocity_Negative(greenVelocity); + set => SetVelocity_Negative(ref greenVelocity, value); } - private static byte GetVelocity(short velocity) + private static byte GetVelocity_Positive(short velocity) => (byte)((~velocity & 0x7FFF) >> 7); - private static void SetVelocity(ref short velocity, byte value) + private static byte GetVelocity_Negative(short velocity) + => (byte)((velocity & 0x7FFF) >> 7); + + private static void SetVelocity_Positive(ref short velocity, byte value) => velocity = (short)(~value << 7); + + private static void SetVelocity_Negative(ref short velocity, byte value) + => velocity = (short)(value << 7); } [StructLayout(LayoutKind.Sequential, Pack = 1)]