prepare the new controller
update JSL
This commit is contained in:
parent
138c17f595
commit
acc33e5a90
Binary file not shown.
Binary file not shown.
Binary file not shown.
254
Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs
Normal file
254
Assets/Scripts/InputSystem/ControllerTypes/InputJoyconPair.cs
Normal file
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 538461cea16b9a94eb31f272a79cd574
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -621,9 +621,8 @@ namespace HeavenStudio.InputSystem
|
||||||
{
|
{
|
||||||
if (type is TypeJoyConLeft or TypeJoyConRight)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -860,6 +859,11 @@ namespace HeavenStudio.InputSystem
|
||||||
return BitwiseUtils.IntToRgb(lightbarColour);
|
return BitwiseUtils.IntToRgb(lightbarColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetJoyshockType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetLightbarColour(Color color)
|
public void SetLightbarColour(Color color)
|
||||||
{
|
{
|
||||||
lightbarColour = BitwiseUtils.RgbToInt(color);
|
lightbarColour = BitwiseUtils.RgbToInt(color);
|
||||||
|
|
|
||||||
|
|
@ -179,17 +179,6 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
obj.SetActive(!usingMouse);
|
obj.SetActive(!usingMouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lastController as InputJoyshock) != null)
|
|
||||||
{
|
|
||||||
(lastController as InputJoyshock)?.UnAssignOtherHalf();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((nextController as InputJoyshock) != null)
|
|
||||||
{
|
|
||||||
nextController.OnSelected();
|
|
||||||
(nextController as InputJoyshock)?.UnAssignOtherHalf();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ namespace HeavenStudio.Editor
|
||||||
[SerializeField] private TMP_Dropdown controllersDropdown;
|
[SerializeField] private TMP_Dropdown controllersDropdown;
|
||||||
[SerializeField] private GameObject pairSearchItem;
|
[SerializeField] private GameObject pairSearchItem;
|
||||||
[SerializeField] private GameObject autoSearchLabel;
|
[SerializeField] private GameObject autoSearchLabel;
|
||||||
[SerializeField] private GameObject pairSearchLabel;
|
// [SerializeField] private GameObject pairSearchLabel;
|
||||||
[SerializeField] private GameObject pairSearchCancelBt;
|
// [SerializeField] private GameObject pairSearchCancelBt;
|
||||||
[SerializeField] private TMP_Text pairingLabel;
|
// [SerializeField] private TMP_Text pairingLabel;
|
||||||
[SerializeField] private List<GameObject> controllerIcons;
|
[SerializeField] private List<GameObject> controllerIcons;
|
||||||
|
|
||||||
[SerializeField] private Material controllerMat;
|
[SerializeField] private Material controllerMat;
|
||||||
|
|
@ -41,8 +41,8 @@ namespace HeavenStudio.Editor
|
||||||
[SerializeField] private Slider cursorSensitivitySlider;
|
[SerializeField] private Slider cursorSensitivitySlider;
|
||||||
|
|
||||||
private bool isAutoSearching = false;
|
private bool isAutoSearching = false;
|
||||||
private bool isPairSearching = false;
|
// private bool isPairSearching = false;
|
||||||
private bool pairSelectLR = false; //true = left, false = right
|
// private bool pairSelectLR = false; //true = left, false = right
|
||||||
|
|
||||||
private bool bindAllMode;
|
private bool bindAllMode;
|
||||||
private int currentBindingBt;
|
private int currentBindingBt;
|
||||||
|
|
@ -113,31 +113,9 @@ namespace HeavenStudio.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPairSearching)
|
// 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,17 +171,6 @@ namespace HeavenStudio.Editor
|
||||||
lastController.SetPlayer(null);
|
lastController.SetPlayer(null);
|
||||||
newController.SetPlayer(1);
|
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();
|
currentControllerLabel.text = "Current Controller: " + newController.GetDeviceName();
|
||||||
|
|
||||||
if (!newController.GetCurrentStyleSupported())
|
if (!newController.GetCurrentStyleSupported())
|
||||||
|
|
@ -215,29 +182,6 @@ namespace HeavenStudio.Editor
|
||||||
UpdateControlStyleMapping();
|
UpdateControlStyleMapping();
|
||||||
ShowControllerBinds(newController);
|
ShowControllerBinds(newController);
|
||||||
ShowControllerIcon(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()
|
public void ControllerDropdownChange()
|
||||||
|
|
@ -300,34 +244,18 @@ namespace HeavenStudio.Editor
|
||||||
public void StartAutoSearch()
|
public void StartAutoSearch()
|
||||||
{
|
{
|
||||||
CancelBind();
|
CancelBind();
|
||||||
if (!isPairSearching)
|
|
||||||
{
|
|
||||||
autoSearchLabel.SetActive(true);
|
autoSearchLabel.SetActive(true);
|
||||||
isAutoSearching = true;
|
isAutoSearching = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void StartPairSearch()
|
public void StartPairSearch()
|
||||||
{
|
{
|
||||||
CancelBind();
|
CancelBind();
|
||||||
if (!isAutoSearching)
|
|
||||||
{
|
|
||||||
pairSearchLabel.SetActive(true);
|
|
||||||
pairSearchCancelBt.SetActive(true);
|
|
||||||
isPairSearching = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CancelPairSearch()
|
public void CancelPairSearch()
|
||||||
{
|
{
|
||||||
CancelBind();
|
CancelBind();
|
||||||
if (isPairSearching)
|
|
||||||
{
|
|
||||||
pairSearchLabel.SetActive(false);
|
|
||||||
pairSearchCancelBt.SetActive(false);
|
|
||||||
isPairSearching = false;
|
|
||||||
pairingLabel.text = "Joy-Con Selected\nPairing was cancelled.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SearchAndConnectControllers()
|
public void SearchAndConnectControllers()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue