Просмотр исходного кода

Separated navigation and control pages

Sandro Kalatozishvili 2 лет назад
Родитель
Сommit
b529ce9281

+ 12 - 0
.vscode/settings.json

@@ -0,0 +1,12 @@
+{
+    "files.associations": {
+        "xremote_control.h": "c",
+        "xremote_learn.h": "c",
+        "xremote_settings.h": "c",
+        "xremote_common_view.h": "c",
+        "xremote_app.h": "c",
+        "xremote_saved_view.h": "c",
+        "infrared_remote.h": "c",
+        "xremote_navigation_view.h": "c"
+    }
+}

+ 1 - 1
views/xremote_about_view.c

@@ -21,7 +21,7 @@ static void xremote_about_view_draw_callback(Canvas* canvas, void* context)
     canvas_draw_str_aligned(canvas, 0, 30, AlignLeft, AlignTop, "Version:");
     canvas_draw_str_aligned(canvas, 0, 30, AlignLeft, AlignTop, "Version:");
     canvas_draw_str_aligned(canvas, 35, 30, AlignLeft, AlignTop, version);
     canvas_draw_str_aligned(canvas, 35, 30, AlignLeft, AlignTop, version);
 
 
-    canvas_draw_str_aligned(canvas, 0, 40, AlignLeft, AlignTop, "License: MIT");
+    canvas_draw_str_aligned(canvas, 0, 40, AlignLeft, AlignTop, "License: GPLv3");
     canvas_draw_str_aligned(canvas, 0, 50, AlignLeft, AlignTop, "Author: kala13x");
     canvas_draw_str_aligned(canvas, 0, 50, AlignLeft, AlignTop, "Author: kala13x");
 
 
     canvas_draw_str_aligned(canvas, 0, 69, AlignLeft, AlignTop, "Contact:");
     canvas_draw_str_aligned(canvas, 0, 69, AlignLeft, AlignTop, "Contact:");

+ 1 - 0
views/xremote_common_view.h

@@ -86,6 +86,7 @@ typedef enum {
     XRemoteViewIRSubmenu,
     XRemoteViewIRSubmenu,
     XRemoteViewIRGeneral,
     XRemoteViewIRGeneral,
     XRemoteViewIRControl,
     XRemoteViewIRControl,
+    XRemoteViewIRNavigation,
     XRemoteViewIRPlayer,
     XRemoteViewIRPlayer,
     XRemoteViewIRCustom
     XRemoteViewIRCustom
 } XRemoteViewID;
 } XRemoteViewID;

+ 7 - 78
views/xremote_control_view.c

@@ -3,93 +3,22 @@
     @license This project is released under the GNU GPLv3 License
     @license This project is released under the GNU GPLv3 License
  *  @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  *  @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  *
  *
- * @brief Control page view callbacks and infrared functionality.
+ * @brief UI and view functionality for the IR control page.
  */
  */
 
 
 #include "xremote_control_view.h"
 #include "xremote_control_view.h"
 
 
 static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
 static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
 {
 {
-    furi_assert(context);
-    XRemoteViewModel* model = context;
-
-    xremote_canvas_draw_header(canvas, "Controller");
-    xremote_canvas_draw_button(canvas, model->up_pressed, 23, 30, XRemoteIconArrowUp);
-    xremote_canvas_draw_button(canvas, model->down_pressed, 23, 72, XRemoteIconArrowDown);
-    xremote_canvas_draw_button(canvas, model->left_pressed, 2, 51, XRemoteIconArrowLeft);
-    xremote_canvas_draw_button(canvas, model->right_pressed, 44, 51, XRemoteIconArrowRight);
-    xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconOk);
-    xremote_canvas_draw_button_wide(canvas, model->back_pressed, 0, 95, "BACK", &I_Back_icon_10x8);
-    xremote_canvas_draw_exit_footer(canvas, "Hold to exit");
-}
-
-static void xremote_control_view_process(XRemoteView* view, InputEvent* event)
-{
-    with_view_model(
-        xremote_view_get_view(view),
-        XRemoteViewModel* model,
-        {
-            if (event->type == InputTypePress)
-            {
-                if (event->key == InputKeyUp)
-                {
-                    model->up_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_UP);
-                }
-                else if (event->key == InputKeyDown)
-                {
-                    model->down_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_DOWN);
-                }
-                else if (event->key == InputKeyLeft)
-                {
-                    model->left_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_LEFT);
-                }
-                else if (event->key == InputKeyRight)
-                {
-                    model->right_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_RIGHT);
-                }
-                else if (event->key == InputKeyOk)
-                {
-                    model->ok_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_OK);
-                }
-                else if (event->key == InputKeyBack)
-                {
-                    model->back_pressed = true;
-                    xremote_view_send_ir(view, XREMOTE_COMMAND_BACK);
-                }
-            }
-            else if (event->type == InputTypeRelease)
-            {
-                if (event->key == InputKeyUp) model->up_pressed = false;
-                else if (event->key == InputKeyDown) model->down_pressed = false;
-                else if (event->key == InputKeyLeft) model->left_pressed = false;
-                else if (event->key == InputKeyRight) model->right_pressed = false;
-                else if (event->key == InputKeyOk) model->ok_pressed = false;
-                else if (event->key == InputKeyBack) model->back_pressed = false;
-            }
-        },
-        true);
-}
-
-static bool xremote_control_view_input_callback(InputEvent* event, void* context)
-{
-    furi_assert(context);
-    XRemoteView* view = (XRemoteView*)context;
-
-    if (event->type == InputTypeLong &&
-        event->key == InputKeyBack) return false;
-
-    xremote_control_view_process(view, event);
-    return true;
+    (void)context;
+    xremote_canvas_draw_header(canvas, "Control");
+    canvas_set_font(canvas, FontSecondary);
+    canvas_draw_str(canvas, 0, 70, "Coming Soon");
+    xremote_canvas_draw_exit_footer(canvas, "Press to exit");
 }
 }
 
 
 XRemoteView* xremote_control_view_alloc(NotificationApp* notifications)
 XRemoteView* xremote_control_view_alloc(NotificationApp* notifications)
 {
 {
     return xremote_view_alloc(notifications,
     return xremote_view_alloc(notifications,
-        xremote_control_view_input_callback,
-        xremote_control_view_draw_callback);
+        NULL, xremote_control_view_draw_callback);
 }
 }

+ 2 - 2
views/xremote_control_view.h

@@ -1,9 +1,9 @@
 /*!
 /*!
- *  @file flipper-xremote/views/xremote_control_view.h
+ *  @file flipper-xremote/views/xremote_navigation_view.h
     @license This project is released under the GNU GPLv3 License
     @license This project is released under the GNU GPLv3 License
  *  @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  *  @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  *
  *
- * @brief Control page view callbacks and infrared functionality.
+ * @brief UI and view functionality for the IR control page.
  */
  */
 
 
 #pragma once
 #pragma once

+ 95 - 0
views/xremote_navigation_view.c

@@ -0,0 +1,95 @@
+/*!
+ *  @file flipper-xremote/views/xremote_navigation_view.c
+    @license This project is released under the GNU GPLv3 License
+ *  @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
+ *
+ * @brief Navigation page view callbacks and infrared functionality.
+ */
+
+#include "xremote_navigation_view.h"
+
+static void xremote_navigation_view_draw_callback(Canvas* canvas, void* context)
+{
+    furi_assert(context);
+    XRemoteViewModel* model = context;
+
+    xremote_canvas_draw_header(canvas, "Navigation");
+    xremote_canvas_draw_button(canvas, model->up_pressed, 23, 30, XRemoteIconArrowUp);
+    xremote_canvas_draw_button(canvas, model->down_pressed, 23, 72, XRemoteIconArrowDown);
+    xremote_canvas_draw_button(canvas, model->left_pressed, 2, 51, XRemoteIconArrowLeft);
+    xremote_canvas_draw_button(canvas, model->right_pressed, 44, 51, XRemoteIconArrowRight);
+    xremote_canvas_draw_button(canvas, model->ok_pressed, 23, 51, XRemoteIconOk);
+    xremote_canvas_draw_button_wide(canvas, model->back_pressed, 0, 95, "BACK", &I_Back_icon_10x8);
+    xremote_canvas_draw_exit_footer(canvas, "Hold to exit");
+}
+
+static void xremote_navigation_view_process(XRemoteView* view, InputEvent* event)
+{
+    with_view_model(
+        xremote_view_get_view(view),
+        XRemoteViewModel* model,
+        {
+            if (event->type == InputTypePress)
+            {
+                if (event->key == InputKeyUp)
+                {
+                    model->up_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_UP);
+                }
+                else if (event->key == InputKeyDown)
+                {
+                    model->down_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_DOWN);
+                }
+                else if (event->key == InputKeyLeft)
+                {
+                    model->left_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_LEFT);
+                }
+                else if (event->key == InputKeyRight)
+                {
+                    model->right_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_RIGHT);
+                }
+                else if (event->key == InputKeyOk)
+                {
+                    model->ok_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_OK);
+                }
+                else if (event->key == InputKeyBack)
+                {
+                    model->back_pressed = true;
+                    xremote_view_send_ir(view, XREMOTE_COMMAND_BACK);
+                }
+            }
+            else if (event->type == InputTypeRelease)
+            {
+                if (event->key == InputKeyUp) model->up_pressed = false;
+                else if (event->key == InputKeyDown) model->down_pressed = false;
+                else if (event->key == InputKeyLeft) model->left_pressed = false;
+                else if (event->key == InputKeyRight) model->right_pressed = false;
+                else if (event->key == InputKeyOk) model->ok_pressed = false;
+                else if (event->key == InputKeyBack) model->back_pressed = false;
+            }
+        },
+        true);
+}
+
+static bool xremote_navigation_view_input_callback(InputEvent* event, void* context)
+{
+    furi_assert(context);
+    XRemoteView* view = (XRemoteView*)context;
+
+    if (event->type == InputTypeLong &&
+        event->key == InputKeyBack) return false;
+
+    xremote_navigation_view_process(view, event);
+    return true;
+}
+
+XRemoteView* xremote_navigation_view_alloc(NotificationApp* notifications)
+{
+    return xremote_view_alloc(notifications,
+        xremote_navigation_view_input_callback,
+        xremote_navigation_view_draw_callback);
+}

+ 13 - 0
views/xremote_navigation_view.h

@@ -0,0 +1,13 @@
+/*!
+ *  @file flipper-xremote/views/xremote_navigation_view.h
+    @license This project is released under the GNU GPLv3 License
+ *  @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
+ *
+ * @brief Navigation page view callbacks and infrared functionality.
+ */
+
+#pragma once
+
+#include "xremote_common_view.h"
+
+XRemoteView* xremote_navigation_view_alloc(NotificationApp* notifications);

+ 1 - 1
xremote.h

@@ -10,6 +10,6 @@
 
 
 #define XREMOTE_VERSION_MAJOR  0
 #define XREMOTE_VERSION_MAJOR  0
 #define XREMOTE_VERSION_MINOR  9
 #define XREMOTE_VERSION_MINOR  9
-#define XREMOTE_BUILD_NUMBER   13
+#define XREMOTE_BUILD_NUMBER   14
 
 
 void xremote_get_version(char *version, size_t length);
 void xremote_get_version(char *version, size_t length);

+ 0 - 1
xremote_app.c

@@ -67,7 +67,6 @@ void xremote_app_view_free(XRemoteApp* app)
     }
     }
 }
 }
 
 
-
 bool xremote_app_has_view(XRemoteApp *app, uint32_t view_id)
 bool xremote_app_has_view(XRemoteApp *app, uint32_t view_id)
 {
 {
     xremote_app_assert(app, false);
     xremote_app_assert(app, false);

+ 6 - 2
xremote_control.c

@@ -10,6 +10,7 @@
 
 
 #include "views/xremote_general_view.h"
 #include "views/xremote_general_view.h"
 #include "views/xremote_control_view.h"
 #include "views/xremote_control_view.h"
+#include "views/xremote_navigation_view.h"
 #include "views/xremote_player_view.h"
 #include "views/xremote_player_view.h"
 #include "views/xremote_custom_view.h"
 #include "views/xremote_custom_view.h"
 
 
@@ -24,7 +25,7 @@ static uint32_t xremote_control_submenu_exit_callback(void* context)
     return XRemoteViewSubmenu;
     return XRemoteViewSubmenu;
 }
 }
 
 
-static uint32_t xremote_control_view_exit_callback(void* context)
+static uint32_t xremote_navigation_view_exit_callback(void* context)
 {
 {
     UNUSED(context);
     UNUSED(context);
     return XRemoteViewIRSubmenu;
     return XRemoteViewIRSubmenu;
@@ -46,6 +47,8 @@ static void xremote_control_submenu_callback(void* context, uint32_t index)
         xremote_app_view_alloc(app, index, xremote_general_view_alloc);
         xremote_app_view_alloc(app, index, xremote_general_view_alloc);
     else if (index == XRemoteViewIRControl)
     else if (index == XRemoteViewIRControl)
         xremote_app_view_alloc(app, index, xremote_control_view_alloc);
         xremote_app_view_alloc(app, index, xremote_control_view_alloc);
+    else if (index == XRemoteViewIRNavigation)
+        xremote_app_view_alloc(app, index, xremote_navigation_view_alloc);
     else if (index == XRemoteViewIRPlayer)
     else if (index == XRemoteViewIRPlayer)
         xremote_app_view_alloc(app, index, xremote_player_view_alloc);
         xremote_app_view_alloc(app, index, xremote_player_view_alloc);
     else if (index == XRemoteViewIRCustom)
     else if (index == XRemoteViewIRCustom)
@@ -53,7 +56,7 @@ static void xremote_control_submenu_callback(void* context, uint32_t index)
 
 
     if (app->view_ctx != NULL)
     if (app->view_ctx != NULL)
     {
     {
-        xremote_app_view_set_previous_callback(app, xremote_control_view_exit_callback);
+        xremote_app_view_set_previous_callback(app, xremote_navigation_view_exit_callback);
         xremote_app_set_view_context(app, app->context, NULL);
         xremote_app_set_view_context(app, app->context, NULL);
         xremote_app_switch_to_view(app, index);
         xremote_app_switch_to_view(app, index);
     }
     }
@@ -111,6 +114,7 @@ XRemoteApp* xremote_control_alloc(XRemoteAppContext* app_ctx)
     xremote_app_submenu_alloc(app, XRemoteViewIRSubmenu, xremote_control_submenu_exit_callback);
     xremote_app_submenu_alloc(app, XRemoteViewIRSubmenu, xremote_control_submenu_exit_callback);
     xremote_app_submenu_add(app, "General", XRemoteViewIRGeneral, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "General", XRemoteViewIRGeneral, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "Control", XRemoteViewIRControl, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "Control", XRemoteViewIRControl, xremote_control_submenu_callback);
+    xremote_app_submenu_add(app, "Navigation", XRemoteViewIRNavigation, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "Playback", XRemoteViewIRPlayer, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "Playback", XRemoteViewIRPlayer, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "Custom", XRemoteViewIRCustom, xremote_control_submenu_callback);
     xremote_app_submenu_add(app, "Custom", XRemoteViewIRCustom, xremote_control_submenu_callback);
     xremote_app_set_user_context(app, remote, xremote_ir_clear_callback);
     xremote_app_set_user_context(app, remote, xremote_ir_clear_callback);