Эх сурвалжийг харах

[Ryujinx.SDL2.Common] Address dotnet-format issues (#5387)

* dotnet format style --severity info

Some changes were manually reverted.

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA1806 and a few CA1854 warnings

* Address most dotnet format whitespace warnings

* dotnet format whitespace after rebase
TSRBerry 2 жил өмнө
parent
commit
b29ded1d60

+ 13 - 8
src/Ryujinx.SDL2.Common/SDL2Driver.cs

@@ -19,10 +19,7 @@ namespace Ryujinx.SDL2.Common
         {
             get
             {
-                if (_instance == null)
-                {
-                    _instance = new SDL2Driver();
-                }
+                _instance ??= new SDL2Driver();
 
                 return _instance;
             }
@@ -43,7 +40,7 @@ namespace Ryujinx.SDL2.Common
 
         private readonly object _lock = new();
 
-        private SDL2Driver() {}
+        private SDL2Driver() { }
 
         private const string SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS = "SDL_JOYSTICK_HIDAPI_COMBINE_JOY_CONS";
 
@@ -80,8 +77,15 @@ namespace Ryujinx.SDL2.Common
                 }
 
                 // First ensure that we only enable joystick events (for connected/disconnected).
-                SDL_GameControllerEventState(SDL_DISABLE);
-                SDL_JoystickEventState(SDL_ENABLE);
+                if (SDL_GameControllerEventState(SDL_IGNORE) != SDL_IGNORE)
+                {
+                    Logger.Error?.PrintMsg(LogClass.Application, "Couldn't change the state of game controller events.");
+                }
+
+                if (SDL_JoystickEventState(SDL_ENABLE) < 0)
+                {
+                    Logger.Error?.PrintMsg(LogClass.Application, $"Failed to enable joystick event polling: {SDL_GetError()}");
+                }
 
                 // Disable all joysticks information, we don't need them no need to flood the event queue for that.
                 SDL_EventState(SDL_EventType.SDL_JOYAXISMOTION, SDL_DISABLE);
@@ -153,7 +157,7 @@ namespace Ryujinx.SDL2.Common
         {
             const int WaitTimeMs = 10;
 
-            using ManualResetEventSlim waitHandle = new ManualResetEventSlim(false);
+            using ManualResetEventSlim waitHandle = new(false);
 
             while (_isRunning)
             {
@@ -199,6 +203,7 @@ namespace Ryujinx.SDL2.Common
 
         public void Dispose()
         {
+            GC.SuppressFinalize(this);
             Dispose(true);
         }
     }