diff --git a/Assets/Plugins/JoyShockLibrary/JoyShockLibrary.cs b/Assets/Plugins/JoyShockLibrary/JoyShockLibrary.cs index ac12b572..a6f6a3f9 100644 --- a/Assets/Plugins/JoyShockLibrary/JoyShockLibrary.cs +++ b/Assets/Plugins/JoyShockLibrary/JoyShockLibrary.cs @@ -29,8 +29,11 @@ public static class JSL public const int ButtonMaskPS = 16; public const int ButtonMaskCapture = 17; public const int ButtonMaskTouchpadClick = 17; - public const int ButtonMaskSL = 18; - public const int ButtonMaskSR = 19; + public const int ButtonMaskMic = 18; + public const int ButtonMaskSL = 19; + public const int ButtonMaskSR = 20; + public const int ButtonMaskFnL = 21; + public const int ButtonMaskFnR = 22; public const int TypeJoyConLeft = 1; public const int TypeJoyConRight = 2; diff --git a/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.dll b/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.dll index b99f671e..abf2267e 100644 Binary files a/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.dll and b/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.dll differ diff --git a/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.h b/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.h index 21b2f88c..2258b00a 100644 --- a/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.h +++ b/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.h @@ -17,31 +17,33 @@ #define JS_SPLIT_TYPE_RIGHT 2 #define JS_SPLIT_TYPE_FULL 3 -#define JSMASK_UP 0x00001 -#define JSMASK_DOWN 0x00002 -#define JSMASK_LEFT 0x00004 -#define JSMASK_RIGHT 0x00008 -#define JSMASK_PLUS 0x00010 -#define JSMASK_OPTIONS 0x00010 -#define JSMASK_MINUS 0x00020 -#define JSMASK_SHARE 0x00020 -#define JSMASK_LCLICK 0x00040 -#define JSMASK_RCLICK 0x00080 -#define JSMASK_L 0x00100 -#define JSMASK_R 0x00200 -#define JSMASK_ZL 0x00400 -#define JSMASK_ZR 0x00800 -#define JSMASK_S 0x01000 -#define JSMASK_E 0x02000 -#define JSMASK_W 0x04000 -#define JSMASK_N 0x08000 -#define JSMASK_HOME 0x10000 -#define JSMASK_PS 0x10000 -#define JSMASK_CAPTURE 0x20000 -#define JSMASK_TOUCHPAD_CLICK 0x20000 -#define JSMASK_MIC 0x40000 -#define JSMASK_SL 0x40000 -#define JSMASK_SR 0x80000 +#define JSMASK_UP 0x000001 +#define JSMASK_DOWN 0x000002 +#define JSMASK_LEFT 0x000004 +#define JSMASK_RIGHT 0x000008 +#define JSMASK_PLUS 0x000010 +#define JSMASK_OPTIONS 0x000010 +#define JSMASK_MINUS 0x000020 +#define JSMASK_SHARE 0x000020 +#define JSMASK_LCLICK 0x000040 +#define JSMASK_RCLICK 0x000080 +#define JSMASK_L 0x000100 +#define JSMASK_R 0x000200 +#define JSMASK_ZL 0x000400 +#define JSMASK_ZR 0x000800 +#define JSMASK_S 0x001000 +#define JSMASK_E 0x002000 +#define JSMASK_W 0x004000 +#define JSMASK_N 0x008000 +#define JSMASK_HOME 0x010000 +#define JSMASK_PS 0x010000 +#define JSMASK_CAPTURE 0x020000 +#define JSMASK_TOUCHPAD_CLICK 0x020000 +#define JSMASK_MIC 0x040000 +#define JSMASK_SL 0x080000 +#define JSMASK_SR 0x100000 +#define JSMASK_FNL 0x200000 +#define JSMASK_FNR 0x400000 #define JSOFFSET_UP 0 #define JSOFFSET_DOWN 1 @@ -66,8 +68,10 @@ #define JSOFFSET_CAPTURE 17 #define JSOFFSET_TOUCHPAD_CLICK 17 #define JSOFFSET_MIC 18 -#define JSOFFSET_SL 18 -#define JSOFFSET_SR 19 +#define JSOFFSET_SL 19 +#define JSOFFSET_SR 20 +#define JSOFFSET_FNL 21 +#define JSOFFSET_FNR 22 // PS5 Player maps for the DS Player Lightbar #define DS5_PLAYER_1 4 diff --git a/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.dylib b/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.dylib index 783efd22..fbb8ad00 100644 Binary files a/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.dylib and b/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.dylib differ diff --git a/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.so b/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.so index 3ad61ac1..a0daa0f0 100644 Binary files a/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.so and b/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.so differ diff --git a/Assets/Resources/Prefabs/Editor/SettingsMenu/ControllerSetup.prefab b/Assets/Resources/Prefabs/Editor/SettingsMenu/ControllerSetup.prefab index 7723f51b..0d3396e5 100644 --- a/Assets/Resources/Prefabs/Editor/SettingsMenu/ControllerSetup.prefab +++ b/Assets/Resources/Prefabs/Editor/SettingsMenu/ControllerSetup.prefab @@ -3758,7 +3758,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &3918594454393827276 RectTransform: m_ObjectHideFlags: 0 @@ -3771,16 +3771,15 @@ RectTransform: m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 3918594454521024533} - {fileID: 3918594455780710548} - {fileID: 3918594455337952163} m_Father: {fileID: 3918594454598345480} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 754, y: -307.9788} - m_SizeDelta: {x: 1468, y: 100} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &3918594454393827267 MonoBehaviour: @@ -3797,10 +3796,10 @@ MonoBehaviour: m_Padding: m_Left: 0 m_Right: 0 - m_Top: 10 - m_Bottom: 16 - m_ChildAlignment: 6 - m_Spacing: 10 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 4 + m_Spacing: 0 m_ChildForceExpandWidth: 0 m_ChildForceExpandHeight: 0 m_ChildControlWidth: 0 @@ -3945,145 +3944,6 @@ MonoBehaviour: m_hasFontAssetChanged: 0 m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} ---- !u!1 &3918594454521024534 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3918594454521024533} - - component: {fileID: 3918594454521024523} - - component: {fileID: 3918594454521024532} - m_Layer: 5 - m_Name: Text (TMP) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &3918594454521024533 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3918594454521024534} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 3918594454393827276} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -46.5} - m_SizeDelta: {x: 320, y: 75} - m_Pivot: {x: 0, y: 0.5} ---- !u!222 &3918594454521024523 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3918594454521024534} - m_CullTransparentMesh: 1 ---- !u!114 &3918594454521024532 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3918594454521024534} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_text: 'Joy-Con (L/R) Selected - - Pairing Second Joy-Con...' - m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8597c35f18a008c428fc5870aec75766, type: 2} - m_sharedMaterial: {fileID: -6562250930271150993, guid: 8597c35f18a008c428fc5870aec75766, type: 2} - m_fontSharedMaterials: [] - m_fontMaterial: {fileID: 0} - m_fontMaterials: [] - m_fontColor32: - serializedVersion: 2 - rgba: 4294967295 - m_fontColor: {r: 1, g: 1, b: 1, a: 1} - m_enableVertexGradient: 0 - m_colorMode: 3 - m_fontColorGradient: - topLeft: {r: 1, g: 1, b: 1, a: 1} - topRight: {r: 1, g: 1, b: 1, a: 1} - bottomLeft: {r: 1, g: 1, b: 1, a: 1} - bottomRight: {r: 1, g: 1, b: 1, a: 1} - m_fontColorGradientPreset: {fileID: 0} - m_spriteAsset: {fileID: 0} - m_tintAllSprites: 0 - m_StyleSheet: {fileID: 0} - m_TextStyleHashCode: -1183493901 - m_overrideHtmlColors: 0 - m_faceColor: - serializedVersion: 2 - rgba: 4294967295 - m_fontSize: 24.5 - m_fontSizeBase: 32 - m_fontWeight: 400 - m_enableAutoSizing: 1 - m_fontSizeMin: 18 - m_fontSizeMax: 36 - m_fontStyle: 0 - m_HorizontalAlignment: 1 - m_VerticalAlignment: 512 - m_textAlignment: 65535 - m_characterSpacing: 0 - m_wordSpacing: 0 - m_lineSpacing: 0 - m_lineSpacingMax: 0 - m_paragraphSpacing: 0 - m_charWidthMaxAdj: 0 - m_TextWrappingMode: 1 - m_wordWrappingRatios: 0.4 - m_overflowMode: 0 - m_linkedTextComponent: {fileID: 0} - parentLinkedComponent: {fileID: 0} - m_enableKerning: 1 - m_ActiveFontFeatures: 6e72656b - m_enableExtraPadding: 0 - checkPaddingRequired: 0 - m_isRichText: 1 - m_EmojiFallbackSupport: 1 - m_parseCtrlCharacters: 1 - m_isOrthographic: 1 - m_isCullingEnabled: 0 - m_horizontalMapping: 0 - m_verticalMapping: 0 - m_uvLineOffset: 0 - m_geometrySortingOrder: 0 - m_IsTextObjectScaleStatic: 0 - m_VertexBufferAutoSizeReduction: 0 - m_useMaxVisibleDescender: 1 - m_pageToDisplay: 1 - m_margin: {x: 0, y: 0, z: 0, w: -7.5} - m_isUsingLegacyAnimationComponent: 0 - m_isVolumetricText: 0 - m_hasFontAssetChanged: 0 - m_baseMaterial: {fileID: 0} - m_maskOffset: {x: 0, y: 0, z: 0, w: 0} --- !u!1 &3918594454531700438 GameObject: m_ObjectHideFlags: 0 @@ -5807,11 +5667,11 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 3918594454393827276} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 476.83002, y: -69} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 688.17, y: 30} m_Pivot: {x: 0, y: 0.5} --- !u!222 &3918594455337952161 @@ -5842,7 +5702,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Press button on second Joy-Con to select... + m_text: Press ZL + ZR to pair Joy-Con m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8597c35f18a008c428fc5870aec75766, type: 2} m_sharedMaterial: {fileID: -6562250930271150993, guid: 8597c35f18a008c428fc5870aec75766, type: 2} @@ -5876,7 +5736,7 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 36 m_fontStyle: 0 - m_HorizontalAlignment: 1 + m_HorizontalAlignment: 2 m_VerticalAlignment: 512 m_textAlignment: 65535 m_characterSpacing: 0 @@ -6010,9 +5870,6 @@ MonoBehaviour: controllersDropdown: {fileID: 3918594454563211279} pairSearchItem: {fileID: 3918594454393827277} autoSearchLabel: {fileID: 3918594454453368363} - pairSearchLabel: {fileID: 3918594455337952172} - pairSearchCancelBt: {fileID: 3918594455780710549} - pairingLabel: {fileID: 3918594454521024532} controllerIcons: - {fileID: 3918594454983356908} - {fileID: 3918594455640061334} @@ -6975,7 +6832,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &3918594455780710548 RectTransform: m_ObjectHideFlags: 0 @@ -6991,11 +6848,11 @@ RectTransform: - {fileID: 3918594455818177326} - {fileID: 3918594456368854930} m_Father: {fileID: 3918594454393827276} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 330, y: -69} + m_AnchoredPosition: {x: 272, y: -25} m_SizeDelta: {x: 136.83, y: 30} m_Pivot: {x: 0, y: 0.5} --- !u!222 &3918594455780710537 @@ -8052,8 +7909,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 723, y: 0} - m_SizeDelta: {x: 1406, y: 0} + m_AnchoredPosition: {x: 704.5, y: 0} + m_SizeDelta: {x: 1369, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &3918594456218978261 CanvasRenderer: diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs new file mode 100644 index 00000000..e19dfcfa --- /dev/null +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs @@ -0,0 +1,495 @@ +using System; +using System.Threading.Tasks; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using HeavenStudio.Util; + +using static JSL; + +namespace HeavenStudio.InputSystem.Loaders +{ + public static class InputJoyconPairInitializer + { + [LoadOrder(3)] + public static InputController[] Initialize() + { + PlayerInput.PlayerInputRefresh.Add(Refresh); + return Refresh(); + } + + public static InputController[] Refresh() + { + int joyconLCount = 0, joyconRCount = 0; + foreach (InputController con in PlayerInput.GetInputControllers()) + { + if (con is InputJoyshock) + { + InputJoyshock joyshock = (InputJoyshock)con; + if (joyshock.GetJoyshockType() == TypeJoyConLeft) + { + joyconLCount++; + } + else if (joyshock.GetJoyshockType() == TypeJoyConRight) + { + joyconRCount++; + } + } + } + if (joyconLCount > 0 && joyconRCount > 0) + { + InputJoyconPair joyconPair = new InputJoyconPair(); + joyconPair.SetPlayer(null); + joyconPair.InitializeController(); + return new InputController[] { joyconPair }; + } + else + { + Debug.Log("No Joy-Con connected."); + return null; + } + } + } +} + +namespace HeavenStudio.InputSystem +{ + public class InputJoyconPair : InputController + { + static readonly string[] nsConButtonNames = new[] + { + "Up", + "Down", + "Left", + "Right", + "Plus", + "Minus", + "Left Stick Click", + "Right Stick Click", + "L", + "R", + "ZL", + "ZR", + "B", + "A", + "Y", + "X", + "Home", + "Capture", + "", // mic on playstation, unused here + "SL", + "SR", + "", // fnl on playstation, unused here + "", // fnr on playstation, unused here + "Stick Up", + "Stick Down", + "Stick Left", + "Stick Right", + }; + + static int[] defaultMappings + { + get + { + return new[] + { + ButtonMaskUp, + ButtonMaskDown, + ButtonMaskLeft, + ButtonMaskRight, + ButtonMaskS, + ButtonMaskE, + ButtonMaskW, + ButtonMaskN, + ButtonMaskL, + ButtonMaskR, + ButtonMaskPlus, + -1 + }; + } + } + + InputJoyshock leftController, rightController; + + int GetButtonForAction(int action) + { + if (currentBindings.Pad == null) return -1; + if (action < 0 || action >= BINDS_MAX) return -1; + + ControlBindings actionMap = currentBindings; + if (actionMap.Pad[action] > ButtonMaskFnR) return -1; + + return actionMap.Pad[action]; + } + + int GetActionForButton(int button, ControlStyles style) + { + if (style != ControlStyles.Pad) return -1; + if (currentBindings.Pad == null) return -1; + if (button < 0 || button >= ButtonMaskFnR) return -1; + + ControlBindings actionMap = currentBindings; + for (int i = 0; i < BINDS_MAX; i++) + { + if (actionMap.Pad[i] == button) + { + return i; + } + } + return -1; + } + + public void SetLeftController(InputJoyshock leftController) + { + this.leftController = leftController; + } + + public void SetRightController(InputJoyshock rightController) + { + this.rightController = rightController; + } + + public bool HasControllers() + { + return leftController != null && rightController != null; + } + + public override bool GetAction(ControlStyles style, int action) + { + if (leftController == null || rightController == null) + { + return false; + } + int button = GetButtonForAction(action); + if (button == -1) { return false; } + return leftController.GetButtonState(button).pressed || rightController.GetButtonState(button).pressed; + } + + public override bool GetActionDown(ControlStyles style, int action, out double dt) + { + dt = 0; + if (leftController == null || rightController == null) + { + return false; + } + int button = GetButtonForAction(action); + if (button == -1) { dt = 0; return false; } + InputJoyshock.JoyshockButtonState leftState = leftController.GetButtonState(button); + if (leftState.pressed && leftState.isDelta) + { + dt = leftState.dt; + return true; + } + InputJoyshock.JoyshockButtonState rightState = rightController.GetButtonState(button); + if (rightState.pressed && rightState.isDelta) + { + dt = rightState.dt; + return true; + } + return false; + } + + public override bool GetActionUp(ControlStyles style, int action, out double dt) + { + dt = 0; + if (leftController == null || rightController == null) + { + return false; + } + int button = GetButtonForAction(action); + if (button == -1) { dt = 0; return false; } + InputJoyshock.JoyshockButtonState leftState = leftController.GetButtonState(button); + if (!leftState.pressed && leftState.isDelta) + { + dt = leftState.dt; + return true; + } + InputJoyshock.JoyshockButtonState rightState = rightController.GetButtonState(button); + if (!rightState.pressed && rightState.isDelta) + { + dt = rightState.dt; + return true; + } + return false; + } + + public override float GetAxis(InputAxis axis) + { + if (leftController == null || rightController == null) + { + return 0; + } + return leftController.GetAxis(axis) + rightController.GetAxis(axis); + } + + public override int GetBindingsVersion() + { + return 1; + } + + public override string[] GetButtonNames() + { + return nsConButtonNames; + } + + public override ControlBindings GetCurrentBindings() + { + return currentBindings; + } + + public override bool GetCurrentStyleSupported() + { + return PlayerInput.CurrentControlStyle is ControlStyles.Pad; // or ControlStyles.Baton + } + + public override ControlBindings GetDefaultBindings() + { + ControlBindings binds = new ControlBindings + { + Pad = defaultMappings, + version = GetBindingsVersion(), + PointerSensitivity = 3 + }; + return binds; + } + + public override ControlStyles GetDefaultStyle() + { + return ControlStyles.Pad; + } + + public override string GetDeviceName() + { + return "Joy-Con Pair"; + } + + public override InputFeatures GetFeatures() + { + if (leftController == null || rightController == null) + { + return 0; + } + InputFeatures features = leftController.GetFeatures() | rightController.GetFeatures(); + return features; + } + + public override bool GetFlick(out double dt) + { + if (leftController == null || rightController == null) + { + dt = 0; + return false; + } + return leftController.GetFlick(out dt) || rightController.GetFlick(out dt); + } + + public override bool GetIsActionUnbindable(int action, ControlStyles style) + { + return false; + } + + public override bool GetIsConnected() + { + if (leftController == null || rightController == null) + { + return false; + } + return leftController.GetIsConnected() && rightController.GetIsConnected(); + } + + public override bool GetIsPoorConnection() + { + if (leftController == null || rightController == null) + { + return false; + } + return leftController.GetIsPoorConnection() || rightController.GetIsPoorConnection(); + } + + public override int GetLastActionDown() + { + if (leftController == null || rightController == null) + { + return -1; + } + int lastLeftButton = leftController.GetLastButtonDown(); + int lastRightButton = rightController.GetLastButtonDown(); + int leftAction = GetActionForButton(lastLeftButton, ControlStyles.Pad); + int rightAction = GetActionForButton(lastRightButton, ControlStyles.Pad); + if (leftAction == -1 && rightAction == -1) + { + return -1; + } + if (leftAction == -1) + { + return rightAction; + } + else + { + return leftAction; + } + } + + public override int GetLastButtonDown(bool strict = false) + { + if (strict || leftController == null || rightController == null) + { + return -1; + } + return Math.Max(leftController.GetLastButtonDown(strict), rightController.GetLastButtonDown(strict)); + } + + public override int? GetPlayer() + { + return playerNum; + } + + public override Vector2 GetPointer() + { + Camera cam = GameManager.instance.CursorCam; + Vector3 rawPointerPos = Input.mousePosition; + rawPointerPos.z = Mathf.Abs(cam.gameObject.transform.position.z); + return cam.ScreenToWorldPoint(rawPointerPos); + } + + public override bool GetPointerLeftRight() + { + return false; + } + + public override bool GetSlide(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueeze() + { + return false; + } + + public override bool GetSqueezeDown(out double dt) + { + dt = 0; + return false; + } + + public override bool GetSqueezeUp(out double dt) + { + dt = 0; + return false; + } + + public override Vector3 GetVector(InputVector vector) + { + if (leftController == null || rightController == null) + { + return Vector3.zero; + } + return leftController.GetVector(vector) + rightController.GetVector(vector); + } + + public override void InitializeController() + { + leftController = null; + rightController = null; + LoadBindings(); + } + + public override void OnSelected() + { + if (leftController == null || rightController == null) + { + return; + } + leftController.OnSelected(); + leftController.SetRotatedStickMode(false); + rightController.OnSelected(); + rightController.SetRotatedStickMode(false); + } + + public override void RecentrePointer() + { + } + + public override void ResetBindings() + { + currentBindings = GetDefaultBindings(); + } + + public override void SetCurrentBindings(ControlBindings newBinds) + { + currentBindings = newBinds; + } + + public override void SetMaterialProperties(Material m) + { + Color colour; + m.SetColor("_BodyColor", ColorUtility.TryParseHtmlString("#2F353A", out colour) ? colour : Color.white); + m.SetColor("_BtnColor", ColorUtility.TryParseHtmlString("#2F353A", out colour) ? colour : Color.white); + if (leftController == null) + { + m.SetColor("_LGripColor", Color.white); + } + else + { + m.SetColor("_LGripColor", leftController.GetBodyColor()); + } + if (rightController == null) + { + m.SetColor("_RGripColor", Color.white); + } + else + { + m.SetColor("_RGripColor", rightController.GetBodyColor()); + } + } + + public override void SetPlayer(int? playerNum) + { + this.playerNum = playerNum; + int handle; + if (leftController != null) + { + handle = leftController.GetHandle(); + if (playerNum == -1 || playerNum == null) + { + JslSetPlayerNumber(handle, 0); + } + else + { + JslSetPlayerNumber(handle, (int)playerNum); + } + } + if (rightController != null) + { + handle = rightController.GetHandle(); + if (playerNum == -1 || playerNum == null) + { + JslSetPlayerNumber(handle, 0); + } + else + { + JslSetPlayerNumber(handle, (int)playerNum); + } + } + } + + public override void TogglePointerLock(bool locked) + { + } + + public override ControlBindings UpdateBindings(ControlBindings lastBinds) + { + if (lastBinds.version == 0) + { + return GetDefaultBindings(); + } + return lastBinds; + } + + public override void UpdateState() + { + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs.meta b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs.meta new file mode 100644 index 00000000..6fd1f9a1 --- /dev/null +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 538461cea16b9a94eb31f272a79cd574 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs index 5dd63bff..df61b68b 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs @@ -11,21 +11,31 @@ namespace HeavenStudio.InputSystem.Loaders { public static class InputJoyshockInitializer { + static bool failedJsl = false; [LoadOrder(2)] public static InputController[] Initialize() { + failedJsl = false; InputJoyshock.joyshocks = new(); PlayerInput.PlayerInputCleanUp += DisposeJoyshocks; PlayerInput.PlayerInputRefresh.Add(Refresh); - InputJoyshock.JslEventInit(); - - InputController[] controllers; + List controllers; int jslDevicesFound = 0; int jslDevicesConnected = 0; int[] jslDeviceHandles; - jslDevicesFound = JslConnectDevices(); + try + { + JslDisconnectAndDisposeAll(); + jslDevicesFound = JslConnectDevices(); + } + catch (Exception e) + { + Debug.LogError("Failed to initialize JoyShockLibrary: " + e.Message); + failedJsl = true; + return null; + } if (jslDevicesFound > 0) { jslDeviceHandles = new int[jslDevicesFound]; @@ -40,16 +50,17 @@ namespace HeavenStudio.InputSystem.Loaders Debug.Log("Connected " + jslDevicesConnected + " JoyShocks."); } - controllers = new InputController[jslDevicesConnected]; + controllers = new(); foreach (int i in jslDeviceHandles) { Debug.Log("Setting up JoyShock: ( Handle " + i + ", type " + JslGetControllerType(i) + " )"); InputJoyshock joyshock = new InputJoyshock(i); joyshock.SetPlayer(null); joyshock.InitializeController(); - controllers[i] = joyshock; + controllers.Add(joyshock); } - return controllers; + InputJoyshock.JslEventInit(); + return controllers.ToArray(); } Debug.Log("No JoyShocks found."); return null; @@ -57,38 +68,42 @@ namespace HeavenStudio.InputSystem.Loaders public static void DisposeJoyshocks() { + if (failedJsl) return; foreach (InputJoyshock joyshock in InputJoyshock.joyshocks.Values) { joyshock.CleanUp(); } - JslSetCallback(null); JslDisconnectAndDisposeAll(); + JslSetCallback(null); } public static InputController[] Refresh() { + if (failedJsl) return null; InputJoyshock.joyshocks.Clear(); - InputController[] controllers; + List controllers; int jslDevicesFound = 0; int jslDevicesConnected = 0; int[] jslDeviceHandles; + JslDisconnectAndDisposeAll(); jslDevicesFound = JslConnectDevices(); if (jslDevicesFound > 0) { jslDeviceHandles = new int[jslDevicesFound]; jslDevicesConnected = JslGetConnectedDeviceHandles(jslDeviceHandles, jslDevicesFound); - controllers = new InputController[jslDevicesConnected]; + controllers = new(); foreach (int i in jslDeviceHandles) { Debug.Log("Setting up JoyShock: ( Handle " + i + ", type " + JslGetControllerType(i) + " )"); InputJoyshock joyshock = new InputJoyshock(i); joyshock.SetPlayer(null); joyshock.InitializeController(); - controllers[i] = joyshock; + controllers.Add(joyshock); } - return controllers; + InputJoyshock.JslEventInit(); + return controllers.ToArray(); } Debug.Log("No JoyShocks found."); return null; @@ -107,7 +122,7 @@ namespace HeavenStudio.InputSystem "Joy-Con (R)", "Pro Controller", "DualShock 4", - "DualSense" + "DualSense/Edge" // jsl doesn't expose a new device ID for DSE }; static readonly int[] dsPlayerColours = new[] @@ -148,10 +163,10 @@ namespace HeavenStudio.InputSystem { return new[] { - 20, - 21, - 22, 23, + 24, + 25, + 26, ButtonMaskLeft, ButtonMaskDown, ButtonMaskUp, @@ -170,10 +185,10 @@ namespace HeavenStudio.InputSystem { return new[] { - 20, - 21, - 22, 23, + 24, + 25, + 26, ButtonMaskE, ButtonMaskN, ButtonMaskS, @@ -228,8 +243,11 @@ namespace HeavenStudio.InputSystem "X", "Home", "Capture", + "", // mic on playstation, unused here "SL", "SR", + "", // fnl on playstation, unused here + "", // fnr on playstation, unused here "Stick Up", "Stick Down", "Stick Left", @@ -256,6 +274,7 @@ namespace HeavenStudio.InputSystem "Triangle", "PS", "Touchpad Click", + "Mic", }; static readonly string[] ps5ButtonNames = new[] @@ -279,13 +298,17 @@ namespace HeavenStudio.InputSystem "PS", "Create", "Mic", + "Left Grip", + "Right Grip", + "Left Function", + "Right Function", }; static readonly float debounceTime = 1f / 90f; public static Dictionary joyshocks; - float stickDeadzone = 0.5f; + const float STICK_DEAD = 0.6f; int joyshockHandle; int type; @@ -293,10 +316,11 @@ namespace HeavenStudio.InputSystem int lightbarColour; string joyshockName; DateTime startTime; + bool joyConWantRotatedStick = true; //buttons, sticks, triggers JoyshockButtonState[] actionStates = new JoyshockButtonState[BINDS_MAX]; - JoyshockButtonState[] buttonStates = new JoyshockButtonState[ButtonMaskSR + 1]; + JoyshockButtonState[] buttonStates = new JoyshockButtonState[ButtonMaskFnR + 1]; JOY_SHOCK_STATE joyBtStateCurrent; //gyro and accelerometer IMU_STATE joyImuStateCurrent, joyImuStateLast; @@ -306,9 +330,6 @@ namespace HeavenStudio.InputSystem // controller settings JSL_SETTINGS joySettings; - InputJoyshock otherHalf; - bool isPair; - public struct JoyshockButtonState { public double dt; // time passed since state @@ -333,12 +354,12 @@ namespace HeavenStudio.InputSystem joyshockHandle = handle; } - int GetButtonForSplitType(int action) + int GetButtonForAction(int action) { if (currentBindings.Pad == null) return -1; if (action < 0 || action >= BINDS_MAX) return -1; ControlBindings actionMap = currentBindings; - if (actionMap.Pad[action] > ButtonMaskSR) return -1; + if (actionMap.Pad[action] > ButtonMaskFnR) return -1; return actionMap.Pad[action]; } @@ -379,7 +400,7 @@ namespace HeavenStudio.InputSystem lastInputStack = new(); actionStates = new JoyshockButtonState[BINDS_MAX]; - buttonStates = new JoyshockButtonState[ButtonMaskSR + 1]; + buttonStates = new JoyshockButtonState[ButtonMaskFnR + 1]; joyBtStateCurrent = new JOY_SHOCK_STATE(); joyImuStateCurrent = new IMU_STATE(); @@ -423,6 +444,9 @@ namespace HeavenStudio.InputSystem for (int i = 0; i < buttonStates.Length; i++) { buttonStates[i].isDelta = false; + buttonStates[i].debounce -= Time.deltaTime; + if (buttonStates[i].debounce < 0) + buttonStates[i].debounce = 0; } foreach (TimestampedState state in lastInputStack) @@ -431,7 +455,7 @@ namespace HeavenStudio.InputSystem for (int i = 0; i < actionStates.Length; i++) { - int bt = GetButtonForSplitType(i); + int bt = GetButtonForAction(i); if (bt != -1) { bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << bt); @@ -453,9 +477,13 @@ namespace HeavenStudio.InputSystem bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << i); if (pressed != buttonStates[i].pressed && !buttonStates[i].isDelta) { - buttonStates[i].pressed = pressed; - buttonStates[i].isDelta = true; - buttonStates[i].dt = reportTime - state.timestamp; + if (buttonStates[i].debounce <= 0) + { + buttonStates[i].pressed = pressed; + buttonStates[i].isDelta = true; + buttonStates[i].dt = reportTime - state.timestamp; + } + buttonStates[i].debounce = debounceTime; } } } @@ -465,22 +493,19 @@ namespace HeavenStudio.InputSystem //left rotates counterclockwise, right rotates clockwise, all by 90 degrees float xAxis = 0f; float yAxis = 0f; - if (otherHalf == null) + + if (joyConWantRotatedStick && type is TypeJoyConLeft or TypeJoyConRight) { - switch (splitType) + switch (type) { - case SplitLeft: + case TypeJoyConLeft: xAxis = -joyBtStateCurrent.stickLY; yAxis = joyBtStateCurrent.stickLX; break; - case SplitRight: //use the right stick instead + case TypeJoyConRight: xAxis = joyBtStateCurrent.stickRY; yAxis = -joyBtStateCurrent.stickRX; break; - case SplitFull: - xAxis = joyBtStateCurrent.stickLX; - yAxis = joyBtStateCurrent.stickLY; - break; } } else @@ -491,17 +516,18 @@ namespace HeavenStudio.InputSystem directionStateLast = directionStateCurrent; directionStateCurrent = 0; - directionStateCurrent |= ((yAxis >= stickDeadzone) ? (1 << ((int)InputDirection.Up)) : 0); - directionStateCurrent |= ((yAxis <= -stickDeadzone) ? (1 << ((int)InputDirection.Down)) : 0); - directionStateCurrent |= ((xAxis >= stickDeadzone) ? (1 << ((int)InputDirection.Right)) : 0); - directionStateCurrent |= ((xAxis <= -stickDeadzone) ? (1 << ((int)InputDirection.Left)) : 0); - //Debug.Log("stick direction: " + directionStateCurrent + "| x axis: " + xAxis + " y axis: " + yAxis); + directionStateCurrent |= (yAxis >= STICK_DEAD) ? (1 << (int)ActionsPad.Up) : 0; + directionStateCurrent |= (yAxis <= -STICK_DEAD) ? (1 << (int)ActionsPad.Down) : 0; + directionStateCurrent |= (xAxis <= -STICK_DEAD) ? (1 << (int)ActionsPad.Left) : 0; + directionStateCurrent |= (xAxis >= STICK_DEAD) ? (1 << (int)ActionsPad.Right) : 0; + // Debug.Log($"{GetDeviceName()} stick direction: {directionStateCurrent}| x axis: {xAxis}, y axis: {yAxis}"); lastInputStack.Clear(); } public override void OnSelected() { + SetRotatedStickMode(true); Task.Run(() => SelectionVibrate()); } @@ -514,8 +540,6 @@ namespace HeavenStudio.InputSystem public override string GetDeviceName() { - if (otherHalf != null) - return "Joy-Con Pair"; return joyshockName; } @@ -530,10 +554,7 @@ namespace HeavenStudio.InputSystem case TypeDualSense: return ps5ButtonNames; default: - if (otherHalf == null) - return nsConButtonNames; - else - return nsProButtonNames; + return nsConButtonNames; } } @@ -577,16 +598,10 @@ namespace HeavenStudio.InputSystem switch (type) { case TypeJoyConLeft: - if (otherHalf == null) - binds.Pad = defaultMappingsL; - else - binds.Pad = defaultMappings; + binds.Pad = defaultMappingsL; break; case TypeJoyConRight: - if (otherHalf == null) - binds.Pad = defaultMappingsR; - else - binds.Pad = defaultMappings; + binds.Pad = defaultMappingsR; break; case TypeProController: binds.Pad = defaultMappings; @@ -599,6 +614,7 @@ namespace HeavenStudio.InputSystem break; } binds.PointerSensitivity = 3; + binds.version = GetBindingsVersion(); return binds; } @@ -617,20 +633,41 @@ namespace HeavenStudio.InputSystem currentBindings = newBinds; } + public override ControlBindings UpdateBindings(ControlBindings lastBinds) + { + if (lastBinds.version == 0) + { + switch (type) + { + case TypeProController: + case TypeDualShock4: + case TypeDualSense: + return lastBinds; + case TypeJoyConLeft: + case TypeJoyConRight: + for (int i = 0; i < lastBinds.Pad.Length; i++) + { + if (lastBinds.Pad[i] is 18 or 19) + lastBinds.Pad[i] = lastBinds.Pad[i] + 1; + } + return lastBinds; + } + } + return lastBinds; + } + + public override int GetBindingsVersion() + { + return 1; + } + public override bool GetIsActionUnbindable(int action, ControlStyles style) { - if (otherHalf == null) + if (type is TypeJoyConLeft or TypeJoyConRight) { - switch (splitType) + if (style is ControlStyles.Pad) { - case SplitLeft: - case SplitRight: - switch (style) - { - case ControlStyles.Pad: - return action is 0 or 1 or 2 or 3; - } - break; + return action is 0 or 1 or 2 or 3; } } return false; @@ -652,48 +689,74 @@ namespace HeavenStudio.InputSystem { for (int i = 0; i < actionStates.Length; i++) { + if (i is 0 or 1 or 2 or 3) + { + if (BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << i)) + { + return i; + } + } if (actionStates[i].pressed && actionStates[i].isDelta) { return i; } } - if (otherHalf != null) - { - return otherHalf.GetLastActionDown(); - } return -1; } - public override bool GetAction(ControlStyles style, int button) + public JoyshockButtonState GetButtonState(int button) { - if (button == -1) { return false; } - if (otherHalf != null) - { - return actionStates[button].pressed || otherHalf.actionStates[button].pressed; - } - return actionStates[button].pressed; + return buttonStates[button]; } - public override bool GetActionDown(ControlStyles style, int button, out double dt) + public JoyshockButtonState[] GetButtonStates() { - if (button == -1) { dt = 0; return false; } - if (otherHalf != null && otherHalf.GetActionDown(style, button, out dt)) + return buttonStates; + } + + public override bool GetAction(ControlStyles style, int action) + { + if (action == -1) { return false; } + bool stick = false; + if (action is 0 or 1 or 2 or 3) + { + stick = BitwiseUtils.WantCurrent(directionStateCurrent, 1 << action); + } + return actionStates[action].pressed || stick; + } + + public override bool GetActionDown(ControlStyles style, int action, out double dt) + { + if (action == -1) { dt = 0; return false; } + dt = actionStates[action].dt; + bool bt = actionStates[action].pressed && actionStates[action].isDelta; + if (bt) { return true; } - dt = actionStates[button].dt; - return actionStates[button].pressed && actionStates[button].isDelta; + else if (action is 0 or 1 or 2 or 3) + { + dt = 0; + return BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << action); + } + return false; } public override bool GetActionUp(ControlStyles style, int button, out double dt) { if (button == -1) { dt = 0; return false; } - if (otherHalf != null && otherHalf.GetActionUp(style, button, out dt)) + dt = actionStates[button].dt; + bool bt = !actionStates[button].pressed && actionStates[button].isDelta; + if (bt) { return true; } - dt = actionStates[button].dt; - return !actionStates[button].pressed && actionStates[button].isDelta; + else if (button is 0 or 1 or 2 or 3) + { + dt = 0; + return BitwiseUtils.WantNotCurrentAndLast(directionStateCurrent, directionStateLast, 1 << button); + } + return false; } public override float GetAxis(InputAxis axis) @@ -713,7 +776,7 @@ namespace HeavenStudio.InputSystem case InputAxis.AxisRStickY: return joyBtStateCurrent.stickRY; case InputAxis.PointerX: //isn't updated for now, so always returns 0f - //return joyTouchStateCurrent.t0X; + //return joyTouchStateCurrent.t0X; case InputAxis.PointerY: //return joyTouchStateCurrent.t0Y; default: @@ -747,93 +810,6 @@ namespace HeavenStudio.InputSystem return cam.ScreenToWorldPoint(rawPointerPos); } - public override bool GetHatDirection(InputDirection direction) - { - int bt; - switch (direction) - { - case InputDirection.Up: - bt = 0; - break; - case InputDirection.Down: - bt = 1; - break; - case InputDirection.Left: - bt = 2; - break; - case InputDirection.Right: - bt = 3; - break; - default: - return false; - } - if (otherHalf != null) - { - return GetAction(ControlStyles.Pad, bt) || BitwiseUtils.WantCurrent(otherHalf.directionStateCurrent, 1 << (int)direction) || BitwiseUtils.WantCurrent(directionStateCurrent, 1 << (int)direction); - } - return GetAction(ControlStyles.Pad, bt) || BitwiseUtils.WantCurrent(directionStateCurrent, 1 << (int)direction); - } - - public override bool GetHatDirectionDown(InputDirection direction, out double dt) - { - int bt; - switch (direction) - { - case InputDirection.Up: - bt = 0; - break; - case InputDirection.Down: - bt = 1; - break; - case InputDirection.Left: - bt = 2; - break; - case InputDirection.Right: - bt = 3; - break; - default: - dt = 0; - return false; - } - bool btbool = GetActionDown(ControlStyles.Pad, bt, out dt); - if (!btbool) dt = 0; - if (otherHalf != null) - { - return btbool || BitwiseUtils.WantCurrentAndNotLast(otherHalf.directionStateCurrent, otherHalf.directionStateLast, 1 << (int)direction) || BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << (int)direction); - } - return btbool || BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << (int)direction); - } - - public override bool GetHatDirectionUp(InputDirection direction, out double dt) - { - int bt; - switch (direction) - { - case InputDirection.Up: - bt = 0; - break; - case InputDirection.Down: - bt = 1; - break; - case InputDirection.Left: - bt = 2; - break; - case InputDirection.Right: - bt = 3; - break; - default: - dt = 0; - return false; - } - bool btbool = GetActionUp(ControlStyles.Pad, bt, out dt); - if (!btbool) dt = 0; - if (otherHalf != null) - { - return btbool || BitwiseUtils.WantNotCurrentAndLast(otherHalf.directionStateCurrent, otherHalf.directionStateLast, 1 << (int)direction) || BitwiseUtils.WantNotCurrentAndLast(directionStateCurrent, directionStateLast, 1 << (int)direction); - } - return btbool || BitwiseUtils.WantNotCurrentAndLast(directionStateCurrent, directionStateLast, 1 << (int)direction); - } - public override void SetPlayer(int? playerNum) { //TODO: dualshock 4 and dualsense lightbar colour support @@ -865,11 +841,6 @@ namespace HeavenStudio.InputSystem public Color GetBodyColor() { - if (otherHalf != null) - { - // gets the colour of the right controller if is split - return BitwiseUtils.IntToRgb(splitType == SplitRight ? joySettings.bodyColour : GetOtherHalf().joySettings.bodyColour); - } return BitwiseUtils.IntToRgb(joySettings.bodyColour); } @@ -882,10 +853,6 @@ namespace HeavenStudio.InputSystem public Color GetLeftGripColor() { - if (otherHalf != null) - { - return BitwiseUtils.IntToRgb(splitType == SplitLeft ? joySettings.lGripColour : GetOtherHalf().joySettings.lGripColour); - } if (joySettings.lGripColour == 0xFFFFFF) return GetBodyColor(); return BitwiseUtils.IntToRgb(joySettings.lGripColour); @@ -893,10 +860,6 @@ namespace HeavenStudio.InputSystem public Color GetRightGripColor() { - if (otherHalf != null) - { - return BitwiseUtils.IntToRgb(splitType == SplitRight ? joySettings.rGripColour : GetOtherHalf().joySettings.rGripColour); - } if (joySettings.rGripColour == 0xFFFFFF) return GetBodyColor(); return BitwiseUtils.IntToRgb(joySettings.rGripColour); @@ -907,6 +870,16 @@ namespace HeavenStudio.InputSystem return BitwiseUtils.IntToRgb(lightbarColour); } + public int GetJoyshockType() + { + return type; + } + + public void SetRotatedStickMode(bool rotated) + { + joyConWantRotatedStick = rotated; + } + public void SetLightbarColour(Color color) { lightbarColour = BitwiseUtils.RgbToInt(color); @@ -931,47 +904,11 @@ namespace HeavenStudio.InputSystem public void DisconnectJoyshock() { - if (otherHalf != null) - { - otherHalf = null; - } JslSetRumble(joyshockHandle, 0, 0); JslSetLightColour(joyshockHandle, 0); JslSetPlayerNumber(joyshockHandle, 0); } - public void AssignOtherHalf(InputJoyshock otherHalf, bool force = false) - { - InputFeatures features = otherHalf.GetFeatures(); - if (features.HasFlag(InputFeatures.Extra_SplitControllerLeft) || features.HasFlag(InputFeatures.Extra_SplitControllerRight)) - { - //two-way link - this.otherHalf = otherHalf; - this.otherHalf.UnAssignOtherHalf(); //juste en cas - this.otherHalf.otherHalf = this; - this.otherHalf.SetPlayer(this.playerNum); - } - else if (force) - { - UnAssignOtherHalf(); - } - } - - public void UnAssignOtherHalf() - { - if (otherHalf != null) - { - this.otherHalf.otherHalf = null; - this.otherHalf.SetPlayer(-1); - } - otherHalf = null; - } - - public InputJoyshock GetOtherHalf() - { - return otherHalf; - } - public override bool GetFlick(out double dt) { dt = 0; @@ -996,12 +933,6 @@ namespace HeavenStudio.InputSystem m.SetColor("_LGripColor", ColorUtility.TryParseHtmlString("#2F353A", out colour) ? colour : Color.white); m.SetColor("_RGripColor", ColorUtility.TryParseHtmlString("#2F353A", out colour) ? colour : Color.white); break; - case "Joy-Con Pair": - m.SetColor("_BodyColor", splitType == SplitRight ? GetButtonColor() : GetOtherHalf().GetButtonColor()); - m.SetColor("_BtnColor", splitType == SplitLeft ? GetButtonColor() : GetOtherHalf().GetButtonColor()); - m.SetColor("_LGripColor", GetLeftGripColor()); - m.SetColor("_RGripColor", GetRightGripColor()); - break; case "DualShock 4": m.SetColor("_BodyColor", ColorUtility.TryParseHtmlString("#E1E2E4", out colour) ? colour : Color.white); m.SetColor("_BtnColor", ColorUtility.TryParseHtmlString("#414246", out colour) ? colour : Color.white); diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs index bb52b9d0..b8aa51bd 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs @@ -131,6 +131,16 @@ namespace HeavenStudio.InputSystem currentBindings = newBinds; } + public override ControlBindings UpdateBindings(ControlBindings lastBinds) + { + return lastBinds; + } + + public override int GetBindingsVersion() + { + return 0; + } + public override bool GetIsActionUnbindable(int action, ControlStyles style) { return false; @@ -197,60 +207,6 @@ namespace HeavenStudio.InputSystem return cam.ScreenToWorldPoint(rawPointerPos); } - //todo: directionals - public override bool GetHatDirection(InputDirection direction) - { - switch (direction) - { - case InputDirection.Up: - return Input.GetKey((KeyCode)currentBindings.Pad[0]); - case InputDirection.Down: - return Input.GetKey((KeyCode)currentBindings.Pad[1]); - case InputDirection.Left: - return Input.GetKey((KeyCode)currentBindings.Pad[2]); - case InputDirection.Right: - return Input.GetKey((KeyCode)currentBindings.Pad[3]); - default: - return false; - } - } - - public override bool GetHatDirectionDown(InputDirection direction, out double dt) - { - dt = 0; - switch (direction) - { - case InputDirection.Up: - return Input.GetKeyDown((KeyCode)currentBindings.Pad[0]); - case InputDirection.Down: - return Input.GetKeyDown((KeyCode)currentBindings.Pad[1]); - case InputDirection.Left: - return Input.GetKeyDown((KeyCode)currentBindings.Pad[2]); - case InputDirection.Right: - return Input.GetKeyDown((KeyCode)currentBindings.Pad[3]); - default: - return false; - } - } - - public override bool GetHatDirectionUp(InputDirection direction, out double dt) - { - dt = 0; - switch (direction) - { - case InputDirection.Up: - return Input.GetKeyUp((KeyCode)currentBindings.Pad[0]); - case InputDirection.Down: - return Input.GetKeyUp((KeyCode)currentBindings.Pad[1]); - case InputDirection.Left: - return Input.GetKeyUp((KeyCode)currentBindings.Pad[2]); - case InputDirection.Right: - return Input.GetKeyUp((KeyCode)currentBindings.Pad[3]); - default: - return false; - } - } - public override void SetPlayer(int? playerNum) { if (playerNum == -1 || playerNum == null) diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs index 09405548..0a19ef65 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputMouse.cs @@ -259,6 +259,16 @@ namespace HeavenStudio.InputSystem currentBindings = newBinds; } + public override ControlBindings UpdateBindings(ControlBindings lastBinds) + { + return lastBinds; + } + + public override int GetBindingsVersion() + { + return 0; + } + public override bool GetIsActionUnbindable(int action, ControlStyles style) { return action is 0; @@ -395,24 +405,6 @@ namespace HeavenStudio.InputSystem return realPos; } - //todo: directionals - public override bool GetHatDirection(InputDirection direction) - { - return false; - } - - public override bool GetHatDirectionDown(InputDirection direction, out double dt) - { - dt = 0; - return false; - } - - public override bool GetHatDirectionUp(InputDirection direction, out double dt) - { - dt = 0; - return false; - } - public override void SetPlayer(int? playerNum) { if (playerNum == -1 || playerNum == null) diff --git a/Assets/Scripts/InputSystem/InputController.cs b/Assets/Scripts/InputSystem/InputController.cs index 4f2a50b3..fd9ec9eb 100644 --- a/Assets/Scripts/InputSystem/InputController.cs +++ b/Assets/Scripts/InputSystem/InputController.cs @@ -141,6 +141,7 @@ namespace HeavenStudio.InputSystem [System.Serializable] public struct ControlBindings { + public int version; public int[] Pad; public int[] Baton; public int[] Touch; @@ -184,7 +185,19 @@ namespace HeavenStudio.InputSystem string json = File.ReadAllText(path); if (json is not null or "") { - currentBindings = JsonUtility.FromJson(json); + try + { + currentBindings = JsonUtility.FromJson(json); + if (currentBindings.version != GetBindingsVersion()) + { + currentBindings = UpdateBindings(currentBindings); + SaveBindings(); + } + } + catch (System.Exception) + { + ResetBindings(); + } } else { @@ -220,6 +233,19 @@ namespace HeavenStudio.InputSystem /// public abstract void SetCurrentBindings(ControlBindings newBinds); + /// + /// updates controller bindings to new versions + /// + /// bindings of a previous version + /// + public abstract ControlBindings UpdateBindings(ControlBindings lastBinds); + + /// + /// gets the current bindings version for this controller + /// + /// + public abstract int GetBindingsVersion(); + /// /// Whether a given action can have be rebount /// @@ -286,29 +312,6 @@ namespace HeavenStudio.InputSystem public abstract void TogglePointerLock(bool locked); public abstract void RecentrePointer(); - /// - /// True if the current direction is active - /// - /// - /// - public abstract bool GetHatDirection(InputDirection direction); - - /// - /// True if the current direction just became active this Update - /// - /// - /// time since the reported event, use to compensate for controller delays - /// - public abstract bool GetHatDirectionDown(InputDirection direction, out double dt); - - /// - /// True if the current direction just became inactive this Update - /// - /// - /// time since the reported event, use to compensate for controller delays - /// - public abstract bool GetHatDirectionUp(InputDirection direction, out double dt); - public abstract bool GetFlick(out double dt); public abstract bool GetSlide(out double dt); public abstract bool GetSqueezeDown(out double dt); diff --git a/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs b/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs index c1e067ac..4efcc278 100644 --- a/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs +++ b/Assets/Scripts/InputSystem/USG.g/InitInputControllers.PlayerInput.ControllerLoaderGenerator.g.cs @@ -23,16 +23,6 @@ namespace HeavenStudio PlayerInputRefresh = new(); PlayerInputCleanUp = null; - controllers = InputJoyshockInitializer.Initialize(); - if (controllers != null) - { - inputDevices.AddRange(controllers); - } - else - { - Debug.Log("InputJoyshockInitializer.Initialize had no controllers to initialize."); - } - controllers = InputKeyboardInitializer.Initialize(); if (controllers != null) { @@ -53,6 +43,26 @@ namespace HeavenStudio Debug.Log("InputMouseInitializer.Initialize had no controllers to initialize."); } + controllers = InputJoyshockInitializer.Initialize(); + if (controllers != null) + { + inputDevices.AddRange(controllers); + } + else + { + Debug.Log("InputJoyshockInitializer.Initialize had no controllers to initialize."); + } + + controllers = InputJoyconPairInitializer.Initialize(); + if (controllers != null) + { + inputDevices.AddRange(controllers); + } + else + { + Debug.Log("InputJoyconPairInitializer.Initialize had no controllers to initialize."); + } + return inputDevices.Count; } diff --git a/Assets/Scripts/LevelEditor/EditorTheme.cs b/Assets/Scripts/LevelEditor/EditorTheme.cs index dc79c412..b201f2da 100644 --- a/Assets/Scripts/LevelEditor/EditorTheme.cs +++ b/Assets/Scripts/LevelEditor/EditorTheme.cs @@ -32,27 +32,44 @@ namespace HeavenStudio.Editor if (File.Exists(Application.persistentDataPath + "/editorTheme.json")) { string json = File.ReadAllText(Application.persistentDataPath + "/editorTheme.json"); - theme = JsonConvert.DeserializeObject(json); - - // Naive way of doing it? Possibly, but we should have a theme editor in the future. - if (defaultTheme.properties.LayerColors != null) + if (json == "") { - theme.properties.LayerColors = new string[] + PersistentDataManager.SaveTheme(ThemeTXT.text); + theme = defaultTheme; + theme.SetLayersGradient(); + return; + } + try + { + theme = JsonConvert.DeserializeObject(json); + + // Naive way of doing it? Possibly, but we should have a theme editor in the future. + if (defaultTheme.properties.LayerColors != null) { - theme.properties.Layer1Col, - theme.properties.Layer2Col, - theme.properties.Layer3Col, - theme.properties.Layer4Col, - theme.properties.Layer5Col - }; - // Create a function for this in the future. - var savedTheme = JsonConvert.SerializeObject(theme, Formatting.Indented, new JsonSerializerSettings() - { - TypeNameHandling = TypeNameHandling.None, - NullValueHandling = NullValueHandling.Include, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - }); - PersistentDataManager.SaveTheme(savedTheme); + theme.properties.LayerColors = new string[] + { + theme.properties.Layer1Col, + theme.properties.Layer2Col, + theme.properties.Layer3Col, + theme.properties.Layer4Col, + theme.properties.Layer5Col + }; + // Create a function for this in the future. + var savedTheme = JsonConvert.SerializeObject(theme, Formatting.Indented, new JsonSerializerSettings() + { + TypeNameHandling = TypeNameHandling.None, + NullValueHandling = NullValueHandling.Include, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + }); + PersistentDataManager.SaveTheme(savedTheme); + } + } + catch + { + PersistentDataManager.SaveTheme(ThemeTXT.text); + theme = defaultTheme; + theme.SetLayersGradient(); + return; } } else diff --git a/Assets/Scripts/PersistentDataManager.cs b/Assets/Scripts/PersistentDataManager.cs index e0df0eb1..1c1508a0 100644 --- a/Assets/Scripts/PersistentDataManager.cs +++ b/Assets/Scripts/PersistentDataManager.cs @@ -67,7 +67,22 @@ namespace HeavenStudio.Common if (File.Exists(Application.persistentDataPath + "/settings.json")) { string json = File.ReadAllText(Application.persistentDataPath + "/settings.json"); - gameSettings = JsonUtility.FromJson(json); + if (json == "") + { + GlobalGameManager.IsFirstBoot = true; + CreateDefaultSettings(); + return; + } + try + { + gameSettings = JsonConvert.DeserializeObject(json); + } + catch (Exception e) + { + Debug.LogError($"Error while loading settings, creating default settings;\n{e.Message}"); + GlobalGameManager.IsFirstBoot = true; + CreateDefaultSettings(); + } } else { diff --git a/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs b/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs index e7a8618e..8e9fc815 100644 --- a/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs +++ b/Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs @@ -38,6 +38,8 @@ public partial class ControllerLoaderGenerator false )) .ToList(); + // sort by load order attribute (lower is first) + loadRunners.Sort((x, y) => x.Method.GetCustomAttribute().Order.CompareTo(y.Method.GetCustomAttribute().Order)); // USG: static classes are IsAbstract is set. if (!context.TargetClass.IsClass) diff --git a/Assets/Scripts/SourceGenerators/MinigameLoaderGenerator.cs b/Assets/Scripts/SourceGenerators/MinigameLoaderGenerator.cs index a686aa5a..1e0c3bf9 100644 --- a/Assets/Scripts/SourceGenerators/MinigameLoaderGenerator.cs +++ b/Assets/Scripts/SourceGenerators/MinigameLoaderGenerator.cs @@ -83,7 +83,6 @@ namespace {context.TargetClass.Namespace} string fullMethodLabel = $"{callingClass}.{method}"; sb.Append($@" - Debug.Log(""Running game loader {callingClass}""); game = {fullMethodLabel}(eventCaller); if (game != null) {{ diff --git a/Assets/Scripts/TitleManager.cs b/Assets/Scripts/TitleManager.cs index ff9e6f75..bfb8be8a 100644 --- a/Assets/Scripts/TitleManager.cs +++ b/Assets/Scripts/TitleManager.cs @@ -155,14 +155,9 @@ namespace HeavenStudio var nextController = newController; var lastController = PlayerInput.GetInputController(1); - if ((newController is InputMouse) && !(lastController is InputMouse)) - { - Debug.Log("Mouse used, selecting keyboard instead"); - nextController = controllers[0]; - } Debug.Log("Assigning controller: " + newController.GetDeviceName()); - if (lastController != nextController && !firstBoot) + if (lastController != nextController)// && !firstBoot) { firstBoot = false; if (nextController == null) @@ -172,6 +167,7 @@ namespace HeavenStudio } lastController.SetPlayer(null); nextController.SetPlayer(1); + nextController.OnSelected(); PlayerInput.CurrentControlStyle = nextController.GetDefaultStyle(); usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch; selectedDisplayIcon.SetActive(!usingMouse); @@ -179,18 +175,8 @@ namespace HeavenStudio { obj.SetActive(!usingMouse); } - - if ((lastController as InputJoyshock) != null) - { - (lastController as InputJoyshock)?.UnAssignOtherHalf(); - } - - if ((nextController as InputJoyshock) != null) - { - nextController.OnSelected(); - (nextController as InputJoyshock)?.UnAssignOtherHalf(); - } } + break; } else { @@ -276,13 +262,13 @@ namespace HeavenStudio } else if (settingsPanel.IsOpen) { - if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch) - { - if (controller.GetLastActionDown() == (int)InputController.ActionsPad.South) - { - SettingsClose(); - } - } + // if (PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch) + // { + // if (controller.GetLastActionDown() == (int)InputController.ActionsPad.South) + // { + // SettingsClose(); + // } + // } } else if (!firstPress) { @@ -570,7 +556,7 @@ namespace HeavenStudio } // waitingForButtonUp = true; - playPanelRevealTime = Time.realtimeSinceStartup + 0.2f; + playPanelRevealTime = Time.realtimeSinceStartup + 0.5f; playPanel.SetActive(true); playMenuRevealed = true; SoundByte.PlayOneShot("ui/UISelect"); diff --git a/Assets/Scripts/UI/SettingsDialog/Tabs/ControllerSettings.cs b/Assets/Scripts/UI/SettingsDialog/Tabs/ControllerSettings.cs index f111446a..9f4e83ec 100644 --- a/Assets/Scripts/UI/SettingsDialog/Tabs/ControllerSettings.cs +++ b/Assets/Scripts/UI/SettingsDialog/Tabs/ControllerSettings.cs @@ -23,9 +23,9 @@ namespace HeavenStudio.Editor [SerializeField] private TMP_Dropdown controllersDropdown; [SerializeField] private GameObject pairSearchItem; [SerializeField] private GameObject autoSearchLabel; - [SerializeField] private GameObject pairSearchLabel; - [SerializeField] private GameObject pairSearchCancelBt; - [SerializeField] private TMP_Text pairingLabel; + // [SerializeField] private GameObject pairSearchLabel; + // [SerializeField] private GameObject pairSearchCancelBt; + // [SerializeField] private TMP_Text pairingLabel; [SerializeField] private List controllerIcons; [SerializeField] private Material controllerMat; @@ -41,8 +41,8 @@ namespace HeavenStudio.Editor [SerializeField] private Slider cursorSensitivitySlider; private bool isAutoSearching = false; - private bool isPairSearching = false; - private bool pairSelectLR = false; //true = left, false = right + // private bool isPairSearching = false; + // private bool pairSelectLR = false; //true = left, false = right private bool bindAllMode; private int currentBindingBt; @@ -113,28 +113,35 @@ namespace HeavenStudio.Editor } } } - else if (isPairSearching) + else if (currentController.GetType() == typeof(InputJoyconPair)) { - var controllers = PlayerInput.GetInputControllers(); - InputController.InputFeatures lrFlag = pairSelectLR ? InputController.InputFeatures.Extra_SplitControllerLeft : InputController.InputFeatures.Extra_SplitControllerRight; - foreach (var pairController in controllers) + InputJoyconPair pair = (InputJoyconPair)currentController; + if (!pair.HasControllers()) { - if (pairController == currentController) continue; - - InputController.InputFeatures features = pairController.GetFeatures(); - if (!features.HasFlag(lrFlag)) continue; - - if (pairController.GetLastButtonDown() > 0) + Debug.Log("Pair searching"); + List controllers = PlayerInput.GetInputControllers() + .Select(x => x as InputJoyshock) + .Where(x => x != null && x.GetJoyshockType() is TypeJoyConLeft or TypeJoyConRight) + .ToList(); + foreach (var possibleController in controllers) { - (PlayerInput.GetInputController(1) as InputJoyshock)?.AssignOtherHalf((InputJoyshock)pairController); - isPairSearching = false; - pairSearchLabel.SetActive(false); - currentControllerLabel.text = "Current Controller: " + pairController.GetDeviceName(); - pairingLabel.text = "Joy-Con Pair Selected\nPairing Successful!"; - ShowControllerIcon(pairController); - - currentController.OnSelected(); - pairController.OnSelected(); + if (possibleController.GetLastButtonDown(true) == ButtonMaskZL && possibleController.GetJoyshockType() == TypeJoyConLeft) + { + pair.SetLeftController(possibleController); + pair.SetMaterialProperties(controllerMat); + } + else if (possibleController.GetLastButtonDown(true) == ButtonMaskZR && possibleController.GetJoyshockType() == TypeJoyConRight) + { + pair.SetRightController(possibleController); + pair.SetMaterialProperties(controllerMat); + } + } + if (pair.HasControllers()) + { + pairSearchItem.SetActive(false); + pair.OnSelected(); + pair.SetPlayer(1); + pair.SetMaterialProperties(controllerMat); } } } @@ -193,17 +200,6 @@ namespace HeavenStudio.Editor lastController.SetPlayer(null); newController.SetPlayer(1); - if ((lastController as InputJoyshock) != null) - { - (lastController as InputJoyshock)?.UnAssignOtherHalf(); - } - - if ((newController as InputJoyshock) != null) - { - newController.OnSelected(); - (newController as InputJoyshock)?.UnAssignOtherHalf(); - } - currentControllerLabel.text = "Current Controller: " + newController.GetDeviceName(); if (!newController.GetCurrentStyleSupported()) @@ -212,32 +208,23 @@ namespace HeavenStudio.Editor stylesDropdown.SetValueWithoutNotify((int)PlayerInput.CurrentControlStyle); } - UpdateControlStyleMapping(); - ShowControllerBinds(newController); - ShowControllerIcon(newController); + newController.OnSelected(); - InputController.InputFeatures features = newController.GetFeatures(); - if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft)) + if (newController is InputJoyconPair) { - pairingLabel.text = "Joy-Con (L) Selected\nPress any button on Joy-Con (R) to pair."; - - pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft); + InputJoyconPair pair = (InputJoyconPair)newController; + pair.SetLeftController(null); + pair.SetRightController(null); pairSearchItem.SetActive(true); - StartPairSearch(); - } - else if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerRight)) - { - pairingLabel.text = "Joy-Con (R) Selected\nPress any button on Joy-Con (L) to pair."; - - pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft); - pairSearchItem.SetActive(true); - StartPairSearch(); } else { - CancelPairSearch(); pairSearchItem.SetActive(false); } + + UpdateControlStyleMapping(); + ShowControllerBinds(newController); + ShowControllerIcon(newController); } public void ControllerDropdownChange() @@ -253,7 +240,12 @@ namespace HeavenStudio.Editor public void StartBindSingle(int bt) { CancelBind(); - if (PlayerInput.GetInputController(1).GetIsActionUnbindable(bt, PlayerInput.CurrentControlStyle)) + InputController currentController = PlayerInput.GetInputController(1); + if (currentController.GetIsActionUnbindable(bt, PlayerInput.CurrentControlStyle)) + { + return; + } + if (currentController is InputJoyconPair && !(currentController as InputJoyconPair).HasControllers()) { return; } @@ -276,9 +268,14 @@ namespace HeavenStudio.Editor public void StartBindAll() { CancelBind(); + InputController currentController = PlayerInput.GetInputController(1); + if (currentController is InputJoyconPair && !(currentController as InputJoyconPair).HasControllers()) + { + return; + } bindAllMode = true; currentBindingBt = -1; - AdvanceAutoBind(PlayerInput.GetInputController(1)); + AdvanceAutoBind(currentController); } public void CancelBind() @@ -300,34 +297,18 @@ namespace HeavenStudio.Editor public void StartAutoSearch() { CancelBind(); - if (!isPairSearching) - { - autoSearchLabel.SetActive(true); - isAutoSearching = true; - } + autoSearchLabel.SetActive(true); + isAutoSearching = true; } public void StartPairSearch() { CancelBind(); - if (!isAutoSearching) - { - pairSearchLabel.SetActive(true); - pairSearchCancelBt.SetActive(true); - isPairSearching = true; - } } public void CancelPairSearch() { CancelBind(); - if (isPairSearching) - { - pairSearchLabel.SetActive(false); - pairSearchCancelBt.SetActive(false); - isPairSearching = false; - pairingLabel.text = "Joy-Con Selected\nPairing was cancelled."; - } } public void SearchAndConnectControllers() diff --git a/Assets/Scripts/USG.g/LoadMinigames.Minigames.MinigameLoaderGenerator.g.cs b/Assets/Scripts/USG.g/LoadMinigames.Minigames.MinigameLoaderGenerator.g.cs index 9023dcd2..85466177 100644 --- a/Assets/Scripts/USG.g/LoadMinigames.Minigames.MinigameLoaderGenerator.g.cs +++ b/Assets/Scripts/USG.g/LoadMinigames.Minigames.MinigameLoaderGenerator.g.cs @@ -13,7 +13,6 @@ namespace HeavenStudio Minigames.Minigame game; - Debug.Log("Running game loader RvlBadmintonLoader"); game = RvlBadmintonLoader.AddGame(eventCaller); if (game != null) { @@ -24,7 +23,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlBadmintonLoader failed!"); } - Debug.Log("Running game loader CtrBearLoader"); game = CtrBearLoader.AddGame(eventCaller); if (game != null) { @@ -35,7 +33,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader CtrBearLoader failed!"); } - Debug.Log("Running game loader RvlBoardMeetingLoader"); game = RvlBoardMeetingLoader.AddGame(eventCaller); if (game != null) { @@ -46,7 +43,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlBoardMeetingLoader failed!"); } - Debug.Log("Running game loader NtrFlickLoader"); game = NtrFlickLoader.AddGame(eventCaller); if (game != null) { @@ -57,7 +53,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrFlickLoader failed!"); } - Debug.Log("Running game loader CtrCatchLoader"); game = CtrCatchLoader.AddGame(eventCaller); if (game != null) { @@ -68,7 +63,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader CtrCatchLoader failed!"); } - Debug.Log("Running game loader RvlBookLoader"); game = RvlBookLoader.AddGame(eventCaller); if (game != null) { @@ -79,7 +73,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlBookLoader failed!"); } - Debug.Log("Running game loader AgbClapLoader"); game = AgbClapLoader.AddGame(eventCaller); if (game != null) { @@ -90,7 +83,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbClapLoader failed!"); } - Debug.Log("Running game loader NtrCoinLoader"); game = NtrCoinLoader.AddGame(eventCaller); if (game != null) { @@ -101,7 +93,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrCoinLoader failed!"); } - Debug.Log("Running game loader NtrCropLoader"); game = NtrCropLoader.AddGame(eventCaller); if (game != null) { @@ -112,7 +103,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrCropLoader failed!"); } - Debug.Log("Running game loader NtrDjLoader"); game = NtrDjLoader.AddGame(eventCaller); if (game != null) { @@ -123,7 +113,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrDjLoader failed!"); } - Debug.Log("Running game loader NtrDogNinjaLoader"); game = NtrDogNinjaLoader.AddGame(eventCaller); if (game != null) { @@ -134,7 +123,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrDogNinjaLoader failed!"); } - Debug.Log("Running game loader RvlDoubleDateLoader"); game = RvlDoubleDateLoader.AddGame(eventCaller); if (game != null) { @@ -145,7 +133,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlDoubleDateLoader failed!"); } - Debug.Log("Running game loader CtrDrummingLoader"); game = CtrDrummingLoader.AddGame(eventCaller); if (game != null) { @@ -156,7 +143,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader CtrDrummingLoader failed!"); } - Debug.Log("Running game loader NtrIdolLoader"); game = NtrIdolLoader.AddGame(eventCaller); if (game != null) { @@ -167,7 +153,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrIdolLoader failed!"); } - Debug.Log("Running game loader AgbFireworkLoader"); game = AgbFireworkLoader.AddGame(eventCaller); if (game != null) { @@ -178,7 +163,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbFireworkLoader failed!"); } - Debug.Log("Running game loader CtrFirstContact"); game = CtrFirstContact.AddGame(eventCaller); if (game != null) { @@ -189,7 +173,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader CtrFirstContact failed!"); } - Debug.Log("Running game loader RvlFlipperFlopLoader"); game = RvlFlipperFlopLoader.AddGame(eventCaller); if (game != null) { @@ -200,7 +183,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlFlipperFlopLoader failed!"); } - Debug.Log("Running game loader RvlForkLoader"); game = RvlForkLoader.AddGame(eventCaller); if (game != null) { @@ -211,7 +193,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlForkLoader failed!"); } - Debug.Log("Running game loader NtrGleeClubLoader"); game = NtrGleeClubLoader.AddGame(eventCaller); if (game != null) { @@ -222,7 +203,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrGleeClubLoader failed!"); } - Debug.Log("Running game loader RvlNewKarateLoader"); game = RvlNewKarateLoader.AddGame(eventCaller); if (game != null) { @@ -233,7 +213,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlNewKarateLoader failed!"); } - Debug.Log("Running game loader CtrTeppanLoader"); game = CtrTeppanLoader.AddGame(eventCaller); if (game != null) { @@ -244,7 +223,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader CtrTeppanLoader failed!"); } - Debug.Log("Running game loader RvlRocketLoader"); game = RvlRocketLoader.AddGame(eventCaller); if (game != null) { @@ -255,7 +233,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlRocketLoader failed!"); } - Debug.Log("Running game loader NtrBackbeatLoader"); game = NtrBackbeatLoader.AddGame(eventCaller); if (game != null) { @@ -266,7 +243,26 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrBackbeatLoader failed!"); } - Debug.Log("Running game loader AgbMarcherLoader"); + game = AgbMannequinFactoryLoader.AddGame(eventCaller); + if (game != null) + { + eventCaller.minigames.Add(game.name, game); + } + else + { + Debug.LogWarning("Game loader AgbMannequinFactoryLoader failed!"); + } + + game = RvlManzaiLoader.AddGame(eventCaller); + if (game != null) + { + eventCaller.minigames.Add(game.name, game); + } + else + { + Debug.LogWarning("Game loader RvlManzaiLoader failed!"); + } + game = AgbMarcherLoader.AddGame(eventCaller); if (game != null) { @@ -277,7 +273,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbMarcherLoader failed!"); } - Debug.Log("Running game loader PcoMeatLoader"); game = PcoMeatLoader.AddGame(eventCaller); if (game != null) { @@ -288,7 +283,16 @@ namespace HeavenStudio Debug.LogWarning("Game loader PcoMeatLoader failed!"); } - Debug.Log("Running game loader AgbUpbeatLoader"); + game = RvlMonkeyWatchLoader.AddGame(eventCaller); + if (game != null) + { + eventCaller.minigames.Add(game.name, game); + } + else + { + Debug.LogWarning("Game loader RvlMonkeyWatchLoader failed!"); + } + game = AgbUpbeatLoader.AddGame(eventCaller); if (game != null) { @@ -299,7 +303,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbUpbeatLoader failed!"); } - Debug.Log("Running game loader ntrMunchyMonkLoader"); game = ntrMunchyMonkLoader.AddGame(eventCaller); if (game != null) { @@ -310,7 +313,16 @@ namespace HeavenStudio Debug.LogWarning("Game loader ntrMunchyMonkLoader failed!"); } - Debug.Log("Running game loader NtrOctopusMachineLoader"); + game = AgbNightWalkLoader.AddGame(eventCaller); + if (game != null) + { + eventCaller.minigames.Add(game.name, game); + } + else + { + Debug.LogWarning("Game loader AgbNightWalkLoader failed!"); + } + game = NtrOctopusMachineLoader.AddGame(eventCaller); if (game != null) { @@ -321,7 +333,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrOctopusMachineLoader failed!"); } - Debug.Log("Running game loader CtrPillowLoader"); game = CtrPillowLoader.AddGame(eventCaller); if (game != null) { @@ -332,7 +343,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader CtrPillowLoader failed!"); } - Debug.Log("Running game loader AgbQuizShowLoader"); game = AgbQuizShowLoader.AddGame(eventCaller); if (game != null) { @@ -343,7 +353,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbQuizShowLoader failed!"); } - Debug.Log("Running game loader NtrPingpongLoader"); game = NtrPingpongLoader.AddGame(eventCaller); if (game != null) { @@ -354,7 +363,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrPingpongLoader failed!"); } - Debug.Log("Running game loader PcoSomenLoader"); game = PcoSomenLoader.AddGame(eventCaller); if (game != null) { @@ -365,7 +373,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader PcoSomenLoader failed!"); } - Debug.Log("Running game loader AgbHairLoader"); game = AgbHairLoader.AddGame(eventCaller); if (game != null) { @@ -376,7 +383,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbHairLoader failed!"); } - Debug.Log("Running game loader RvlRingsideLoader"); game = RvlRingsideLoader.AddGame(eventCaller); if (game != null) { @@ -387,7 +393,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlRingsideLoader failed!"); } - Debug.Log("Running game loader NtrRockersLoader"); game = NtrRockersLoader.AddGame(eventCaller); if (game != null) { @@ -398,7 +403,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrRockersLoader failed!"); } - Debug.Log("Running game loader NtrSamuraiLoader"); game = NtrSamuraiLoader.AddGame(eventCaller); if (game != null) { @@ -409,7 +413,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrSamuraiLoader failed!"); } - Debug.Log("Running game loader RvlSeeSawLoader"); game = RvlSeeSawLoader.AddGame(eventCaller); if (game != null) { @@ -420,7 +423,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlSeeSawLoader failed!"); } - Debug.Log("Running game loader AgbGhostLoader"); game = AgbGhostLoader.AddGame(eventCaller); if (game != null) { @@ -431,7 +433,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbGhostLoader failed!"); } - Debug.Log("Running game loader AgbBatterLoader"); game = AgbBatterLoader.AddGame(eventCaller); if (game != null) { @@ -442,7 +443,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbBatterLoader failed!"); } - Debug.Log("Running game loader AgbSpaceDanceLoader"); game = AgbSpaceDanceLoader.AddGame(eventCaller); if (game != null) { @@ -453,7 +453,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbSpaceDanceLoader failed!"); } - Debug.Log("Running game loader NtrSoccerLoader"); game = NtrSoccerLoader.AddGame(eventCaller); if (game != null) { @@ -464,7 +463,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrSoccerLoader failed!"); } - Debug.Log("Running game loader NtrSplashdownLoader"); game = NtrSplashdownLoader.AddGame(eventCaller); if (game != null) { @@ -475,7 +473,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrSplashdownLoader failed!"); } - Debug.Log("Running game loader RvlTambourineLoader"); game = RvlTambourineLoader.AddGame(eventCaller); if (game != null) { @@ -486,7 +483,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlTambourineLoader failed!"); } - Debug.Log("Running game loader AgbTapLoader"); game = AgbTapLoader.AddGame(eventCaller); if (game != null) { @@ -497,7 +493,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbTapLoader failed!"); } - Debug.Log("Running game loader RvlTapTroupeLoader"); game = RvlTapTroupeLoader.AddGame(eventCaller); if (game != null) { @@ -508,7 +503,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader RvlTapTroupeLoader failed!"); } - Debug.Log("Running game loader NtrDazzlesLoader"); game = NtrDazzlesLoader.AddGame(eventCaller); if (game != null) { @@ -519,7 +513,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrDazzlesLoader failed!"); } - Debug.Log("Running game loader AgbTossBoysLoader"); game = AgbTossBoysLoader.AddGame(eventCaller); if (game != null) { @@ -530,7 +523,16 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbTossBoysLoader failed!"); } - Debug.Log("Running game loader AgbTramLoader"); + game = TotemClimbLoader.AddGame(eventCaller); + if (game != null) + { + eventCaller.minigames.Add(game.name, game); + } + else + { + Debug.LogWarning("Game loader TotemClimbLoader failed!"); + } + game = AgbTramLoader.AddGame(eventCaller); if (game != null) { @@ -541,7 +543,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbTramLoader failed!"); } - Debug.Log("Running game loader MobTrickLoader"); game = MobTrickLoader.AddGame(eventCaller); if (game != null) { @@ -552,7 +553,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader MobTrickLoader failed!"); } - Debug.Log("Running game loader NtrTunnelLoader"); game = NtrTunnelLoader.AddGame(eventCaller); if (game != null) { @@ -563,7 +563,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader NtrTunnelLoader failed!"); } - Debug.Log("Running game loader AgbWaltzLoader"); game = AgbWaltzLoader.AddGame(eventCaller); if (game != null) { @@ -574,7 +573,6 @@ namespace HeavenStudio Debug.LogWarning("Game loader AgbWaltzLoader failed!"); } - Debug.Log("Running game loader RvlWorkingDoughLoader"); game = RvlWorkingDoughLoader.AddGame(eventCaller); if (game != null) {