diff --git a/namedropper/Assets/TrackballInputManager.cs b/namedropper/Assets/TrackballInputManager.cs index a8879e5..96e8025 100644 --- a/namedropper/Assets/TrackballInputManager.cs +++ b/namedropper/Assets/TrackballInputManager.cs @@ -8,7 +8,7 @@ using UnityEngine.UI; public class TrackballInputManager : MonoBehaviour { - const float defaultMiceSensitivity = 1f; + const float defaultMiceSensitivity = 2f; const float upMultiplier = .5f; const float accelerationThreshold = 40; const float accelerationMultiplier = 2; @@ -26,6 +26,8 @@ public class TrackballInputManager : MonoBehaviour public const byte RE_MOUSE = 2; public const byte RE_DEVICE_DISCONNECT = 1; + List _ignoredDevices = new List(); + [StructLayout(LayoutKind.Sequential)] public struct RawInputEvent { @@ -44,29 +46,37 @@ public class TrackballInputManager : MonoBehaviour public int playerID; public float sensitivity; } - public static TrackballInputManager instance; + //public static TrackballInputManager instance; [SerializeField] List _players; // Start is called before the first frame update void Start() { - instance = this; - bool res = init(); - Debug.Log("Init() ==> " + res); + //instance = this; + if (isInit == false) + { + bool res = init(); + Debug.Log("Init() ==> " + res); + isInit = true; + } //Debug.Log(Marshal.SizeOf(typeof(RawInputEvent))); //canvas = GetComponent(); //canvasRect = GetComponent(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; + + _ignoredDevices.Add(4468289); } public void OnDestroy() { - instance = null; + //instance = null; + kill(); + isInit = false; } int lastEvents = 0; - bool isInit = true; + static bool isInit = false; void Update() { @@ -112,8 +122,11 @@ public class TrackballInputManager : MonoBehaviour } else { - Debug.Log("Unknown device found"); - AddPlayer(ev.devHandle); + if (_ignoredDevices.Contains(ev.devHandle) == false) + { + Debug.Log("Unknown device found"); + AddPlayer(ev.devHandle); + } } } } @@ -133,6 +146,9 @@ public class TrackballInputManager : MonoBehaviour int AddPlayer(int deviceId) { + if (_ignoredDevices.Contains(deviceId)) + return -1; + if (!isInit) { Debug.LogError("Not initialized");