Skip to content

Commit

Permalink
Clean up Santroller XInput matcher creation a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNathannator committed May 27, 2023
1 parent 888f252 commit 3c24718
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal static SantrollerDeviceType GetDeviceType(ushort version)
internal static SantrollerRhythmType GetRhythmType(ushort version)
=> (SantrollerRhythmType)((version >> 4) & 0x0F);

internal static int GetRevisionValue(SantrollerDeviceType deviceType, SantrollerRhythmType rhythmType, int consoleType)
internal static int GetRevisionValue(SantrollerDeviceType deviceType, SantrollerRhythmType rhythmType, int consoleType = 0)
=> (((int)deviceType & 0xFF) << 8) | (((int)rhythmType & 0x0F) << 4) | (consoleType & 0x0F);

internal static void RegisterHIDLayout<TDevice>(SantrollerDeviceType deviceType,
Expand Down Expand Up @@ -116,13 +116,11 @@ internal static InputDeviceMatcher GetXInputMatcher(int subType,
{
if (deviceType == SantrollerDeviceType.Unknown)
(deviceType, rhythmType) = s_XInputSubtypeToDeviceType[subType];
int revision = (((int)deviceType) << 8) | (((int)rhythmType) << 4);
int revision = GetRevisionValue(deviceType, rhythmType);

return new InputDeviceMatcher()
.WithInterface(XInputLayoutFinder.InterfaceName)
.WithCapability("subType", subType)
.WithCapability("gamepad/leftStickX", (int)VendorID)
.WithCapability("gamepad/leftStickY", (int)ProductID)
return XInputLayoutFinder.GetMatcher(subType)
.WithCapability("gamepad/leftStickX", VendorID)
.WithCapability("gamepad/leftStickY", ProductID)
.WithCapability("gamepad/rightStickX", revision);
}
}
Expand Down

0 comments on commit 3c24718

Please sign in to comment.