Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Sync system apps --nobuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Dec 8, 2023
1 parent 76534b0 commit efbcdc2
Show file tree
Hide file tree
Showing 38 changed files with 1,491 additions and 414 deletions.
5 changes: 2 additions & 3 deletions applications/system/hex_viewer/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ App(
"dialogs",
],
stack_size=2 * 1024,
order=20,
fap_icon="icons/hex_10px.png",
fap_icon="icons/hex_10px.bmp",
fap_icon_assets="icons",
fap_category="Tools",
fap_author="@QtRoS",
fap_version="2.0",
fap_description="App allows to view various files as HEX.",
fap_description="App allows to view various files as HEX",
)
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool hex_viewer_open_file(void* context, const char* file_path) {
// TODO Separate function?
if(hex_viewer->model->stream) {
buffered_file_stream_close(hex_viewer->model->stream);
stream_free(hex_viewer->model->stream); // TODO Check
stream_free(hex_viewer->model->stream);
hex_viewer->model->file_offset = 0;
}

Expand Down
5 changes: 4 additions & 1 deletion applications/system/hex_viewer/hex_viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ HexViewer* hex_viewer_app_alloc() {
void hex_viewer_app_free(HexViewer* app) {
furi_assert(app);

if(app->model->stream) buffered_file_stream_close(app->model->stream);
if(app->model->stream) {
buffered_file_stream_close(app->model->stream);
stream_free(app->model->stream);
}

// Scene manager
scene_manager_free(app->scene_manager);
Expand Down
1 change: 0 additions & 1 deletion applications/system/hex_viewer/hex_viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ typedef struct {
Stream* stream;
} HexViewerModel;

// TODO Clean
typedef struct {
HexViewerModel* model;

Expand Down
Binary file added applications/system/hex_viewer/icons/hex_10px.bmp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void hex_viewer_scene_scroll_on_enter(void* context) {

TextInput* text_input = app->text_input;

text_input_set_header_text(text_input, "Scroll to percent (0..100)");
text_input_set_header_text(text_input, "Scroll to percentage (0..100)");
text_input_set_result_callback(
text_input,
hex_viewer_scene_scroll_callback,
Expand Down
13 changes: 8 additions & 5 deletions applications/system/hex_viewer/views/hex_viewer_startscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
width,
0,
ROW_HEIGHT * HEX_VIEWER_LINES_ON_SCREEN,
first_line_on_screen, // TODO
first_line_on_screen,
line_count - (HEX_VIEWER_LINES_ON_SCREEN - 1));
}

char temp_buf[32];
uint32_t row_iters = model->file_read_bytes / HEX_VIEWER_BYTES_PER_LINE;
if(model->file_read_bytes % HEX_VIEWER_BYTES_PER_LINE != 0) row_iters += 1;

// For the rest of drawing.
canvas_set_font(canvas, FontKeyboard);

for(uint32_t i = 0; i < row_iters; ++i) {
uint32_t bytes_left_per_row = model->file_read_bytes - i * HEX_VIEWER_BYTES_PER_LINE;
bytes_left_per_row = MIN(bytes_left_per_row, HEX_VIEWER_BYTES_PER_LINE);
Expand All @@ -79,21 +82,21 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
for(uint32_t j = 0; j < bytes_left_per_row; ++j)
if(!isprint((int)temp_buf[j])) temp_buf[j] = '.';

canvas_set_font(canvas, FontKeyboard);
//canvas_set_font(canvas, FontKeyboard);
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
} else {
uint32_t addr = model->file_offset + i * HEX_VIEWER_BYTES_PER_LINE;
snprintf(temp_buf, 32, "%04lX", addr);

canvas_set_font(canvas, FontKeyboard);
//canvas_set_font(canvas, FontKeyboard);
canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
}

char* p = temp_buf;
for(uint32_t j = 0; j < bytes_left_per_row; ++j)
p += snprintf(p, 32, "%02X ", model->file_bytes[i][j]);

canvas_set_font(canvas, FontKeyboard);
//canvas_set_font(canvas, FontKeyboard);
canvas_draw_str(canvas, LEFT_OFFSET + 41, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
}

Expand Down Expand Up @@ -125,7 +128,7 @@ bool hex_viewer_startscreen_input(InputEvent* event, void* context) {
furi_assert(context);
HexViewerStartscreen* instance = context;
HexViewer* app = instance->context; // TO so good, but works
// TODO InputTypeShort?

if(event->type == InputTypeRelease || event->type == InputTypeRepeat) {
switch(event->key) {
case InputKeyBack:
Expand Down
4 changes: 0 additions & 4 deletions applications/system/hid_app/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ App(
apptype=FlipperAppType.EXTERNAL,
entry_point="hid_usb_app",
stack_size=1 * 1024,
fap_description="Use Flipper as a HID remote control over USB",
fap_version="1.0",
fap_category="USB",
fap_icon="hid_usb_10px.png",
fap_icon_assets="assets",
Expand All @@ -19,8 +17,6 @@ App(
apptype=FlipperAppType.EXTERNAL,
entry_point="hid_ble_app",
stack_size=1 * 1024,
fap_description="Use Flipper as a HID remote control over Bluetooth",
fap_version="1.0",
fap_category="Bluetooth",
fap_icon="hid_ble_10px.png",
fap_icon_assets="assets",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/BtnBackV_9x9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/BtnLeft_9x9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/Hand_8x10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/Hold_15x5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/Mic_7x11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/system/hid_app/assets/for_help_27x5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 37 additions & 22 deletions applications/system/hid_app/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ enum HidDebugSubmenuIndex {
HidSubmenuIndexNumpad,
HidSubmenuIndexMedia,
HidSubmenuIndexMovie,
HidSubmenuIndexTikTok,
HidSubmenuIndexTikShorts,
HidSubmenuIndexMouse,
HidSubmenuIndexMouseClicker,
HidSubmenuIndexMouseJiggler,
HidSubmenuIndexPtt,
HidSubmenuIndexPushToTalk,
};

static void hid_submenu_callback(void* context, uint32_t index) {
Expand Down Expand Up @@ -45,18 +45,18 @@ static void hid_submenu_callback(void* context, uint32_t index) {
} else if(index == HidSubmenuIndexMouse) {
app->view_id = HidViewMouse;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouse);
} else if(index == HidSubmenuIndexTikTok) {
app->view_id = BtHidViewTikTok;
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewTikTok);
} else if(index == HidSubmenuIndexTikShorts) {
app->view_id = BtHidViewTikShorts;
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewTikShorts);
} else if(index == HidSubmenuIndexMouseClicker) {
app->view_id = HidViewMouseClicker;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseClicker);
} else if(index == HidSubmenuIndexMouseJiggler) {
app->view_id = HidViewMouseJiggler;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseJiggler);
} else if(index == HidSubmenuIndexPtt) {
app->view_id = HidViewPtt;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewPtt);
} else if(index == HidSubmenuIndexPushToTalk) {
app->view_id = HidViewPushToTalkMenu;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewPushToTalkMenu);
}
}

Expand All @@ -80,7 +80,7 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con
hid_mouse_clicker_set_connected_status(hid->hid_mouse_clicker, connected);
hid_mouse_jiggler_set_connected_status(hid->hid_mouse_jiggler, connected);
hid_ptt_set_connected_status(hid->hid_ptt, connected);
hid_tiktok_set_connected_status(hid->hid_tiktok, connected);
hid_tikshorts_set_connected_status(hid->hid_tikshorts, connected);
}

static uint32_t hid_menu_view(void* context) {
Expand All @@ -93,6 +93,11 @@ static uint32_t hid_exit(void* context) {
return VIEW_NONE;
}

static uint32_t hid_ptt_menu_view(void* context) {
UNUSED(context);
return HidViewPushToTalkMenu;
}

Hid* hid_alloc(HidTransport transport) {
Hid* app = malloc(sizeof(Hid));
app->transport = transport;
Expand Down Expand Up @@ -134,7 +139,7 @@ Hid* hid_alloc(HidTransport transport) {
submenu_add_item(
app->device_type_submenu,
"TikTok / YT Shorts",
HidSubmenuIndexTikTok,
HidSubmenuIndexTikShorts,
hid_submenu_callback,
app);
}
Expand All @@ -151,7 +156,11 @@ Hid* hid_alloc(HidTransport transport) {
hid_submenu_callback,
app);
submenu_add_item(
app->device_type_submenu, "PTT", HidSubmenuIndexPtt, hid_submenu_callback, app);
app->device_type_submenu,
"PushToTalk",
HidSubmenuIndexPushToTalk,
hid_submenu_callback,
app);
view_set_previous_callback(submenu_get_view(app->device_type_submenu), hid_exit);
view_dispatcher_add_view(
app->view_dispatcher, HidViewSubmenu, submenu_get_view(app->device_type_submenu));
Expand All @@ -163,7 +172,6 @@ Hid* hid_alloc(HidTransport transport) {
Hid* hid_app_alloc_view(void* context) {
furi_assert(context);
Hid* app = context;
// Dialog view

// Keynote view
app->hid_keynote = hid_keynote_alloc(app);
Expand Down Expand Up @@ -195,11 +203,11 @@ Hid* hid_app_alloc_view(void* context) {
view_dispatcher_add_view(
app->view_dispatcher, HidViewMovie, hid_movie_get_view(app->hid_movie));

// TikTok view
app->hid_tiktok = hid_tiktok_alloc(app);
view_set_previous_callback(hid_tiktok_get_view(app->hid_tiktok), hid_menu_view);
// TikTok / YT Shorts view
app->hid_tikshorts = hid_tikshorts_alloc(app);
view_set_previous_callback(hid_tikshorts_get_view(app->hid_tikshorts), hid_menu_view);
view_dispatcher_add_view(
app->view_dispatcher, BtHidViewTikTok, hid_tiktok_get_view(app->hid_tiktok));
app->view_dispatcher, BtHidViewTikShorts, hid_tikshorts_get_view(app->hid_tikshorts));

// Mouse view
app->hid_mouse = hid_mouse_alloc(app);
Expand All @@ -223,10 +231,15 @@ Hid* hid_app_alloc_view(void* context) {
HidViewMouseJiggler,
hid_mouse_jiggler_get_view(app->hid_mouse_jiggler));

// Ptt view
// PushToTalk view
app->hid_ptt_menu = hid_ptt_menu_alloc(app);
view_set_previous_callback(hid_ptt_menu_get_view(app->hid_ptt_menu), hid_menu_view);
view_dispatcher_add_view(
app->view_dispatcher, HidViewPushToTalkMenu, hid_ptt_menu_get_view(app->hid_ptt_menu));
app->hid_ptt = hid_ptt_alloc(app);
view_set_previous_callback(hid_ptt_get_view(app->hid_ptt), hid_menu_view);
view_dispatcher_add_view(app->view_dispatcher, HidViewPtt, hid_ptt_get_view(app->hid_ptt));
view_set_previous_callback(hid_ptt_get_view(app->hid_ptt), hid_ptt_menu_view);
view_dispatcher_add_view(
app->view_dispatcher, HidViewPushToTalk, hid_ptt_get_view(app->hid_ptt));

return app;
}
Expand Down Expand Up @@ -258,10 +271,12 @@ void hid_free(Hid* app) {
hid_mouse_clicker_free(app->hid_mouse_clicker);
view_dispatcher_remove_view(app->view_dispatcher, HidViewMouseJiggler);
hid_mouse_jiggler_free(app->hid_mouse_jiggler);
view_dispatcher_remove_view(app->view_dispatcher, HidViewPtt);
view_dispatcher_remove_view(app->view_dispatcher, HidViewPushToTalkMenu);
hid_ptt_menu_free(app->hid_ptt_menu);
view_dispatcher_remove_view(app->view_dispatcher, HidViewPushToTalk);
hid_ptt_free(app->hid_ptt);
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewTikTok);
hid_tiktok_free(app->hid_tiktok);
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewTikShorts);
hid_tikshorts_free(app->hid_tikshorts);
view_dispatcher_free(app->view_dispatcher);

// Close records
Expand Down
8 changes: 5 additions & 3 deletions applications/system/hid_app/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include "views/hid_mouse.h"
#include "views/hid_mouse_clicker.h"
#include "views/hid_mouse_jiggler.h"
#include "views/hid_tiktok.h"
#include "views/hid_tikshorts.h"
#include "views/hid_ptt.h"
#include "views/hid_ptt_menu.h"

#include <assets_icons.h>

Expand All @@ -51,8 +52,9 @@ struct Hid {
HidMouse* hid_mouse;
HidMouseClicker* hid_mouse_clicker;
HidMouseJiggler* hid_mouse_jiggler;
HidTikTok* hid_tiktok;
HidPtt* hid_ptt;
HidTikShorts* hid_tikshorts;
HidPushToTalk* hid_ptt;
HidPushToTalkMenu* hid_ptt_menu;

HidTransport transport;
uint32_t view_id;
Expand Down
6 changes: 4 additions & 2 deletions applications/system/hid_app/views.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ typedef enum {
HidViewMouse,
HidViewMouseClicker,
HidViewMouseJiggler,
BtHidViewTikTok,
HidViewPtt,
BtHidViewTikShorts,
HidViewPushToTalk,
HidViewPushToTalkMenu,
HidViewPushToTalkHelp,
} HidView;
13 changes: 8 additions & 5 deletions applications/system/hid_app/views/hid_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,15 @@ static bool hid_media_input_callback(InputEvent* event, void* context) {
HidMedia* hid_media = context;
bool consumed = false;

if(event->type == InputTypePress) {
hid_media_process_press(hid_media, event);
consumed = true;
} else if(event->type == InputTypeRelease) {
hid_media_process_release(hid_media, event);
if(event->type == InputTypeLong && event->key == InputKeyBack) {
hid_hal_keyboard_release_all(hid_media->hid);
} else {
consumed = true;
if(event->type == InputTypePress) {
hid_media_process_press(hid_media, event);
} else if(event->type == InputTypeRelease) {
hid_media_process_release(hid_media, event);
}
}
return consumed;
}
Expand Down
16 changes: 11 additions & 5 deletions applications/system/hid_app/views/hid_movie.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,19 @@ static bool hid_movie_input_callback(InputEvent* event, void* context) {
HidMovie* hid_movie = context;
bool consumed = false;

if(event->type == InputTypePress) {
hid_movie_process_press(hid_movie, event);
consumed = true;
} else if(event->type == InputTypeRelease) {
hid_movie_process_release(hid_movie, event);
if(event->type == InputTypeLong && event->key == InputKeyBack) {
hid_hal_keyboard_release_all(hid_movie->hid);
} else {
consumed = true;
if(event->type == InputTypePress) {
hid_movie_process_press(hid_movie, event);
consumed = true;
} else if(event->type == InputTypeRelease) {
hid_movie_process_release(hid_movie, event);
consumed = true;
}
}

return consumed;
}

Expand Down
Loading

0 comments on commit efbcdc2

Please sign in to comment.