diff --git a/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.dll b/Assets/Plugins/JoyShockLibrary/Plugins/JoyShockLibrary.dll index f83c1226b..abf2267e1 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/libJoyShockLibrary.dylib b/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.dylib index 405204e45..fbb8ad00d 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 e37994c4d..a0daa0f04 100644 Binary files a/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.so and b/Assets/Plugins/JoyShockLibrary/Plugins/libJoyShockLibrary.so differ diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs new file mode 100644 index 000000000..a31c9772e --- /dev/null +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs @@ -0,0 +1,254 @@ +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 + { + public override bool GetAction(ControlStyles style, int action) + { + throw new NotImplementedException(); + } + + public override bool GetActionDown(ControlStyles style, int action, out double dt) + { + throw new NotImplementedException(); + } + + public override bool GetActionUp(ControlStyles style, int action, out double dt) + { + throw new NotImplementedException(); + } + + public override float GetAxis(InputAxis axis) + { + throw new NotImplementedException(); + } + + public override int GetBindingsVersion() + { + throw new NotImplementedException(); + } + + public override string[] GetButtonNames() + { + throw new NotImplementedException(); + } + + public override ControlBindings GetCurrentBindings() + { + throw new NotImplementedException(); + } + + public override bool GetCurrentStyleSupported() + { + throw new NotImplementedException(); + } + + public override ControlBindings GetDefaultBindings() + { + throw new NotImplementedException(); + } + + public override ControlStyles GetDefaultStyle() + { + throw new NotImplementedException(); + } + + public override string GetDeviceName() + { + throw new NotImplementedException(); + } + + public override InputFeatures GetFeatures() + { + throw new NotImplementedException(); + } + + public override bool GetFlick(out double dt) + { + throw new NotImplementedException(); + } + + public override bool GetHatDirection(InputDirection direction) + { + throw new NotImplementedException(); + } + + public override bool GetHatDirectionDown(InputDirection direction, out double dt) + { + throw new NotImplementedException(); + } + + public override bool GetHatDirectionUp(InputDirection direction, out double dt) + { + throw new NotImplementedException(); + } + + public override bool GetIsActionUnbindable(int action, ControlStyles style) + { + throw new NotImplementedException(); + } + + public override bool GetIsConnected() + { + throw new NotImplementedException(); + } + + public override bool GetIsPoorConnection() + { + throw new NotImplementedException(); + } + + public override int GetLastActionDown() + { + throw new NotImplementedException(); + } + + public override int GetLastButtonDown(bool strict = false) + { + throw new NotImplementedException(); + } + + public override int? GetPlayer() + { + throw new NotImplementedException(); + } + + public override Vector2 GetPointer() + { + throw new NotImplementedException(); + } + + public override bool GetPointerLeftRight() + { + throw new NotImplementedException(); + } + + public override bool GetSlide(out double dt) + { + throw new NotImplementedException(); + } + + public override bool GetSqueeze() + { + throw new NotImplementedException(); + } + + public override bool GetSqueezeDown(out double dt) + { + throw new NotImplementedException(); + } + + public override bool GetSqueezeUp(out double dt) + { + throw new NotImplementedException(); + } + + public override Vector3 GetVector(InputVector vector) + { + throw new NotImplementedException(); + } + + public override void InitializeController() + { + throw new NotImplementedException(); + } + + public override void OnSelected() + { + throw new NotImplementedException(); + } + + public override void RecentrePointer() + { + throw new NotImplementedException(); + } + + public override void ResetBindings() + { + throw new NotImplementedException(); + } + + public override void SetCurrentBindings(ControlBindings newBinds) + { + throw new NotImplementedException(); + } + + public override void SetMaterialProperties(Material m) + { + throw new NotImplementedException(); + } + + public override void SetPlayer(int? playerNum) + { + throw new NotImplementedException(); + } + + public override void TogglePointerLock(bool locked) + { + throw new NotImplementedException(); + } + + public override ControlBindings UpdateBindings(ControlBindings lastBinds) + { + throw new NotImplementedException(); + } + + public override void UpdateState() + { + throw new NotImplementedException(); + } + } +} \ 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 000000000..6fd1f9a14 --- /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 f767c4429..098bc347b 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs @@ -621,10 +621,9 @@ namespace HeavenStudio.InputSystem { if (type is TypeJoyConLeft or TypeJoyConRight) { - switch (style) + if (style is ControlStyles.Pad) { - case ControlStyles.Pad: - return action is 0 or 1 or 2 or 3; + return action is 0 or 1 or 2 or 3; } } return false; @@ -860,6 +859,11 @@ namespace HeavenStudio.InputSystem return BitwiseUtils.IntToRgb(lightbarColour); } + public int GetJoyshockType() + { + return type; + } + public void SetLightbarColour(Color color) { lightbarColour = BitwiseUtils.RgbToInt(color); diff --git a/Assets/Scripts/TitleManager.cs b/Assets/Scripts/TitleManager.cs index ff9e6f757..df289c8d3 100644 --- a/Assets/Scripts/TitleManager.cs +++ b/Assets/Scripts/TitleManager.cs @@ -179,17 +179,6 @@ 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(); - } } } else diff --git a/Assets/Scripts/UI/SettingsDialog/Tabs/ControllerSettings.cs b/Assets/Scripts/UI/SettingsDialog/Tabs/ControllerSettings.cs index f111446a2..65581b452 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,31 +113,9 @@ namespace HeavenStudio.Editor } } } - else if (isPairSearching) - { - var controllers = PlayerInput.GetInputControllers(); - InputController.InputFeatures lrFlag = pairSelectLR ? InputController.InputFeatures.Extra_SplitControllerLeft : InputController.InputFeatures.Extra_SplitControllerRight; - foreach (var pairController in controllers) - { - if (pairController == currentController) continue; - - InputController.InputFeatures features = pairController.GetFeatures(); - if (!features.HasFlag(lrFlag)) continue; - - if (pairController.GetLastButtonDown() > 0) - { - (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(); - } - } - } + // else if (isPairSearching) + // { + // } } } @@ -193,17 +171,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()) @@ -215,29 +182,6 @@ namespace HeavenStudio.Editor UpdateControlStyleMapping(); ShowControllerBinds(newController); ShowControllerIcon(newController); - - InputController.InputFeatures features = newController.GetFeatures(); - if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft)) - { - pairingLabel.text = "Joy-Con (L) Selected\nPress any button on Joy-Con (R) to pair."; - - pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft); - 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); - } } public void ControllerDropdownChange() @@ -300,34 +244,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()