فهرست منبع

move type to virtual portal

Sanjay Govind 11 ماه پیش
والد
کامیت
588c324028
5فایلهای تغییر یافته به همراه17 افزوده شده و 13 حذف شده
  1. 4 4
      portal_of_flipper_i.c
  2. 0 6
      portal_of_flipper_i.h
  3. 2 2
      scenes/pof_scene_type_select.c
  4. 5 1
      virtual_portal.c
  5. 6 0
      virtual_portal.h

+ 4 - 4
portal_of_flipper_i.c

@@ -7,10 +7,10 @@
 void pof_start(PoFApp* app) {
 void pof_start(PoFApp* app) {
     furi_assert(app);
     furi_assert(app);
 
 
-    if (app->type == PoFHid) {
+    if (app->virtual_portal->type == PoFHid) {
         app->pof_usb = pof_usb_start(app->virtual_portal);
         app->pof_usb = pof_usb_start(app->virtual_portal);
     }
     }
-    if (app->type == PoFXbox360) {
+    if (app->virtual_portal->type == PoFXbox360) {
         app->pof_usb = pof_usb_start_xbox360(app->virtual_portal);
         app->pof_usb = pof_usb_start_xbox360(app->virtual_portal);
     }
     }
 }
 }
@@ -18,10 +18,10 @@ void pof_start(PoFApp* app) {
 void pof_stop(PoFApp* app) {
 void pof_stop(PoFApp* app) {
     furi_assert(app);
     furi_assert(app);
 
 
-    if (app->type == PoFHid) {
+    if (app->virtual_portal->type == PoFHid) {
         pof_usb_stop(app->pof_usb);
         pof_usb_stop(app->pof_usb);
     }
     }
-    if (app->type == PoFXbox360) {
+    if (app->virtual_portal->type == PoFXbox360) {
         pof_usb_stop_xbox360(app->pof_usb);
         pof_usb_stop_xbox360(app->pof_usb);
     }
     }
 }
 }

+ 0 - 6
portal_of_flipper_i.h

@@ -19,11 +19,6 @@
 
 
 typedef struct PoFApp PoFApp;
 typedef struct PoFApp PoFApp;
 
 
-typedef enum {
-    PoFHid,
-    PoFXbox360
-} PoFType;
-
 struct PoFApp {
 struct PoFApp {
     Gui* gui;
     Gui* gui;
     ViewDispatcher* view_dispatcher;
     ViewDispatcher* view_dispatcher;
@@ -37,7 +32,6 @@ struct PoFApp {
     VirtualPortal* virtual_portal;
     VirtualPortal* virtual_portal;
 
 
     PoFUsb* pof_usb;
     PoFUsb* pof_usb;
-    PoFType type;
     
     
 };
 };
 
 

+ 2 - 2
scenes/pof_scene_type_select.c

@@ -36,12 +36,12 @@ bool pof_scene_type_select_on_event(void* context, SceneManagerEvent event) {
     PoFApp* pof = context;
     PoFApp* pof = context;
     if(event.type == SceneManagerEventTypeCustom) {
     if(event.type == SceneManagerEventTypeCustom) {
         if (event.event == SubmenuIndexSwapHid) {
         if (event.event == SubmenuIndexSwapHid) {
-            pof->type = PoFHid;
+            pof->virtual_portal->type = PoFHid;
             pof_start(pof);
             pof_start(pof);
             scene_manager_next_scene(pof->scene_manager, PoFSceneMain);
             scene_manager_next_scene(pof->scene_manager, PoFSceneMain);
             return true;
             return true;
         } else if (event.event == SubmenuIndexSwapXbox360) {
         } else if (event.event == SubmenuIndexSwapXbox360) {
-            pof->type = PoFXbox360;
+            pof->virtual_portal->type = PoFXbox360;
             pof_start(pof);
             pof_start(pof);
             scene_manager_next_scene(pof->scene_manager, PoFSceneMain);
             scene_manager_next_scene(pof->scene_manager, PoFSceneMain);
             return true;
             return true;

+ 5 - 1
virtual_portal.c

@@ -124,7 +124,11 @@ int virtual_portal_reset(VirtualPortal* virtual_portal, uint8_t* message, uint8_
     uint8_t index = 0;
     uint8_t index = 0;
     response[index++] = 'R';
     response[index++] = 'R';
     response[index++] = 0x02;
     response[index++] = 0x02;
-    response[index++] = 0x19;
+    if (virtual_portal->type == PoFHid) {
+        response[index++] = 0x19;
+    } else {
+        response[index++] = 0x1B;
+    }
     //response[index++] = 0x0a;
     //response[index++] = 0x0a;
     //response[index++] = 0x03;
     //response[index++] = 0x03;
     //response[index++] = 0x02;
     //response[index++] = 0x02;

+ 6 - 0
virtual_portal.h

@@ -6,12 +6,18 @@
 
 
 #define POF_TOKEN_LIMIT 16
 #define POF_TOKEN_LIMIT 16
 
 
+typedef enum {
+    PoFHid,
+    PoFXbox360
+} PoFType;
+
 typedef struct {
 typedef struct {
     PoFToken* tokens[POF_TOKEN_LIMIT];
     PoFToken* tokens[POF_TOKEN_LIMIT];
     uint8_t sequence_number;
     uint8_t sequence_number;
     bool active;
     bool active;
     bool speaker;
     bool speaker;
     NotificationApp* notifications;
     NotificationApp* notifications;
+    PoFType type;
 } VirtualPortal;
 } VirtualPortal;
 
 
 VirtualPortal* virtual_portal_alloc(NotificationApp* notifications);
 VirtualPortal* virtual_portal_alloc(NotificationApp* notifications);