5757using UnityEngine . XR ;
5858using Valve . Newtonsoft . Json ;
5959using Valve . VR ;
60+ using WebSocketSharp ;
6061using static iiMenu . Utilities . AssetUtilities ;
6162using static iiMenu . Utilities . FileUtilities ;
6263using static iiMenu . Utilities . RandomUtilities ;
@@ -193,12 +194,25 @@ public static void OnLaunch()
193194 {
194195 Settings . LoadPreferences ( ) ;
195196 }
196- catch
197+ catch ( Exception exc )
197198 {
199+ LogManager . LogError (
200+ $ "Error with Settings.LoadPreferences() at { exc . StackTrace } : { exc . Message } ") ;
201+
198202 CoroutineManager . instance . StartCoroutine ( DelayLoadPreferences ( ) ) ;
199203 }
200204 }
201205
206+ try
207+ {
208+ Settings . LoadPCControls ( ) ;
209+ }
210+ catch ( Exception exc )
211+ {
212+ LogManager . LogError (
213+ $ "Error with Settings.LoadPCControls() at { exc . StackTrace } : { exc . Message } ") ;
214+ }
215+
202216 if ( new DirectoryInfo ( Path . Combine ( GetGamePath ( ) , PluginInfo . ClientResourcePath ) ) . CreationTime >= DateTime . Now . AddYears ( 1 ) )
203217 AchievementManager . UnlockAchievement ( new AchievementManager . Achievement
204218 {
@@ -217,19 +231,19 @@ public static void Prefix()
217231 #region Controls
218232 try
219233 {
220- rightPrimary = ControllerInputPoller . instance . rightControllerPrimaryButton || UnityInput . Current . GetKey ( KeyCode . E ) ;
221- rightSecondary = ControllerInputPoller . instance . rightControllerSecondaryButton || UnityInput . Current . GetKey ( KeyCode . R ) ;
222- leftPrimary = ControllerInputPoller . instance . leftControllerPrimaryButton || UnityInput . Current . GetKey ( KeyCode . F ) ;
223- leftSecondary = ControllerInputPoller . instance . leftControllerSecondaryButton || UnityInput . Current . GetKey ( KeyCode . G ) ;
224- leftGrab = ControllerInputPoller . instance . leftGrab || UnityInput . Current . GetKey ( KeyCode . LeftBracket ) ;
225- rightGrab = ControllerInputPoller . instance . rightGrab || UnityInput . Current . GetKey ( KeyCode . RightBracket ) ;
234+ rightPrimary = ControllerInputPoller . instance . rightControllerPrimaryButton || UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . RightPrimaryButton ] ) ;
235+ rightSecondary = ControllerInputPoller . instance . rightControllerSecondaryButton || UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . RightSecondaryButton ] ) ;
236+ leftPrimary = ControllerInputPoller . instance . leftControllerPrimaryButton || UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . LeftPrimaryButton ] ) ;
237+ leftSecondary = ControllerInputPoller . instance . leftControllerSecondaryButton || UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . LeftSecondaryButton ] ) ;
238+ leftGrab = ControllerInputPoller . instance . leftGrab || UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . LeftGrip ] ) ;
239+ rightGrab = ControllerInputPoller . instance . rightGrab || UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . RightGrip ] ) ;
226240 leftTrigger = ControllerInputPoller . TriggerFloat ( XRNode . LeftHand ) ;
227241 rightTrigger = ControllerInputPoller . TriggerFloat ( XRNode . RightHand ) ;
228242
229- if ( UnityInput . Current . GetKey ( KeyCode . Minus ) )
243+ if ( UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . LeftTrigger ] ) )
230244 leftTrigger = 1f ;
231245
232- if ( UnityInput . Current . GetKey ( KeyCode . Equals ) )
246+ if ( UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . RightTrigger ] ) )
233247 rightTrigger = 1f ;
234248
235249 if ( IsSteam )
@@ -250,18 +264,20 @@ public static void Prefix()
250264 }
251265
252266 bool arrowKeysPressed = UnityInput . Current . GetKey ( KeyCode . UpArrow ) || UnityInput . Current . GetKey ( KeyCode . DownArrow ) || UnityInput . Current . GetKey ( KeyCode . LeftArrow ) || UnityInput . Current . GetKey ( KeyCode . RightArrow ) ;
267+ bool leftOverride = UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . LeftOverride ] ) ;
268+
253269 if ( arrowKeysPressed )
254270 {
255271 Vector2 direction = new Vector2 ( ( UnityInput . Current . GetKey ( KeyCode . RightArrow ) ? 1f : 0f ) + ( UnityInput . Current . GetKey ( KeyCode . LeftArrow ) ? - 1f : 0f ) , ( UnityInput . Current . GetKey ( KeyCode . UpArrow ) ? 1f : 0f ) + ( UnityInput . Current . GetKey ( KeyCode . DownArrow ) ? - 1f : 0f ) ) ;
256- if ( UnityInput . Current . GetKey ( KeyCode . LeftAlt ) )
272+ if ( leftOverride )
257273 rightJoystick = direction ;
258274 else
259275 leftJoystick = direction ;
260276 }
261277
262- if ( UnityInput . Current . GetKey ( KeyCode . Return ) )
278+ if ( UnityInput . Current . GetKey ( Settings . pcBindings [ Settings . ControllerBinding . JoystickClick ] ) )
263279 {
264- if ( UnityInput . Current . GetKey ( KeyCode . LeftAlt ) )
280+ if ( leftOverride )
265281 rightJoystickClick = true ;
266282 else
267283 leftJoystickClick = true ;
@@ -290,14 +306,7 @@ public static void Prefix()
290306 }
291307 }
292308
293- shouldBePC = UnityInput . Current . GetKey ( KeyCode . E )
294- || UnityInput . Current . GetKey ( KeyCode . R )
295- || UnityInput . Current . GetKey ( KeyCode . F )
296- || UnityInput . Current . GetKey ( KeyCode . G )
297- || UnityInput . Current . GetKey ( KeyCode . LeftBracket )
298- || UnityInput . Current . GetKey ( KeyCode . RightBracket )
299- || UnityInput . Current . GetKey ( KeyCode . Minus )
300- || UnityInput . Current . GetKey ( KeyCode . Equals )
309+ shouldBePC = Settings . pcBindings . Values . Any ( key => UnityInput . Current . GetKey ( key ) )
301310 || Mouse . current . leftButton . isPressed
302311 || Mouse . current . rightButton . isPressed
303312 || arrowKeysPressed ;
0 commit comments