From a93e8647ca5cded4bf9dafbbb9fbdc33b5774863 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 9 Mar 2023 16:14:43 -0500 Subject: [PATCH] trackballs working on my laptop --- .gitignore | 3 ++ namedropper/Assets/Join.cs | 34 ++++++++++++++++--- namedropper/Assets/Scenes/Title.unity | 5 ++- namedropper/Assets/Scripts/TopicSelect.cs | 17 ++++++++++ namedropper/Assets/TrackballInputManager.cs | 36 ++++++++++++++++++--- 5 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..695d50d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +rawinputdll/rawinputdll/.vs/rawinputdll/v17 +rawinputdll/rawinputdll/UpgradeLog.htm +rawinputdll/rawinputdll/.vs/rawinputdll/project-colors.json diff --git a/namedropper/Assets/Join.cs b/namedropper/Assets/Join.cs index 2ea5d77..eca36eb 100644 --- a/namedropper/Assets/Join.cs +++ b/namedropper/Assets/Join.cs @@ -10,14 +10,23 @@ public class Join : MonoBehaviour [SerializeField] List _readyKeys = new List(); int _numPlayersReady = 0; + public int NumPlayersReady { get => _numPlayersReady; + set + { + _numPlayersReady = value; + UpdateText(); + } + } + void Start() { + NumPlayersReady = 4; UpdateText(); } void UpdateText() { - _numPlayersReadyText.text = _numPlayersReady + " players ready"; + _numPlayersReadyText.text = NumPlayersReady + " players ready"; } // Update is called once per frame void Update() @@ -28,7 +37,7 @@ public class Join : MonoBehaviour if (Input.GetKeyDown(key)) { keysToRemove.Add(key); - _numPlayersReady++; + NumPlayersReady++; UpdateText(); } } @@ -50,15 +59,30 @@ public class Join : MonoBehaviour StartGame(); } - if (Input.GetKeyDown(KeyCode.Alpha4)) + if (Input.GetKeyDown(KeyCode.F1)) + { + NumPlayersReady = 1; + } + + if (Input.GetKeyDown(KeyCode.F2)) + { + NumPlayersReady = 2; + } + + if (Input.GetKeyDown(KeyCode.F3)) + { + NumPlayersReady = 3; + } + + if (Input.GetKeyDown(KeyCode.F4)) { - _numPlayersReady = 4; + NumPlayersReady = 4; } } void StartGame() { - GameManager.Instance.NumPlayers = _numPlayersReady; + GameManager.Instance.NumPlayers = NumPlayersReady; SceneManager.LoadScene("TopicSelect"); } } diff --git a/namedropper/Assets/Scenes/Title.unity b/namedropper/Assets/Scenes/Title.unity index 49991c6..b41d090 100644 --- a/namedropper/Assets/Scenes/Title.unity +++ b/namedropper/Assets/Scenes/Title.unity @@ -291,7 +291,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: 0 players ready + m_text: 4 players ready m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 4fe6d5308385b4341885d0d510c8e2aa, type: 2} m_sharedMaterial: {fileID: 1001970574707011636, guid: 4fe6d5308385b4341885d0d510c8e2aa, type: 2} @@ -833,8 +833,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: "\nPress Start to join\n\nPress 1 to start Co-op mode\n or 2 to start - VS. mode" + m_text: "\nPress 1 to start Co-op mode\n or 2 to start VS. mode" m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 4fe6d5308385b4341885d0d510c8e2aa, type: 2} m_sharedMaterial: {fileID: 1001970574707011636, guid: 4fe6d5308385b4341885d0d510c8e2aa, type: 2} diff --git a/namedropper/Assets/Scripts/TopicSelect.cs b/namedropper/Assets/Scripts/TopicSelect.cs index 26596be..c531a6d 100644 --- a/namedropper/Assets/Scripts/TopicSelect.cs +++ b/namedropper/Assets/Scripts/TopicSelect.cs @@ -94,6 +94,18 @@ public class TopicSelect : MonoBehaviour // Update is called once per frame void Update() { + if (Input.GetKeyDown(KeyCode.Alpha1)) + { + PickTopic(_topic1Box); + } + else if (Input.GetKeyDown(KeyCode.Alpha2)) + { + PickTopic(_topic2Box); + } + else if (Input.GetKeyDown(KeyCode.Alpha3)) + { + PickTopic(_topic3Box); + } } @@ -143,6 +155,11 @@ public class TopicSelect : MonoBehaviour void Results() { TopicBox topicBox = _picks[Random.Range(0, _picks.Count)]; + PickTopic(topicBox); + } + + public static void PickTopic(TopicBox topicBox) + { GameDataManager.Instance.CurrentTopic = topicBox.TopicData; SceneManager.LoadScene("Game"); } diff --git a/namedropper/Assets/TrackballInputManager.cs b/namedropper/Assets/TrackballInputManager.cs index 96e8025..eb64f80 100644 --- a/namedropper/Assets/TrackballInputManager.cs +++ b/namedropper/Assets/TrackballInputManager.cs @@ -8,10 +8,10 @@ using UnityEngine.UI; public class TrackballInputManager : MonoBehaviour { - const float defaultMiceSensitivity = 2f; + const float defaultMiceSensitivity = 1.5f; const float upMultiplier = .5f; - const float accelerationThreshold = 40; - const float accelerationMultiplier = 2; + const float accelerationThreshold = 120; + const float accelerationMultiplier = .75f; [DllImport("LibRawInput")] private static extern bool init(); @@ -65,7 +65,25 @@ public class TrackballInputManager : MonoBehaviour Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; + //josh's desktop devices _ignoredDevices.Add(4468289); + + //josh's laptop devices + _ignoredDevices.Add(75111393); + _ignoredDevices.Add(1265500329); + _ignoredDevices.Add(579863325); + _ignoredDevices.Add(1384081); + _ignoredDevices.Add(188554181); + _ignoredDevices.Add(1331371593); + _ignoredDevices.Add(1834746285); + _ignoredDevices.Add(170921507); + _ignoredDevices.Add(381291525); + _ignoredDevices.Add(254348147); + _ignoredDevices.Add(254282139); + + + + } public void OnDestroy() @@ -109,8 +127,16 @@ public class TrackballInputManager : MonoBehaviour { float dx = ev.x * defaultMiceSensitivity; float dy = ev.y * defaultMiceSensitivity; - if (Mathf.Abs(dx) > accelerationThreshold) dx *= accelerationMultiplier; - if (Mathf.Abs(dy) > accelerationThreshold) dy *= accelerationMultiplier; + if (Mathf.Abs(dx) > accelerationThreshold) + { + print("hit acceleration threshold x"); + dx *= accelerationMultiplier; + } + if (Mathf.Abs(dy) > accelerationThreshold) + { + print("hit acceleration threshold y"); + dy *= accelerationMultiplier; + } if (dy < 0) dy *= upMultiplier;