From a5fa34f8b004a8a2d2eb00844131b347372218e1 Mon Sep 17 00:00:00 2001 From: William Lebel Date: Sun, 28 May 2023 16:21:51 -0400 Subject: [PATCH] Add custom control scheme for new input asset Doesn't work yet with arcade inputs --- Assets/ConjureOS-SDK.meta | 8 + Assets/ConjureOS-SDK/Scripts.meta | 8 + Assets/ConjureOS-SDK/Scripts/Editor.meta | 8 + Assets/ConjureOS-SDK/Scripts/InputSystem.meta | 3 + .../InputSystem/ConjureArcadeController.cs | 339 ++++++++++++++ .../ConjureArcadeController.cs.meta | 3 + .../Scripts/InputSystem/ConjureInputSystem.cs | 30 ++ .../InputSystem/ConjureInputSystem.cs.meta | 3 + Assets/Scenes/SampleScene.unity | 100 ++++- Assets/Test-Input.meta | 8 + Assets/Test-Input/Test.cs | 424 ++++++++++++++++++ Assets/Test-Input/Test.cs.meta | 11 + Assets/Test-Input/Test.inputactions | 217 +++++++++ Assets/Test-Input/Test.inputactions.meta | 14 + Assets/Test-Input/TestInputBehavior.cs | 70 +++ Assets/Test-Input/TestInputBehavior.cs.meta | 11 + Packages/manifest.json | 1 + Packages/packages-lock.json | 9 + ProjectSettings/ProjectSettings.asset | 2 +- ProjectSettings/SceneTemplateSettings.json | 167 +++++++ 20 files changed, 1425 insertions(+), 11 deletions(-) create mode 100644 Assets/ConjureOS-SDK.meta create mode 100644 Assets/ConjureOS-SDK/Scripts.meta create mode 100644 Assets/ConjureOS-SDK/Scripts/Editor.meta create mode 100644 Assets/ConjureOS-SDK/Scripts/InputSystem.meta create mode 100644 Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs create mode 100644 Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs.meta create mode 100644 Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs create mode 100644 Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs.meta create mode 100644 Assets/Test-Input.meta create mode 100644 Assets/Test-Input/Test.cs create mode 100644 Assets/Test-Input/Test.cs.meta create mode 100644 Assets/Test-Input/Test.inputactions create mode 100644 Assets/Test-Input/Test.inputactions.meta create mode 100644 Assets/Test-Input/TestInputBehavior.cs create mode 100644 Assets/Test-Input/TestInputBehavior.cs.meta create mode 100644 ProjectSettings/SceneTemplateSettings.json diff --git a/Assets/ConjureOS-SDK.meta b/Assets/ConjureOS-SDK.meta new file mode 100644 index 0000000..43393bc --- /dev/null +++ b/Assets/ConjureOS-SDK.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f384b751500f6074f844214aa12360b0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ConjureOS-SDK/Scripts.meta b/Assets/ConjureOS-SDK/Scripts.meta new file mode 100644 index 0000000..5b8fb47 --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2dbc2a9fc657c7c49ad7589198f093e2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ConjureOS-SDK/Scripts/Editor.meta b/Assets/ConjureOS-SDK/Scripts/Editor.meta new file mode 100644 index 0000000..4c79252 --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4968396d1c0a1a4409395e0b48e64580 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ConjureOS-SDK/Scripts/InputSystem.meta b/Assets/ConjureOS-SDK/Scripts/InputSystem.meta new file mode 100644 index 0000000..5200be1 --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts/InputSystem.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2ffaf48f91334e9ab682a5785caa93fc +timeCreated: 1685298626 \ No newline at end of file diff --git a/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs new file mode 100644 index 0000000..498daca --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs @@ -0,0 +1,339 @@ +#if ENABLE_INPUT_SYSTEM +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using UnityEngine; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Controls; +using UnityEngine.InputSystem.Layouts; +using UnityEngine.InputSystem.LowLevel; +using UnityEngine.InputSystem.Utilities; +using ConjureOS.Input.LowLevel; +using UnityEngine.InputSystem.Users; + +using System.Collections.Generic; +using ArrayHelpers = ConjureOS.Input.Utilities.ArrayHelpers; + +namespace ConjureOS.Input.Utilities +{ + /// + /// A collection of utility functions for working with arrays. + /// + /// + /// The goal of this collection is to make it easy to use arrays directly rather than resorting to + /// . + /// + internal static class ArrayHelpers + { + public static int IndexOfReference(this TFirst[] array, TSecond value, int count = -1) + where TSecond : class + where TFirst : TSecond + { + return IndexOfReference(array, value, 0, count); + } + + public static int IndexOfReference(this TFirst[] array, TSecond value, int startIndex, int count) + where TSecond : class + where TFirst : TSecond + { + if (array == null) + return -1; + + if (count < 0) + count = array.Length - startIndex; + for (var i = startIndex; i < startIndex + count; ++i) + if (ReferenceEquals(array[i], value)) + return i; + + return -1; + } + + public static int AppendWithCapacity(ref TValue[] array, ref int count, TValue value, int capacityIncrement = 10) + { + if (array == null) + { + array = new TValue[capacityIncrement]; + array[0] = value; + ++count; + return 0; + } + + var capacity = array.Length; + if (capacity == count) + { + capacity += capacityIncrement; + Array.Resize(ref array, capacity); + } + + var index = count; + array[index] = value; + ++count; + + return index; + } + + public static void EraseAtWithCapacity(this TValue[] array, ref int count, int index) + { + Debug.Assert(array != null); + Debug.Assert(count <= array.Length); + Debug.Assert(index >= 0 && index < count); + + // If we're erasing from the beginning or somewhere in the middle, move + // the array contents down from after the index. + if (index < count - 1) + { + Array.Copy(array, index + 1, array, index, count - index - 1); + } + + array[count - 1] = default; // Tail has been moved down by one. + --count; + } + } +} + + +namespace ConjureOS.Input.LowLevel +{ + /// + /// Default state layout for Conjure Arcade controllers. + /// + /// + [StructLayout(LayoutKind.Explicit, Size = 28)] + public struct ConjureArcadeControllerState : IInputStateTypeInfo + { + public static FourCC Format => new FourCC('C', 'N', 'J', 'A'); + + /// + /// Button bit mask. + /// + /// Button bit mask. + /// + /// + /// + /// + /// + /// + /// + /// + /// + [InputControl(name = "buttonA", layout = "Button", bit = (uint)ConjureArcadeControllerButton.ButtonA, displayName = "Button A", shortDisplayName = "A")] + [InputControl(name = "buttonB", layout = "Button", bit = (uint)ConjureArcadeControllerButton.ButtonB, displayName = "Button B", shortDisplayName = "B")] + [InputControl(name = "buttonC", layout = "Button", bit = (uint)ConjureArcadeControllerButton.ButtonC, displayName = "Button C", shortDisplayName = "C")] + + [InputControl(name = "button1", layout = "Button", bit = (uint)ConjureArcadeControllerButton.Button1, displayName = "Button 1", shortDisplayName = "1")] + [InputControl(name = "button2", layout = "Button", bit = (uint)ConjureArcadeControllerButton.Button2, displayName = "Button 2", shortDisplayName = "2")] + [InputControl(name = "button3", layout = "Button", bit = (uint)ConjureArcadeControllerButton.Button3, displayName = "Button 3", shortDisplayName = "3")] + + [InputControl(name = "buttonStart", layout = "Button", bit = (uint)ConjureArcadeControllerButton.ButtonStart, usages = new[] { "Join", "Pause" }, displayName = "Button Start", shortDisplayName = "Start")] + [InputControl(name = "buttonPower", layout = "Button", bit = (uint)ConjureArcadeControllerButton.ButtonPower, usages = new[] { "Power", "Exit" }, displayName = "Button Power", shortDisplayName = "Power")] + [FieldOffset(0)] + public uint buttons; + + /// + /// Stick position. Each axis goes from -1 to 1 with + /// 0 being center position. + /// + /// Left stick position. + /// + [InputControl(layout = "Stick", usage = "Primary2DMotion", processors = "stickDeadzone", displayName = "Stick", shortDisplayName = "S")] + [FieldOffset(4)] + public Vector2 stick; + + /// + /// State format tag for GamepadState. + /// + /// Returns "CNJA". + public FourCC format => Format; + + /// + /// Create a gamepad state with the given buttons being pressed. + /// + /// Buttons to put into pressed state. + /// is null. + public ConjureArcadeControllerState(params GamepadButton[] buttons) + : this() + { + if (buttons == null) + throw new ArgumentNullException(nameof(buttons)); + + foreach (var button in buttons) + { + Debug.Assert((int)button < 32, $"Expected button < 32, so we fit into the 32 bit wide bitmask"); + var bit = 1U << (int)button; + this.buttons |= bit; + } + } + + /// + /// Set the specific buttons to be pressed or unpressed. + /// + /// A gamepad button. + /// Whether to set to be pressed or not pressed in + /// . + /// GamepadState with a modified mask. + public ConjureArcadeControllerState WithButton(GamepadButton button, bool value = true) + { + Debug.Assert((int)button < 32, $"Expected button < 32, so we fit into the 32 bit wide bitmask"); + var bit = 1U << (int)button; + if (value) + buttons |= bit; + else + buttons &= ~bit; + return this; + } + } + + public enum ConjureArcadeControllerButton + { + ButtonA = 0, + ButtonB = 1, + ButtonC = 2, + + Button1 = 3, + Button2 = 4, + Button3 = 5, + + ButtonStart = 6, + ButtonPower = 7, + } +} + +namespace ConjureOS.Input +{ + [InputControlLayout(stateType = typeof(ConjureArcadeControllerState), displayName = "Conjure Arcade Controller")] + public class ConjureArcadeController : InputDevice + { + public ButtonControl buttonA { get; protected set; } + public ButtonControl buttonB { get; protected set; } + public ButtonControl buttonC { get; protected set; } + + public ButtonControl button1 { get; protected set; } + public ButtonControl button2 { get; protected set; } + public ButtonControl button3 { get; protected set; } + + public ButtonControl buttonStart { get; protected set; } + public ButtonControl buttonPower { get; protected set; } + + public StickControl stick { get; protected set; } + + /// + /// Retrieve a gamepad button by its enumeration + /// constant. + /// + /// Button to retrieve. + /// is not a valid gamepad + /// button value. + public ButtonControl this[ConjureArcadeControllerButton button] + { + get + { + switch (button) + { + case ConjureArcadeControllerButton.ButtonA: return buttonA; + case ConjureArcadeControllerButton.ButtonB: return buttonB; + case ConjureArcadeControllerButton.ButtonC: return buttonC; + case ConjureArcadeControllerButton.Button1: return button1; + case ConjureArcadeControllerButton.Button2: return button2; + case ConjureArcadeControllerButton.Button3: return button3; + case ConjureArcadeControllerButton.ButtonStart: return buttonStart; + case ConjureArcadeControllerButton.ButtonPower: return buttonPower; + default: + throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(GamepadButton)); + } + } + } + + /// + /// The gamepad last used/connected by the player or null if there is no gamepad connected + /// to the system. + /// + /// + /// When added, a device is automatically made current (see ), so + /// when connecting a gamepad, it will also become current. After that, it will only become current again + /// when input change on non-noisy controls (see ) is received. + /// + /// For local multiplayer scenarios (or whenever there are multiple gamepads that need to be usable + /// in a concurrent fashion), it is not recommended to rely on this property. Instead, it is recommended + /// to use or . + /// + /// + /// + public static ConjureArcadeController current { get; private set; } + + /// + /// A list of gamepads currently connected to the system. + /// + /// All currently connected gamepads. + /// + /// Does not cause GC allocation. + /// + /// Do not hold on to the value returned by this getter but rather query it whenever + /// you need it. Whenever the gamepad setup changes, the value returned by this getter + /// is invalidated. + /// + /// + public new static ReadOnlyArray all => new(s_Gamepads, 0, s_GamepadCount); + + /// + protected override void FinishSetup() + { + buttonA = GetChildControl("buttonA"); + buttonB = GetChildControl("buttonB"); + buttonC = GetChildControl("buttonC"); + + button1 = GetChildControl("button1"); + button2 = GetChildControl("button2"); + button3 = GetChildControl("button3"); + + buttonStart = GetChildControl("buttonStart"); + buttonPower = GetChildControl("buttonPower"); + + stick = GetChildControl("stick"); + + base.FinishSetup(); + } + + /// + /// Make the gamepad the gamepad. + /// + /// + /// This is called automatically by the system when there is input on a gamepad. + /// + public override void MakeCurrent() + { + base.MakeCurrent(); + current = this; + } + + /// + /// Called when the gamepad is added to the system. + /// + protected override void OnAdded() + { + ArrayHelpers.AppendWithCapacity(ref s_Gamepads, ref s_GamepadCount, this); + } + + /// + /// Called when the gamepad is removed from the system. + /// + protected override void OnRemoved() + { + if (current == this) + current = null; + + // Remove from `all`. + var index = ArrayHelpers.IndexOfReference(s_Gamepads, this, s_GamepadCount); + if (index != -1) + ArrayHelpers.EraseAtWithCapacity(s_Gamepads, ref s_GamepadCount, index); + else + { + Debug.Assert(false, + $"Gamepad {this} seems to not have been added but is being removed (gamepad list: {string.Join(", ", all)})"); // Put in else to not allocate on normal path. + } + } + + private static int s_GamepadCount; + private static ConjureArcadeController[] s_Gamepads; + } +} +#endif \ No newline at end of file diff --git a/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs.meta b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs.meta new file mode 100644 index 0000000..0791ad4 --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureArcadeController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e62e8126e50e4fd2b062c6a83533560e +timeCreated: 1685298675 \ No newline at end of file diff --git a/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs new file mode 100644 index 0000000..dc703e8 --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs @@ -0,0 +1,30 @@ +using UnityEditor; +using UnityEngine; +using UnityEngine.InputSystem.Layouts; +using UnityEngine.InputSystem; + +namespace ConjureOS.Input +{ +#if UNITY_EDITOR + [InitializeOnLoad] // Call static class constructor in editor. +#endif + static public class ConjureInputSystem + { + static ConjureInputSystem() + { + Debug.Log("Mamamiiiiia"); +#if UNITY_EDITOR + InitializeInEditor(); +#endif + } + + static void InitializeInEditor() + { +#if UNITY_EDITOR && ENABLE_INPUT_SYSTEM + InputSystem.RegisterLayout( + matches: new InputDeviceMatcher() + .WithInterface("ConjureArcadeController")); +#endif + } + } +} \ No newline at end of file diff --git a/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs.meta b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs.meta new file mode 100644 index 0000000..e18dcd6 --- /dev/null +++ b/Assets/ConjureOS-SDK/Scripts/InputSystem/ConjureInputSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 30d9c0af719248758be0853447bb0b6f +timeCreated: 1685303377 \ No newline at end of file diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 2221b04..298bb20 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -118,6 +118,8 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 debug: m_Flags: 0 m_NavMeshData: {fileID: 0} @@ -125,7 +127,8 @@ NavMeshSettings: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 705507995} @@ -141,15 +144,18 @@ GameObject: Light: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 705507993} m_Enabled: 1 - serializedVersion: 8 + serializedVersion: 10 m_Type: 1 + m_Shape: 0 m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} m_Intensity: 1 m_Range: 10 m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 m_CookieSize: 10 m_Shadows: m_Type: 2 @@ -159,6 +165,24 @@ Light: m_Bias: 0.05 m_NormalBias: 0.4 m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 m_Cookie: {fileID: 0} m_DrawHalo: 0 m_Flare: {fileID: 0} @@ -166,23 +190,29 @@ Light: m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 + m_RenderingLayerMask: 1 m_Lightmapping: 1 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 6570 m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!4 &705507995 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 705507993} m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 1 @@ -191,7 +221,8 @@ Transform: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 963194228} @@ -208,23 +239,26 @@ GameObject: AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_Enabled: 1 --- !u!20 &963194227 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_GateFitMode: 2 m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 @@ -256,12 +290,58 @@ Camera: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1522364153 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1522364155} + - component: {fileID: 1522364154} + m_Layer: 0 + m_Name: Testo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1522364154 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1522364153} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c0e6fe775cd2edd45944811c411d4dde, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1522364155 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1522364153} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3.8084364, y: -1.0925081, z: -10.868857} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Test-Input.meta b/Assets/Test-Input.meta new file mode 100644 index 0000000..12c13eb --- /dev/null +++ b/Assets/Test-Input.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1962d2e88e914bd4fb1f59490b888101 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Test-Input/Test.cs b/Assets/Test-Input/Test.cs new file mode 100644 index 0000000..4bf1c01 --- /dev/null +++ b/Assets/Test-Input/Test.cs @@ -0,0 +1,424 @@ +//------------------------------------------------------------------------------ +// +// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator +// version 1.4.4 +// from Assets/Test-Input/Test.inputactions +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Utilities; + +public partial class @TheTestInputs : IInputActionCollection2, IDisposable +{ + public InputActionAsset asset { get; } + public @TheTestInputs() + { + asset = InputActionAsset.FromJson(@"{ + ""name"": ""Test"", + ""maps"": [ + { + ""name"": ""Test"", + ""id"": ""8c830899-5b93-4485-b6cf-690688a32987"", + ""actions"": [ + { + ""name"": ""PressButton1"", + ""type"": ""Button"", + ""id"": ""7fc97698-5a30-4ede-b705-3089212e33a4"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButton2"", + ""type"": ""Button"", + ""id"": ""36279e50-c398-4905-a495-8c9a0c7ea6a0"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButton3"", + ""type"": ""Button"", + ""id"": ""5e4a401d-31b5-4238-be45-fcb742db8257"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButtonA"", + ""type"": ""Button"", + ""id"": ""282753cf-d354-460a-b3d8-897b57100e1c"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButtonB"", + ""type"": ""Button"", + ""id"": ""bcb4b7cb-c447-4222-8b17-021f5992da49"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButtonC"", + ""type"": ""Button"", + ""id"": ""72e5810c-02b1-45de-a7a9-e0732cc11a84"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButtonStart"", + ""type"": ""Button"", + ""id"": ""85317456-76d2-423e-bfbe-4c59f9412c30"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""PressButtonPower"", + ""type"": ""Button"", + ""id"": ""5e2022da-d536-4c6d-b997-9b9005b5fcc1"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""Move"", + ""type"": ""Value"", + ""id"": ""1efea12d-0e62-4272-98f2-419a3972b23e"", + ""expectedControlType"": ""Vector2"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": true + } + ], + ""bindings"": [ + { + ""name"": """", + ""id"": ""1b6d6e5f-df9e-4700-b09a-58d03a083c57"", + ""path"": ""/button1"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButton1"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""52815d9a-0ebf-48b6-ae4f-0db59a5e0785"", + ""path"": ""/l"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""PressButton1"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""dd68c926-eaf2-402d-a3dc-c0c0e5278960"", + ""path"": ""/button2"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButton2"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""c4ec34c3-a5b5-4d25-951d-2c4e9ae5567f"", + ""path"": ""/button3"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButton3"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""5d36faa3-e6f9-4d7e-a708-8fa196d0bfa2"", + ""path"": ""/buttonA"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButtonA"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""a7c51fe1-33ec-4c06-9cec-0f45917c7347"", + ""path"": ""/buttonB"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButtonB"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""e580378c-77e5-413f-9dff-8b10adca2e64"", + ""path"": ""/buttonC"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButtonC"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""a7d5c7a7-7684-4f91-b0f1-c27cf506a3f6"", + ""path"": ""/buttonStart"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButtonStart"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""3cd16b1e-35e3-4be2-9e3e-e68a8470ba76"", + ""path"": ""/buttonPower"", + ""interactions"": """", + ""processors"": """", + ""groups"": ""New control scheme"", + ""action"": ""PressButtonPower"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""7628f7a3-2ff4-41b8-8f72-a8c723238dff"", + ""path"": ""/stick"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": false + } + ] + } + ], + ""controlSchemes"": [ + { + ""name"": ""New control scheme"", + ""bindingGroup"": ""New control scheme"", + ""devices"": [ + { + ""devicePath"": """", + ""isOptional"": false, + ""isOR"": false + } + ] + } + ] +}"); + // Test + m_Test = asset.FindActionMap("Test", throwIfNotFound: true); + m_Test_PressButton1 = m_Test.FindAction("PressButton1", throwIfNotFound: true); + m_Test_PressButton2 = m_Test.FindAction("PressButton2", throwIfNotFound: true); + m_Test_PressButton3 = m_Test.FindAction("PressButton3", throwIfNotFound: true); + m_Test_PressButtonA = m_Test.FindAction("PressButtonA", throwIfNotFound: true); + m_Test_PressButtonB = m_Test.FindAction("PressButtonB", throwIfNotFound: true); + m_Test_PressButtonC = m_Test.FindAction("PressButtonC", throwIfNotFound: true); + m_Test_PressButtonStart = m_Test.FindAction("PressButtonStart", throwIfNotFound: true); + m_Test_PressButtonPower = m_Test.FindAction("PressButtonPower", throwIfNotFound: true); + m_Test_Move = m_Test.FindAction("Move", throwIfNotFound: true); + } + + public void Dispose() + { + UnityEngine.Object.Destroy(asset); + } + + public InputBinding? bindingMask + { + get => asset.bindingMask; + set => asset.bindingMask = value; + } + + public ReadOnlyArray? devices + { + get => asset.devices; + set => asset.devices = value; + } + + public ReadOnlyArray controlSchemes => asset.controlSchemes; + + public bool Contains(InputAction action) + { + return asset.Contains(action); + } + + public IEnumerator GetEnumerator() + { + return asset.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Enable() + { + asset.Enable(); + } + + public void Disable() + { + asset.Disable(); + } + public IEnumerable bindings => asset.bindings; + + public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false) + { + return asset.FindAction(actionNameOrId, throwIfNotFound); + } + public int FindBinding(InputBinding bindingMask, out InputAction action) + { + return asset.FindBinding(bindingMask, out action); + } + + // Test + private readonly InputActionMap m_Test; + private ITestActions m_TestActionsCallbackInterface; + private readonly InputAction m_Test_PressButton1; + private readonly InputAction m_Test_PressButton2; + private readonly InputAction m_Test_PressButton3; + private readonly InputAction m_Test_PressButtonA; + private readonly InputAction m_Test_PressButtonB; + private readonly InputAction m_Test_PressButtonC; + private readonly InputAction m_Test_PressButtonStart; + private readonly InputAction m_Test_PressButtonPower; + private readonly InputAction m_Test_Move; + public struct TestActions + { + private @TheTestInputs m_Wrapper; + public TestActions(@TheTestInputs wrapper) { m_Wrapper = wrapper; } + public InputAction @PressButton1 => m_Wrapper.m_Test_PressButton1; + public InputAction @PressButton2 => m_Wrapper.m_Test_PressButton2; + public InputAction @PressButton3 => m_Wrapper.m_Test_PressButton3; + public InputAction @PressButtonA => m_Wrapper.m_Test_PressButtonA; + public InputAction @PressButtonB => m_Wrapper.m_Test_PressButtonB; + public InputAction @PressButtonC => m_Wrapper.m_Test_PressButtonC; + public InputAction @PressButtonStart => m_Wrapper.m_Test_PressButtonStart; + public InputAction @PressButtonPower => m_Wrapper.m_Test_PressButtonPower; + public InputAction @Move => m_Wrapper.m_Test_Move; + public InputActionMap Get() { return m_Wrapper.m_Test; } + public void Enable() { Get().Enable(); } + public void Disable() { Get().Disable(); } + public bool enabled => Get().enabled; + public static implicit operator InputActionMap(TestActions set) { return set.Get(); } + public void SetCallbacks(ITestActions instance) + { + if (m_Wrapper.m_TestActionsCallbackInterface != null) + { + @PressButton1.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton1; + @PressButton1.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton1; + @PressButton1.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton1; + @PressButton2.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton2; + @PressButton2.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton2; + @PressButton2.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton2; + @PressButton3.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton3; + @PressButton3.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton3; + @PressButton3.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButton3; + @PressButtonA.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonA; + @PressButtonA.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonA; + @PressButtonA.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonA; + @PressButtonB.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonB; + @PressButtonB.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonB; + @PressButtonB.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonB; + @PressButtonC.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonC; + @PressButtonC.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonC; + @PressButtonC.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonC; + @PressButtonStart.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonStart; + @PressButtonStart.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonStart; + @PressButtonStart.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonStart; + @PressButtonPower.started -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonPower; + @PressButtonPower.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonPower; + @PressButtonPower.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnPressButtonPower; + @Move.started -= m_Wrapper.m_TestActionsCallbackInterface.OnMove; + @Move.performed -= m_Wrapper.m_TestActionsCallbackInterface.OnMove; + @Move.canceled -= m_Wrapper.m_TestActionsCallbackInterface.OnMove; + } + m_Wrapper.m_TestActionsCallbackInterface = instance; + if (instance != null) + { + @PressButton1.started += instance.OnPressButton1; + @PressButton1.performed += instance.OnPressButton1; + @PressButton1.canceled += instance.OnPressButton1; + @PressButton2.started += instance.OnPressButton2; + @PressButton2.performed += instance.OnPressButton2; + @PressButton2.canceled += instance.OnPressButton2; + @PressButton3.started += instance.OnPressButton3; + @PressButton3.performed += instance.OnPressButton3; + @PressButton3.canceled += instance.OnPressButton3; + @PressButtonA.started += instance.OnPressButtonA; + @PressButtonA.performed += instance.OnPressButtonA; + @PressButtonA.canceled += instance.OnPressButtonA; + @PressButtonB.started += instance.OnPressButtonB; + @PressButtonB.performed += instance.OnPressButtonB; + @PressButtonB.canceled += instance.OnPressButtonB; + @PressButtonC.started += instance.OnPressButtonC; + @PressButtonC.performed += instance.OnPressButtonC; + @PressButtonC.canceled += instance.OnPressButtonC; + @PressButtonStart.started += instance.OnPressButtonStart; + @PressButtonStart.performed += instance.OnPressButtonStart; + @PressButtonStart.canceled += instance.OnPressButtonStart; + @PressButtonPower.started += instance.OnPressButtonPower; + @PressButtonPower.performed += instance.OnPressButtonPower; + @PressButtonPower.canceled += instance.OnPressButtonPower; + @Move.started += instance.OnMove; + @Move.performed += instance.OnMove; + @Move.canceled += instance.OnMove; + } + } + } + public TestActions @Test => new TestActions(this); + private int m_NewcontrolschemeSchemeIndex = -1; + public InputControlScheme NewcontrolschemeScheme + { + get + { + if (m_NewcontrolschemeSchemeIndex == -1) m_NewcontrolschemeSchemeIndex = asset.FindControlSchemeIndex("New control scheme"); + return asset.controlSchemes[m_NewcontrolschemeSchemeIndex]; + } + } + public interface ITestActions + { + void OnPressButton1(InputAction.CallbackContext context); + void OnPressButton2(InputAction.CallbackContext context); + void OnPressButton3(InputAction.CallbackContext context); + void OnPressButtonA(InputAction.CallbackContext context); + void OnPressButtonB(InputAction.CallbackContext context); + void OnPressButtonC(InputAction.CallbackContext context); + void OnPressButtonStart(InputAction.CallbackContext context); + void OnPressButtonPower(InputAction.CallbackContext context); + void OnMove(InputAction.CallbackContext context); + } +} diff --git a/Assets/Test-Input/Test.cs.meta b/Assets/Test-Input/Test.cs.meta new file mode 100644 index 0000000..add9937 --- /dev/null +++ b/Assets/Test-Input/Test.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1679088dcfad616499e8a56947eb4fe5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Test-Input/Test.inputactions b/Assets/Test-Input/Test.inputactions new file mode 100644 index 0000000..0be1305 --- /dev/null +++ b/Assets/Test-Input/Test.inputactions @@ -0,0 +1,217 @@ +{ + "name": "Test", + "maps": [ + { + "name": "Test", + "id": "8c830899-5b93-4485-b6cf-690688a32987", + "actions": [ + { + "name": "PressButton1", + "type": "Button", + "id": "7fc97698-5a30-4ede-b705-3089212e33a4", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButton2", + "type": "Button", + "id": "36279e50-c398-4905-a495-8c9a0c7ea6a0", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButton3", + "type": "Button", + "id": "5e4a401d-31b5-4238-be45-fcb742db8257", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButtonA", + "type": "Button", + "id": "282753cf-d354-460a-b3d8-897b57100e1c", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButtonB", + "type": "Button", + "id": "bcb4b7cb-c447-4222-8b17-021f5992da49", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButtonC", + "type": "Button", + "id": "72e5810c-02b1-45de-a7a9-e0732cc11a84", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButtonStart", + "type": "Button", + "id": "85317456-76d2-423e-bfbe-4c59f9412c30", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PressButtonPower", + "type": "Button", + "id": "5e2022da-d536-4c6d-b997-9b9005b5fcc1", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "Move", + "type": "Value", + "id": "1efea12d-0e62-4272-98f2-419a3972b23e", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + } + ], + "bindings": [ + { + "name": "", + "id": "1b6d6e5f-df9e-4700-b09a-58d03a083c57", + "path": "/button1", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButton1", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "52815d9a-0ebf-48b6-ae4f-0db59a5e0785", + "path": "/l", + "interactions": "", + "processors": "", + "groups": "", + "action": "PressButton1", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "dd68c926-eaf2-402d-a3dc-c0c0e5278960", + "path": "/button2", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButton2", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "c4ec34c3-a5b5-4d25-951d-2c4e9ae5567f", + "path": "/button3", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButton3", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "5d36faa3-e6f9-4d7e-a708-8fa196d0bfa2", + "path": "/buttonA", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButtonA", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "a7c51fe1-33ec-4c06-9cec-0f45917c7347", + "path": "/buttonB", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButtonB", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "e580378c-77e5-413f-9dff-8b10adca2e64", + "path": "/buttonC", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButtonC", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "a7d5c7a7-7684-4f91-b0f1-c27cf506a3f6", + "path": "/buttonStart", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButtonStart", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "3cd16b1e-35e3-4be2-9e3e-e68a8470ba76", + "path": "/buttonPower", + "interactions": "", + "processors": "", + "groups": "New control scheme", + "action": "PressButtonPower", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "7628f7a3-2ff4-41b8-8f72-a8c723238dff", + "path": "/stick", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [ + { + "name": "New control scheme", + "bindingGroup": "New control scheme", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + } + ] +} \ No newline at end of file diff --git a/Assets/Test-Input/Test.inputactions.meta b/Assets/Test-Input/Test.inputactions.meta new file mode 100644 index 0000000..e08964f --- /dev/null +++ b/Assets/Test-Input/Test.inputactions.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: ff3eb4b73c9b6b9449ed441e5eb03514 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} + generateWrapperCode: 1 + wrapperCodePath: + wrapperClassName: TheTestInputs + wrapperCodeNamespace: diff --git a/Assets/Test-Input/TestInputBehavior.cs b/Assets/Test-Input/TestInputBehavior.cs new file mode 100644 index 0000000..942954d --- /dev/null +++ b/Assets/Test-Input/TestInputBehavior.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.InputSystem; + +public class TestInputBehavior : MonoBehaviour +{ + private TheTestInputs inputActionAsset; + + void Start() + { + inputActionAsset = new TheTestInputs(); + + inputActionAsset.Test.PressButtonA.performed += PressButtonA; + inputActionAsset.Test.PressButtonB.performed += PressButtonB; + inputActionAsset.Test.PressButtonC.performed += PressButtonC; + inputActionAsset.Test.PressButton1.performed += PressButton1; + inputActionAsset.Test.PressButton2.performed += PressButton2; + inputActionAsset.Test.PressButton3.performed += PressButton3; + inputActionAsset.Test.PressButtonStart.performed += PressButtonStart; + inputActionAsset.Test.PressButtonPower.performed += PressButtonPower; + inputActionAsset.Test.Move.performed += UseJoystick; + } + + void PressButtonA(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button A"); + } + + void PressButtonB(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button B"); + } + + void PressButtonC(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button C"); + } + + void PressButton1(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button 1"); + } + + void PressButton2(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button 2"); + } + + void PressButton3(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button 3"); + } + + void PressButtonStart(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button start"); + } + + void PressButtonPower(InputAction.CallbackContext callbackContext) + { + Debug.Log("Button power"); + } + + void UseJoystick(InputAction.CallbackContext callbackContext) + { + Vector2 direction = callbackContext.ReadValue(); + Debug.Log($"Joystick: {direction}"); + } +} diff --git a/Assets/Test-Input/TestInputBehavior.cs.meta b/Assets/Test-Input/TestInputBehavior.cs.meta new file mode 100644 index 0000000..28b38d3 --- /dev/null +++ b/Assets/Test-Input/TestInputBehavior.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c0e6fe775cd2edd45944811c411d4dde +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 5992a0f..861c9e3 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -5,6 +5,7 @@ "com.unity.ide.rider": "3.0.18", "com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.vscode": "1.2.5", + "com.unity.inputsystem": "1.4.4", "com.unity.test-framework": "1.1.31", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.4", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index a1c80be..02e1854 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -60,6 +60,15 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.inputsystem": { + "version": "1.4.4", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.uielements": "1.0.0" + }, + "url": "https://packages.unity.com" + }, "com.unity.performance.profile-analyzer": { "version": "1.1.1", "depth": 1, diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c0a3b0f..7046391 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -704,7 +704,7 @@ PlayerSettings: m_VersionCode: 1 m_VersionName: apiCompatibilityLevel: 6 - activeInputHandler: 0 + activeInputHandler: 2 windowsGamepadBackendHint: 0 cloudProjectId: framebufferDepthMemorylessMode: 0 diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 0000000..6f3e60f --- /dev/null +++ b/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,167 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "ignore": false, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + "newSceneOverride": 0 +} \ No newline at end of file