Skip to content

Commit

Permalink
PTT: added menu, new apps and improved controls
Browse files Browse the repository at this point in the history
  • Loading branch information
hryamzik committed Nov 28, 2023
1 parent b654b5a commit 34610b4
Show file tree
Hide file tree
Showing 23 changed files with 1,014 additions and 320 deletions.
Binary file added base_pack/hid_app/assets/BrokenButton_15x15.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 base_pack/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 base_pack/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 base_pack/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.
Binary file added base_pack/hid_app/assets/Help_exit_64x9.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 base_pack/hid_app/assets/Help_top_64x17.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 base_pack/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 base_pack/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.
Binary file removed base_pack/hid_app/assets/Mic_btn_8x10.png
Binary file not shown.
Binary file added base_pack/hid_app/assets/MicrophoneCrossed_16x16.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 base_pack/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.
29 changes: 20 additions & 9 deletions base_pack/hid_app/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enum HidDebugSubmenuIndex {
HidSubmenuIndexMouse,
HidSubmenuIndexMouseClicker,
HidSubmenuIndexMouseJiggler,
HidSubmenuIndexPtt,
HidSubmenuIndexPushToTalk,
};

static void hid_submenu_callback(void* context, uint32_t index) {
Expand Down Expand Up @@ -54,9 +54,9 @@ static void hid_submenu_callback(void* context, uint32_t index) {
} 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 Down Expand Up @@ -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 @@ -151,7 +156,7 @@ 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 Down Expand Up @@ -224,11 +229,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_set_previous_callback(hid_ptt_get_view(app->hid_ptt), hid_ptt_menu_view);
view_dispatcher_add_view(
app->view_dispatcher, HidViewPtt, hid_ptt_get_view(app->hid_ptt));
app->view_dispatcher, HidViewPushToTalk, hid_ptt_get_view(app->hid_ptt));

return app;
}
Expand Down Expand Up @@ -260,7 +269,9 @@ 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, BtHidViewTikShorts);
hid_tikshorts_free(app->hid_tikshorts);
Expand Down
4 changes: 3 additions & 1 deletion base_pack/hid_app/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "views/hid_mouse_jiggler.h"
#include "views/hid_tikshorts.h"
#include "views/hid_ptt.h"
#include "views/hid_ptt_menu.h"

#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"

Expand All @@ -52,7 +53,8 @@ struct Hid {
HidMouseClicker* hid_mouse_clicker;
HidMouseJiggler* hid_mouse_jiggler;
HidTikShorts* hid_tikshorts;
HidPtt* hid_ptt;
HidPushToTalk* hid_ptt;
HidPushToTalkMenu* hid_ptt_menu;

HidTransport transport;
uint32_t view_id;
Expand Down
Binary file modified base_pack/hid_app/hid_usb_10px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion base_pack/hid_app/views.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ typedef enum {
HidViewMouseClicker,
HidViewMouseJiggler,
BtHidViewTikShorts,
HidViewPtt,
HidViewPushToTalk,
HidViewPushToTalkMenu,
HidViewPushToTalkHelp,
} HidView;
842 changes: 538 additions & 304 deletions base_pack/hid_app/views/hid_ptt.c

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions base_pack/hid_app/views/hid_ptt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
#include <gui/view.h>

typedef struct Hid Hid;
typedef struct HidPtt HidPtt;
typedef struct HidPushToTalk HidPushToTalk;

HidPtt* hid_ptt_alloc(Hid* bt_hid);
HidPushToTalk* hid_ptt_alloc(Hid* bt_hid);

void hid_ptt_free(HidPtt* hid_ptt);
void hid_ptt_free(HidPushToTalk* hid_ptt);

View* hid_ptt_get_view(HidPtt* hid_ptt);
View* hid_ptt_get_view(HidPushToTalk* hid_ptt);

void hid_ptt_set_connected_status(HidPtt* hid_ptt, bool connected);
void hid_ptt_set_connected_status(HidPushToTalk* hid_ptt, bool connected);

enum HidPushToTalkOSes {
HidPushToTalkMacOS,
HidPushToTalkLinux,
};
Loading

0 comments on commit 34610b4

Please sign in to comment.