mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-26 03:25:22 +00:00
add controller selection, auto-search
- fix bug in master volume control where the text input doesn't work - fix bug in the Fan Club minigame where the player wouldn't jump when they were supposed to
This commit is contained in:
parent
a45625ebd0
commit
96ac465200
8 changed files with 144 additions and 35 deletions
|
@ -736,7 +736,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &14095204
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3972,7 +3972,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: -289.15, y: 2}
|
||||
m_AnchoredPosition: {x: -289.15002, y: 2}
|
||||
m_SizeDelta: {x: -578.29, y: 49.92}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!114 &156962255
|
||||
|
@ -10814,6 +10814,9 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
numConnectedLabel: {fileID: 976256976}
|
||||
currentControllerLabel: {fileID: 1007704296}
|
||||
controllersDropdown: {fileID: 1317282580}
|
||||
splitControllersDropdown: {fileID: 1219573650}
|
||||
autoSearchLabel: {fileID: 1359502640}
|
||||
--- !u!1 &528192059
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -13272,7 +13275,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 704039020}
|
||||
m_Direction: 0
|
||||
m_Value: 0
|
||||
m_Size: 0.032871276
|
||||
m_Size: 0.03287128
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
@ -19115,7 +19118,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 1589389271}
|
||||
m_Direction: 2
|
||||
m_Value: 1
|
||||
m_Size: 1
|
||||
m_Size: 0.9999944
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
@ -24822,7 +24825,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 130.0071}
|
||||
m_AnchoredPosition: {x: 0, y: 129.91104}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!114 &1154875944
|
||||
|
@ -25279,7 +25282,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -49.999878}
|
||||
m_AnchoredPosition: {x: 0, y: -49.99991}
|
||||
m_SizeDelta: {x: -48, y: -148}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1182686745
|
||||
|
@ -38346,7 +38349,19 @@ MonoBehaviour:
|
|||
m_TargetGraphic: {fileID: 1802706671}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 527828799}
|
||||
m_TargetAssemblyTypeName: HeavenStudio.Editor.ControllerSettings, Assembly-CSharp
|
||||
m_MethodName: StartAutoSearch
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &1802706671
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -38494,7 +38509,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -84.98996}
|
||||
m_AnchoredPosition: {x: 0, y: -84.98999}
|
||||
m_SizeDelta: {x: 320, y: -113.92}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!1 &1852819572
|
||||
|
|
|
@ -122,6 +122,7 @@ namespace HeavenStudio.Games.Scripts_FanClub
|
|||
{
|
||||
animator.Play("FanFree", -1, 0);
|
||||
stopBeat = false;
|
||||
clappingStartTime = Single.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,6 +205,7 @@ namespace HeavenStudio.Games.Scripts_FanClub
|
|||
animator.Play("FanJump", -1, 0);
|
||||
Jukebox.PlayOneShotGame("fanClub/play_jump");
|
||||
jumpStartTime = cond.songPositionInBeats;
|
||||
clappingStartTime = Single.MinValue;
|
||||
stopCharge = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,17 +123,17 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public override bool GetButton(int button)
|
||||
{
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, mappings[button]);
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, 1 << mappings[button]);
|
||||
}
|
||||
|
||||
public override bool GetButtonDown(int button)
|
||||
{
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, mappings[button]);
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << mappings[button]);
|
||||
}
|
||||
|
||||
public override bool GetButtonUp(int button)
|
||||
{
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, mappings[button]);
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << mappings[button]);
|
||||
}
|
||||
|
||||
public override float GetAxis(InputAxis axis)
|
||||
|
@ -164,74 +164,93 @@ namespace HeavenStudio.InputSystem
|
|||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
//todo: check analogue stick hat direction too
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, ButtonMaskUp);
|
||||
bt = mappings[0];
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, ButtonMaskDown);
|
||||
bt = mappings[1];
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, ButtonMaskLeft);
|
||||
bt = mappings[2];
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, ButtonMaskRight);
|
||||
bt = mappings[3];
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, 1 << bt);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction)
|
||||
{
|
||||
//todo: check analogue stick hat direction too
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskUp);
|
||||
bt = mappings[0];
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskDown);
|
||||
bt = mappings[1];
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskLeft);
|
||||
bt = mappings[2];
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskRight);
|
||||
bt = mappings[3];
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction)
|
||||
{
|
||||
//todo: check analogue stick hat direction too
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskUp);
|
||||
bt = mappings[0];
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskDown);
|
||||
bt = mappings[1];
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskLeft);
|
||||
bt = mappings[2];
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, ButtonMaskRight);
|
||||
bt = mappings[3];
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt);
|
||||
}
|
||||
|
||||
public override void SetPlayer(int playerNum)
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
if (playerNum == -1)
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
{
|
||||
this.playerNum = null;
|
||||
JslSetPlayerNumber(joyshockHandle, 0);
|
||||
return;
|
||||
}
|
||||
this.playerNum = playerNum;
|
||||
int ledMask = (int) this.playerNum;
|
||||
if (type == TypeDualSense)
|
||||
{
|
||||
if (playerNum <= 4)
|
||||
{
|
||||
playerNum = DualSensePlayerMask[playerNum];
|
||||
ledMask = DualSensePlayerMask[(int) this.playerNum];
|
||||
}
|
||||
}
|
||||
JslSetPlayerNumber(joyshockHandle, playerNum);
|
||||
this.playerNum = playerNum;
|
||||
JslSetPlayerNumber(joyshockHandle, ledMask);
|
||||
}
|
||||
|
||||
public override int? GetPlayer()
|
||||
|
|
|
@ -136,14 +136,14 @@ namespace HeavenStudio.InputSystem
|
|||
}
|
||||
}
|
||||
|
||||
public override void SetPlayer(int playerNum)
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
if (playerNum == -1)
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
{
|
||||
this.playerNum = null;
|
||||
return;
|
||||
}
|
||||
this.playerNum = playerNum;
|
||||
this.playerNum = (int) playerNum;
|
||||
}
|
||||
|
||||
public override int? GetPlayer()
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace HeavenStudio.InputSystem
|
|||
public abstract bool GetHatDirectionDown(InputDirection direction); // direction just became active?
|
||||
public abstract bool GetHatDirectionUp(InputDirection direction); // direction just became inactive?
|
||||
|
||||
public abstract void SetPlayer(int playerNum); // Set the player number (starts at 1, set to -1 or null for no player)
|
||||
public abstract void SetPlayer(int? playerNum); // Set the player number (starts at 1, set to -1 or null for no player)
|
||||
public abstract int? GetPlayer(); // Get the player number (null if no player)
|
||||
|
||||
//public abstract Sprite GetDisplayIcon(); //"big icon" for the controller in the settings menu
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace HeavenStudio
|
|||
InputJoyshock joyshock = new InputJoyshock(i);
|
||||
joyshock.InitializeController();
|
||||
joyshock.SetPlayer(inputDevices.Count + 1);
|
||||
inputDevices.Add(joyshock);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -99,6 +100,22 @@ namespace HeavenStudio
|
|||
return null;
|
||||
}
|
||||
|
||||
public static int GetInputControllerId(int player)
|
||||
{
|
||||
//select input controller id that has player field set to player
|
||||
//this will return the first controller that has that player number in the case of controller pairs (eg. Joy-Cons)
|
||||
//so such controllers should have a reference to the other controller in the pair
|
||||
//controller IDs are determined by connection order (the Keyboard is always first)
|
||||
for (int i = 0; i < inputDevices.Count; i++)
|
||||
{
|
||||
if (inputDevices[i].GetPlayer() == player)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void UpdateInputControllers()
|
||||
{
|
||||
foreach (InputController i in inputDevices)
|
||||
|
|
|
@ -17,10 +17,53 @@ namespace HeavenStudio.Editor
|
|||
[SerializeField] private TMP_Text currentControllerLabel;
|
||||
[SerializeField] private TMP_Dropdown controllersDropdown;
|
||||
[SerializeField] private TMP_Dropdown splitControllersDropdown;
|
||||
[SerializeField] private GameObject autoSearchLabel;
|
||||
|
||||
private bool isAutoSearching = false;
|
||||
|
||||
private void Start() {
|
||||
numConnectedLabel.text = "Connected: " + PlayerInput.GetNumControllersConnected();
|
||||
currentControllerLabel.text = "Current Controller: " + PlayerInput.GetInputController(1).GetDeviceName();
|
||||
PopulateControllersDropdown();
|
||||
PopulateSplitControllersDropdown();
|
||||
|
||||
controllersDropdown.onValueChanged.AddListener(delegate
|
||||
{
|
||||
InputController lastController = PlayerInput.GetInputController(1);
|
||||
InputController newController = PlayerInput.GetInputControllers()[controllersDropdown.value];
|
||||
lastController.SetPlayer(newController.GetPlayer() != null ? (int) newController.GetPlayer() : -1);
|
||||
newController.SetPlayer(1);
|
||||
currentControllerLabel.text = "Current Controller: " + newController.GetDeviceName();
|
||||
|
||||
if (typeof(InputJoyshock) == newController.GetType()) {
|
||||
StartCoroutine(SelectionVibrate((InputJoyshock) newController));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (isAutoSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
foreach (var controller in controllers) {
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
PlayerInput.GetInputController(1).SetPlayer(controller.GetPlayer() != null ? (int) controller.GetPlayer() : -1);
|
||||
controller.SetPlayer(1);
|
||||
isAutoSearching = false;
|
||||
autoSearchLabel.SetActive(false);
|
||||
controllersDropdown.value = PlayerInput.GetInputControllerId(1);
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
|
||||
if (typeof(InputJoyshock) == controller.GetType()) {
|
||||
StartCoroutine(SelectionVibrate((InputJoyshock) controller));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAutoSearch() {
|
||||
autoSearchLabel.SetActive(true);
|
||||
isAutoSearching = true;
|
||||
}
|
||||
|
||||
public void SearchAndConnectControllers()
|
||||
|
@ -28,9 +71,11 @@ namespace HeavenStudio.Editor
|
|||
int connected = PlayerInput.InitInputControllers();
|
||||
numConnectedLabel.text = "Connected: " + connected;
|
||||
currentControllerLabel.text = "Current Controller: " + PlayerInput.GetInputController(1).GetDeviceName();
|
||||
PopulateControllersDropdown();
|
||||
PopulateSplitControllersDropdown();
|
||||
}
|
||||
|
||||
public void populateControllersDropdown()
|
||||
public void PopulateControllersDropdown()
|
||||
{
|
||||
List<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
|
||||
var vals = PlayerInput.GetInputControllers();
|
||||
|
@ -44,7 +89,7 @@ namespace HeavenStudio.Editor
|
|||
controllersDropdown.value = 0;
|
||||
}
|
||||
|
||||
public void populateSplitControllersDropdown()
|
||||
public void PopulateSplitControllersDropdown()
|
||||
{
|
||||
List<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
|
||||
var vals = PlayerInput.GetInputControllers();
|
||||
|
@ -62,5 +107,16 @@ namespace HeavenStudio.Editor
|
|||
splitControllersDropdown.AddOptions(dropDownData);
|
||||
splitControllersDropdown.value = 0;
|
||||
}
|
||||
|
||||
IEnumerator SelectionVibrate(InputJoyshock controller)
|
||||
{
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.2f, 0.25f, 80f, 160f);
|
||||
yield return new WaitForSeconds(0.08f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0f, 0f, 0f, 0f);
|
||||
yield return new WaitForSeconds(0.04f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.25f, 0f, 640f, 0f);
|
||||
yield return new WaitForSeconds(0.05f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0f, 0f, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,7 +68,7 @@ namespace HeavenStudio.Editor
|
|||
|
||||
public void OnVolLabelChanged()
|
||||
{
|
||||
volSlider.value = (float)System.Math.Round(System.Convert.ToSingle(volLabel.text), 2);
|
||||
volSlider.value = (float)System.Math.Round(System.Convert.ToSingle(volLabel.text) / 100f, 2);
|
||||
GlobalGameManager.ChangeMasterVolume(volSlider.value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue