JoyShockLibrary (#213)

Fix PlayerInput.cs errors on MacOS
Fix libraries not being added to the final build
This commit is contained in:
Saraistupid
2023-01-21 03:39:58 +02:00
committed by GitHub
parent 26ff58a407
commit d41463ed82
10 changed files with 200 additions and 6 deletions

BIN
Assets/Scripts/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -87,6 +87,17 @@ namespace HeavenStudio
public static InputController GetInputController(int player)
{
// Needed so Keyboard works on MacOS
#if UNITY_EDITOR_OSX
inputDevices = new List<InputController>();
if(inputDevices.Count < 1)
{
InputKeyboard keyboard = new InputKeyboard();
keyboard.SetPlayer(1);
keyboard.InitializeController();
inputDevices.Add(keyboard);
}
#endif
//select input controller 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
@ -106,6 +117,19 @@ namespace HeavenStudio
//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)
// Needed so Keyboard works on MacOS
#if UNITY_EDITOR_OSX
inputDevices = new List<InputController>();
if(inputDevices.Count < 1)
{
InputKeyboard keyboard = new InputKeyboard();
keyboard.SetPlayer(1);
keyboard.InitializeController();
inputDevices.Add(keyboard);
}
#endif
for (int i = 0; i < inputDevices.Count; i++)
{
if (inputDevices[i].GetPlayer() == player)
@ -118,6 +142,17 @@ namespace HeavenStudio
public static void UpdateInputControllers()
{
// Needed so Keyboard works on MacOS
#if UNITY_EDITOR_OSX
inputDevices = new List<InputController>();
if(inputDevices.Count < 1)
{
InputKeyboard keyboard = new InputKeyboard();
keyboard.SetPlayer(1);
keyboard.InitializeController();
inputDevices.Add(keyboard);
}
#endif
foreach (InputController i in inputDevices)
{
i.UpdateState();
@ -244,4 +279,4 @@ namespace HeavenStudio
return GetInputController(1).GetHatDirectionUp((InputController.InputDirection) direction) && playerHasControl();
}
}
}
}