Skip to content

Commit

Permalink
Added more pro-guitar controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Mar 11, 2023
1 parent 9dbf1c5 commit 9796998
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 31 deletions.
8 changes: 8 additions & 0 deletions Assets/Script/Input/ProGuitar.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Layouts;

namespace YARG.Input {

#if UNITY_EDITOR
// Make sure static constructor is called during startup.
[InitializeOnLoad]
#endif

[InputControlLayout(stateType = typeof(ProGuitarMadCatzInputReport))]
public class ProGuitarMadCatzGampad : InputDevice {
public abstract class AbstractProGuitarGampad : InputDevice {
public IntegerControl Fret0 {
get;
private set;
Expand Down Expand Up @@ -104,19 +94,5 @@ public IntegerControl GetStringControl(int i) {
_ => null
};
}

static ProGuitarMadCatzGampad() {
// Wii Fender Mustang
InputSystem.RegisterLayout<ProGuitarMadCatzGampad>(matches: new InputDeviceMatcher()
.WithInterface("HID")
.WithCapability("vendorId", 0x1BAD)
.WithCapability("productId", 0x3430));
}

// Make sure the static constructor above is called during startup (runtime).
[RuntimeInitializeOnLoadMethod]
private static void Init() {

}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Assets/Script/Input/ProGuitar/HIDProGuitarDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Layouts;

namespace YARG.Input {

#if UNITY_EDITOR
// Make sure static constructor is called during startup.
[InitializeOnLoad]
#endif

[InputControlLayout(stateType = typeof(HIDProGuitarInputReport))]
public class HIDProGuitarGampad : AbstractProGuitarGampad {
static HIDProGuitarGampad() {
// Wii Fender Mustang
InputSystem.RegisterLayout<HIDProGuitarGampad>(matches: new InputDeviceMatcher()
.WithInterface("HID")
.WithCapability("vendorId", 0x1BAD)
.WithCapability("productId", 0x3430));

// PS3 Fender Mustang
InputSystem.RegisterLayout<HIDProGuitarGampad>(matches: new InputDeviceMatcher()
.WithInterface("HID")
.WithCapability("vendorId", 0x12BA)
.WithCapability("productId", 0x2430));
}

// Make sure the static constructor above is called during startup (runtime).
[RuntimeInitializeOnLoadMethod]
private static void Init() {

}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace YARG.Input {
[StructLayout(LayoutKind.Explicit, Size = 27)]
public struct ProGuitarMadCatzInputReport : IInputStateTypeInfo {
public struct HIDProGuitarInputReport : IInputStateTypeInfo {
public FourCC format => new('H', 'I', 'D');

[InputControl(name = "fret0", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 5)]
Expand Down
11 changes: 11 additions & 0 deletions Assets/Script/Input/ProGuitar/HIDProGuitarInputReport.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Assets/Script/Input/ProGuitar/XInpProGuitarDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Layouts;

namespace YARG.Input {

#if UNITY_EDITOR
// Make sure static constructor is called during startup.
[InitializeOnLoad]
#endif

[InputControlLayout(stateType = typeof(XInpProGuitarInputReport))]
public class XInpProGuitarGampad : AbstractProGuitarGampad {
static XInpProGuitarGampad() {
// Xbox Fender Mustang
// NOTE: Should only works on Windows. XInput is handled differently on different platforms.
InputSystem.RegisterLayout<XInpProGuitarGampad>(matches: new InputDeviceMatcher()
.WithInterface("XInput")
.WithCapability("subType", 25));
}

// Make sure the static constructor above is called during startup (runtime).
[RuntimeInitializeOnLoadMethod]
private static void Init() {

}
}
}
11 changes: 11 additions & 0 deletions Assets/Script/Input/ProGuitar/XInpProGuitarDevice.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Assets/Script/Input/ProGuitar/XInpProGuitarInputReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Utilities;

namespace YARG.Input {
[StructLayout(LayoutKind.Explicit, Size = 27)]
public struct XInpProGuitarInputReport : IInputStateTypeInfo {
public FourCC format => new('X', 'I', 'N', 'P');

[InputControl(name = "fret0", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 5)]
[InputControl(name = "fret1", format = "BIT", layout = "Integer", bit = 5, sizeInBits = 5)]
[InputControl(name = "fret2", format = "BIT", layout = "Integer", bit = 10, sizeInBits = 5)]
[InputControl(name = "fret3", format = "BIT", layout = "Integer", bit = 16, sizeInBits = 5)]
[InputControl(name = "fret4", format = "BIT", layout = "Integer", bit = 21, sizeInBits = 5)]
[InputControl(name = "fret5", format = "BIT", layout = "Integer", bit = 26, sizeInBits = 5)]
[FieldOffset(6)]
public int fretStates;

[InputControl(name = "string0", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 7)]
[FieldOffset(10)]
public byte str0Velocity;
[InputControl(name = "string1", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 7)]
[FieldOffset(11)]
public byte str1Velocity;
[InputControl(name = "string2", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 7)]
[FieldOffset(12)]
public byte str2Velocity;
[InputControl(name = "string3", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 7)]
[FieldOffset(13)]
public byte str3Velocity;
[InputControl(name = "string4", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 7)]
[FieldOffset(14)]
public byte str4Velocity;
[InputControl(name = "string5", format = "BIT", layout = "Integer", bit = 0, sizeInBits = 7)]
[FieldOffset(15)]
public byte str5Velocity;

[FieldOffset(25)]
public short reportId;
}
}
11 changes: 11 additions & 0 deletions Assets/Script/Input/ProGuitar/XInpProGuitarInputReport.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Assets/Script/Input/RealGuitarInputStrategy.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using YARG.Data;

namespace YARG.Input {
Expand Down Expand Up @@ -38,7 +37,7 @@ public override string[] GetMappingNames() {
}

public override void UpdatePlayerMode() {
if (inputDevice is not ProGuitarMadCatzGampad input) {
if (inputDevice is not AbstractProGuitarGampad input) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ PlayerSettings:
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.1.0
preloadedAssets: []
preloadedAssets:
- {fileID: 11400000, guid: 8efbce013f4e1c34895851b7038c76e9, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
Expand Down

0 comments on commit 9796998

Please sign in to comment.