SDL: Improve SDL2 main, adding memory card and usb drivers

From a054a5f7f2dde31431cf890e421886faacdf5f54 Mon Sep 17 00:00:00 2001
From: Francisco Javier Trujillo Mata <[EMAIL REDACTED]>
Date: Wed, 29 Jun 2022 01:09:17 +0200
Subject: [PATCH] Improve SDL2 main, adding memory card and usb drivers

---
 src/main/ps2/SDL_ps2_main.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/main/ps2/SDL_ps2_main.c b/src/main/ps2/SDL_ps2_main.c
index 60b1fbd0a06..1bc8154b38b 100644
--- a/src/main/ps2/SDL_ps2_main.c
+++ b/src/main/ps2/SDL_ps2_main.c
@@ -12,6 +12,8 @@
 #include <sifrpc.h>
 #include <iopcontrol.h>
 #include <sbv_patches.h>
+#include <ps2_fileXio_driver.h>
+#include <ps2_memcard_driver.h>
 
 #ifdef main
     #undef main
@@ -24,11 +26,27 @@ static void prepare_IOP()
    sbv_patch_disable_prefix_check();
 }
 
+static void init_drivers() {
+    init_fileXio_driver();
+    init_memcard_driver(true);
+}
+
+static void deinit_drivers() {
+    deinit_memcard_driver(true);
+    deinit_fileXio_driver();
+}
+
 int main(int argc, char *argv[])
 {
+    int res;
     prepare_IOP();
+    init_drivers();
+
+    res = SDL_main(argc, argv);
 
-    return SDL_main(argc, argv);
+    deinit_drivers();    
+    
+    return res;
 }
 
 #endif /* _EE */