mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 06:54:19 +00:00
Merge pull request #753 from Willy-JL/hid-app-merge-fix
Hid app merge fix
This commit is contained in:
commit
e4ed15ba23
20 changed files with 273 additions and 202 deletions
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
BIN
applications/system/hid_app/assets/DolphinDone_80x58.png
Normal file
BIN
applications/system/hid_app/assets/DolphinDone_80x58.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB |
|
@ -4,27 +4,9 @@
|
|||
#include "views.h"
|
||||
#include <notification/notification_messages.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include "hid_icons.h"
|
||||
|
||||
#define TAG "HidApp"
|
||||
|
||||
enum HidDebugSubmenuIndex {
|
||||
HidSubmenuIndexKeynote,
|
||||
HidSubmenuIndexKeynoteVertical,
|
||||
HidSubmenuIndexKeyboard,
|
||||
HidSubmenuIndexNumpad,
|
||||
HidSubmenuIndexMedia,
|
||||
HidSubmenuIndexMusicMacOs,
|
||||
HidSubmenuIndexMovie,
|
||||
HidSubmenuIndexTikTok,
|
||||
HidSubmenuIndexMouse,
|
||||
HidSubmenuIndexMouseClicker,
|
||||
HidSubmenuIndexMouseJiggler,
|
||||
HidSubmenuIndexMouseJigglerStealth,
|
||||
HidSubmenuIndexPushToTalk,
|
||||
HidSubmenuIndexRemovePairing,
|
||||
};
|
||||
|
||||
bool hid_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
|
@ -34,9 +16,7 @@ bool hid_custom_event_callback(void* context, uint32_t event) {
|
|||
bool hid_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
FURI_LOG_D("HID", "Back event");
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewSubmenu);
|
||||
return true;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
void bt_hid_remove_pairing(Hid* app) {
|
||||
|
@ -53,53 +33,12 @@ void bt_hid_remove_pairing(Hid* app) {
|
|||
furi_hal_bt_start_advertising();
|
||||
}
|
||||
|
||||
static void hid_submenu_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
if(index == HidSubmenuIndexKeynote) {
|
||||
hid_keynote_set_orientation(app->hid_keynote, false);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewKeynote);
|
||||
} else if(index == HidSubmenuIndexKeynoteVertical) {
|
||||
hid_keynote_set_orientation(app->hid_keynote, true);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewKeynote);
|
||||
} else if(index == HidSubmenuIndexKeyboard) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewKeyboard);
|
||||
} else if(index == HidSubmenuIndexNumpad) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewNumpad);
|
||||
} else if(index == HidSubmenuIndexMedia) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMedia);
|
||||
} else if(index == HidSubmenuIndexMusicMacOs) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMusicMacOs);
|
||||
} else if(index == HidSubmenuIndexMovie) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMovie);
|
||||
} else if(index == HidSubmenuIndexMouse) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouse);
|
||||
} else if(index == HidSubmenuIndexTikTok) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewTikTok);
|
||||
} else if(index == HidSubmenuIndexMouseClicker) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseClicker);
|
||||
} else if(index == HidSubmenuIndexMouseJiggler) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseJiggler);
|
||||
} else if(index == HidSubmenuIndexMouseJigglerStealth) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseJigglerStealth);
|
||||
} else if(index == HidSubmenuIndexPushToTalk) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewPushToTalkMenu);
|
||||
} else if(index == HidSubmenuIndexRemovePairing) {
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneUnpair);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_hid_connection_status_changed_callback(BtStatus status, void* context) {
|
||||
furi_assert(context);
|
||||
Hid* hid = context;
|
||||
bool connected = (status == BtStatusConnected);
|
||||
#ifdef HID_TRANSPORT_BLE
|
||||
if(connected) {
|
||||
notification_internal_message(hid->notifications, &sequence_set_blue_255);
|
||||
} else {
|
||||
notification_internal_message(hid->notifications, &sequence_reset_blue);
|
||||
}
|
||||
#endif
|
||||
const bool connected = (status == BtStatusConnected);
|
||||
notification_internal_message(
|
||||
hid->notifications, connected ? &sequence_set_blue_255 : &sequence_reset_blue);
|
||||
hid_keynote_set_connected_status(hid->hid_keynote, connected);
|
||||
hid_keyboard_set_connected_status(hid->hid_keyboard, connected);
|
||||
hid_numpad_set_connected_status(hid->hid_numpad, connected);
|
||||
|
@ -114,17 +53,12 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con
|
|||
hid_tiktok_set_connected_status(hid->hid_tiktok, connected);
|
||||
}
|
||||
|
||||
static uint32_t hid_exit(void* context) {
|
||||
UNUSED(context);
|
||||
return VIEW_NONE;
|
||||
}
|
||||
|
||||
static uint32_t hid_ptt_menu_view(void* context) {
|
||||
UNUSED(context);
|
||||
return HidViewPushToTalkMenu;
|
||||
}
|
||||
|
||||
Hid* hid_alloc(void) {
|
||||
Hid* hid_alloc() {
|
||||
Hid* app = malloc(sizeof(Hid));
|
||||
|
||||
// Gui
|
||||
|
@ -139,55 +73,18 @@ Hid* hid_alloc(void) {
|
|||
// View dispatcher
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, hid_back_event_callback);
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
view_dispatcher_set_custom_event_callback(app->view_dispatcher, hid_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, hid_back_event_callback);
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
// Scene Manager
|
||||
app->scene_manager = scene_manager_alloc(&hid_scene_handlers, app);
|
||||
|
||||
// Device Type Submenu view
|
||||
app->submenu = submenu_alloc();
|
||||
submenu_add_item(app->submenu, "Keynote", HidSubmenuIndexKeynote, hid_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Keynote Vertical",
|
||||
HidSubmenuIndexKeynoteVertical,
|
||||
hid_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(app->submenu, "Keyboard", HidSubmenuIndexKeyboard, hid_submenu_callback, app);
|
||||
submenu_add_item(app->submenu, "Numpad", HidSubmenuIndexNumpad, hid_submenu_callback, app);
|
||||
submenu_add_item(app->submenu, "Media", HidSubmenuIndexMedia, hid_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Apple Music macOS", HidSubmenuIndexMusicMacOs, hid_submenu_callback, app);
|
||||
submenu_add_item(app->submenu, "Movie", HidSubmenuIndexMovie, hid_submenu_callback, app);
|
||||
submenu_add_item(app->submenu, "Mouse", HidSubmenuIndexMouse, hid_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "TikTok / YT Shorts", HidSubmenuIndexTikTok, hid_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Mouse Clicker", HidSubmenuIndexMouseClicker, hid_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Mouse Jiggler", HidSubmenuIndexMouseJiggler, hid_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Mouse Jiggler Stealth",
|
||||
HidSubmenuIndexMouseJigglerStealth,
|
||||
hid_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu, "PushToTalk", HidSubmenuIndexPushToTalk, hid_submenu_callback, app);
|
||||
#ifdef HID_TRANSPORT_BLE
|
||||
submenu_add_item(
|
||||
app->submenu, "Remove Pairing", HidSubmenuIndexRemovePairing, hid_submenu_callback, app);
|
||||
#endif
|
||||
view_set_previous_callback(submenu_get_view(app->submenu), hid_exit);
|
||||
view_dispatcher_add_view(app->view_dispatcher, HidViewSubmenu, submenu_get_view(app->submenu));
|
||||
return app;
|
||||
}
|
||||
|
||||
Hid* hid_app_alloc_view(void* context) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
view_dispatcher_add_view(app->view_dispatcher, HidViewSubmenu, submenu_get_view(app->submenu));
|
||||
|
||||
// Dialog view
|
||||
app->dialog = dialog_ex_alloc();
|
||||
|
@ -327,18 +224,16 @@ void hid_free(Hid* app) {
|
|||
int32_t hid_usb_app(void* p) {
|
||||
UNUSED(p);
|
||||
Hid* app = hid_alloc();
|
||||
app = hid_app_alloc_view(app);
|
||||
|
||||
FURI_LOG_D("HID", "Starting as USB app");
|
||||
|
||||
FuriHalUsbInterface* usb_mode_prev = furi_hal_usb_get_config();
|
||||
furi_hal_usb_unlock();
|
||||
furi_check(furi_hal_usb_set_config(&usb_hid, NULL) == true);
|
||||
|
||||
bt_hid_connection_status_changed_callback(BtStatusConnected, app);
|
||||
|
||||
dolphin_deed(DolphinDeedPluginStart);
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneMain);
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneStart);
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
|
@ -352,7 +247,6 @@ int32_t hid_usb_app(void* p) {
|
|||
int32_t hid_ble_app(void* p) {
|
||||
UNUSED(p);
|
||||
Hid* app = hid_alloc();
|
||||
app = hid_app_alloc_view(app);
|
||||
|
||||
FURI_LOG_D("HID", "Starting as BLE app");
|
||||
|
||||
|
@ -382,7 +276,7 @@ int32_t hid_ble_app(void* p) {
|
|||
|
||||
dolphin_deed(DolphinDeedPluginStart);
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneMain);
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneStart);
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ struct Hid {
|
|||
HidPushToTalk* hid_ptt;
|
||||
HidPushToTalkMenu* hid_ptt_menu;
|
||||
};
|
||||
|
||||
void bt_hid_remove_pairing(Hid* app);
|
||||
|
||||
void hid_hal_keyboard_press(Hid* instance, uint16_t event);
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
ADD_SCENE(hid, start, Start)
|
||||
ADD_SCENE(hid, main, Main)
|
||||
ADD_SCENE(hid, unpair, Unpair)
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
void hid_scene_main_on_enter(void* context) {
|
||||
Hid* app = context;
|
||||
|
||||
view_dispatcher_switch_to_view(
|
||||
app->view_dispatcher, scene_manager_get_scene_state(app->scene_manager, HidSceneMain));
|
||||
}
|
||||
|
|
167
applications/system/hid_app/scenes/hid_scene_start.c
Normal file
167
applications/system/hid_app/scenes/hid_scene_start.c
Normal file
|
@ -0,0 +1,167 @@
|
|||
#include "../hid.h"
|
||||
#include "../views.h"
|
||||
|
||||
enum HidSubmenuIndex {
|
||||
HidSubmenuIndexKeynote,
|
||||
HidSubmenuIndexKeynoteVertical,
|
||||
HidSubmenuIndexKeyboard,
|
||||
HidSubmenuIndexNumpad,
|
||||
HidSubmenuIndexMedia,
|
||||
HidSubmenuIndexMusicMacOs,
|
||||
HidSubmenuIndexMovie,
|
||||
HidSubmenuIndexTikTok,
|
||||
HidSubmenuIndexMouse,
|
||||
HidSubmenuIndexMouseClicker,
|
||||
HidSubmenuIndexMouseJiggler,
|
||||
HidSubmenuIndexMouseJigglerStealth,
|
||||
HidSubmenuIndexPushToTalk,
|
||||
HidSubmenuIndexRemovePairing,
|
||||
};
|
||||
|
||||
static void hid_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void hid_scene_start_on_enter(void* context) {
|
||||
Hid* app = context;
|
||||
submenu_add_item(
|
||||
app->submenu, "Keynote", HidSubmenuIndexKeynote, hid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Keynote Vertical",
|
||||
HidSubmenuIndexKeynoteVertical,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Keyboard", HidSubmenuIndexKeyboard, hid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Numpad", HidSubmenuIndexNumpad, hid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Media", HidSubmenuIndexMedia, hid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Apple Music macOS",
|
||||
HidSubmenuIndexMusicMacOs,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Movie", HidSubmenuIndexMovie, hid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu, "Mouse", HidSubmenuIndexMouse, hid_scene_start_submenu_callback, app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"TikTok / YT Shorts",
|
||||
HidSubmenuIndexTikTok,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Mouse Clicker",
|
||||
HidSubmenuIndexMouseClicker,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Mouse Jiggler",
|
||||
HidSubmenuIndexMouseJiggler,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Mouse Jiggler Stealth",
|
||||
HidSubmenuIndexMouseJigglerStealth,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"PushToTalk",
|
||||
HidSubmenuIndexPushToTalk,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
#ifdef HID_TRANSPORT_BLE
|
||||
submenu_add_item(
|
||||
app->submenu,
|
||||
"Bluetooth Unpairing",
|
||||
HidSubmenuIndexRemovePairing,
|
||||
hid_scene_start_submenu_callback,
|
||||
app);
|
||||
#endif
|
||||
|
||||
submenu_set_selected_item(
|
||||
app->submenu, scene_manager_get_scene_state(app->scene_manager, HidSceneStart));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewSubmenu);
|
||||
}
|
||||
|
||||
bool hid_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
Hid* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == HidSubmenuIndexRemovePairing) {
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneUnpair);
|
||||
} else {
|
||||
HidView view_id;
|
||||
|
||||
switch(event.event) {
|
||||
case HidSubmenuIndexKeynote:
|
||||
view_id = HidViewKeynote;
|
||||
hid_keynote_set_orientation(app->hid_keynote, false);
|
||||
break;
|
||||
case HidSubmenuIndexKeynoteVertical:
|
||||
view_id = HidViewKeynote;
|
||||
hid_keynote_set_orientation(app->hid_keynote, true);
|
||||
break;
|
||||
case HidSubmenuIndexKeyboard:
|
||||
view_id = HidViewKeyboard;
|
||||
break;
|
||||
case HidSubmenuIndexNumpad:
|
||||
view_id = HidViewNumpad;
|
||||
break;
|
||||
case HidSubmenuIndexMedia:
|
||||
view_id = HidViewMedia;
|
||||
break;
|
||||
case HidSubmenuIndexMusicMacOs:
|
||||
view_id = HidViewMusicMacOs;
|
||||
break;
|
||||
case HidSubmenuIndexMovie:
|
||||
view_id = HidViewMovie;
|
||||
break;
|
||||
case HidSubmenuIndexTikTok:
|
||||
view_id = BtHidViewTikTok;
|
||||
break;
|
||||
case HidSubmenuIndexMouse:
|
||||
view_id = HidViewMouse;
|
||||
break;
|
||||
case HidSubmenuIndexMouseClicker:
|
||||
view_id = HidViewMouseClicker;
|
||||
break;
|
||||
case HidSubmenuIndexMouseJiggler:
|
||||
view_id = HidViewMouseJiggler;
|
||||
break;
|
||||
case HidSubmenuIndexMouseJigglerStealth:
|
||||
view_id = HidViewMouseJigglerStealth;
|
||||
break;
|
||||
case HidSubmenuIndexPushToTalk:
|
||||
view_id = HidViewPushToTalkMenu;
|
||||
break;
|
||||
default:
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
scene_manager_set_scene_state(app->scene_manager, HidSceneMain, view_id);
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneMain);
|
||||
}
|
||||
|
||||
scene_manager_set_scene_state(app->scene_manager, HidSceneStart, event.event);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void hid_scene_start_on_exit(void* context) {
|
||||
Hid* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
|
@ -36,7 +36,7 @@ void hid_scene_unpair_on_enter(void* context) {
|
|||
dialog_ex_set_right_button_text(app->dialog, "Unpair");
|
||||
|
||||
// Un-pair success popup view
|
||||
popup_set_icon(app->popup, 32, 5, &I_DolphinNice_96x59);
|
||||
popup_set_icon(app->popup, 48, 6, &I_DolphinDone_80x58);
|
||||
popup_set_header(app->popup, "Done", 14, 15, AlignLeft, AlignTop);
|
||||
popup_set_timeout(app->popup, 1500);
|
||||
popup_set_context(app->popup, app);
|
||||
|
|
|
@ -230,7 +230,7 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Header
|
||||
#ifdef HID_TRANSPORT_BLE
|
||||
if((!model->connected)) {
|
||||
if(!model->connected) {
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Keyboard");
|
||||
|
|
|
@ -273,7 +273,6 @@ HidKeynote* hid_keynote_alloc(Hid* hid) {
|
|||
view_allocate_model(hid_keynote->view, ViewModelTypeLocking, sizeof(HidKeynoteModel));
|
||||
view_set_draw_callback(hid_keynote->view, hid_keynote_draw_callback);
|
||||
view_set_input_callback(hid_keynote->view, hid_keynote_input_callback);
|
||||
|
||||
return hid_keynote;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,6 +197,7 @@ static bool hid_media_input_callback(InputEvent* event, void* context) {
|
|||
hid_media_process_release(hid_media, event);
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
@ -208,7 +209,6 @@ HidMedia* hid_media_alloc(Hid* hid) {
|
|||
view_allocate_model(hid_media->view, ViewModelTypeLocking, sizeof(HidMediaModel));
|
||||
view_set_draw_callback(hid_media->view, hid_media_draw_callback);
|
||||
view_set_input_callback(hid_media->view, hid_media_input_callback);
|
||||
|
||||
return hid_media;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <gui/view.h>
|
||||
|
||||
typedef struct Hid Hid;
|
||||
|
||||
typedef struct HidMedia HidMedia;
|
||||
|
||||
HidMedia* hid_media_alloc(Hid* hid);
|
||||
|
|
|
@ -53,9 +53,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Up
|
||||
if(model->up_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 6, &I_S_UP_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 80, 8, &I_Pin_arrow_up_7x9);
|
||||
|
@ -63,9 +63,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Down
|
||||
if(model->down_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 36, &I_S_DOWN_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 80, 40, &I_Pin_arrow_down_7x9);
|
||||
|
@ -73,9 +73,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Left
|
||||
if(model->left_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 61, 13, &I_S_LEFT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 63, 25, &I_Pin_arrow_left_9x7);
|
||||
|
@ -83,9 +83,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Right
|
||||
if(model->right_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 91, 13, &I_S_RIGHT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 95, 25, &I_Pin_arrow_right_9x7);
|
||||
|
@ -93,9 +93,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Ok
|
||||
if(model->left_mouse_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 74, 19, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 79, 24, &I_Left_mouse_icon_9x9);
|
||||
|
@ -103,9 +103,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Back
|
||||
if(model->right_mouse_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 107, 33, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 112, 38, &I_Right_mouse_icon_9x9);
|
||||
|
@ -201,6 +201,15 @@ static bool hid_mouse_input_callback(InputEvent* event, void* context) {
|
|||
|
||||
if(event->type == InputTypeLong && event->key == InputKeyBack) {
|
||||
hid_hal_mouse_release_all(hid_mouse->hid);
|
||||
|
||||
with_view_model(
|
||||
hid_mouse->view,
|
||||
HidMouseModel * model,
|
||||
{
|
||||
model->left_mouse_held = false;
|
||||
model->left_mouse_pressed = false;
|
||||
},
|
||||
false);
|
||||
} else {
|
||||
hid_mouse_process(hid_mouse, event);
|
||||
consumed = true;
|
||||
|
@ -217,7 +226,6 @@ HidMouse* hid_mouse_alloc(Hid* hid) {
|
|||
view_allocate_model(hid_mouse->view, ViewModelTypeLocking, sizeof(HidMouseModel));
|
||||
view_set_draw_callback(hid_mouse->view, hid_mouse_draw_callback);
|
||||
view_set_input_callback(hid_mouse->view, hid_mouse_input_callback);
|
||||
|
||||
return hid_mouse;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,37 +52,37 @@ static void hid_mouse_clicker_draw_callback(Canvas* canvas, void* context) {
|
|||
#endif
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text_aligned(canvas, 27, 3, AlignLeft, AlignTop, "Mouse Clicker");
|
||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse Clicker");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
|
||||
// Ok
|
||||
canvas_draw_icon(canvas, 63, 25, &I_Space_65x18);
|
||||
canvas_draw_icon(canvas, 58, 25, &I_Space_65x18);
|
||||
|
||||
if(model->running) {
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
|
||||
FuriString* rate_label = furi_string_alloc();
|
||||
furi_string_printf(rate_label, "%d clicks/s\n\nUp / Down", model->rate);
|
||||
elements_multiline_text(canvas, AlignLeft, 35, furi_string_get_cstr(rate_label));
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
furi_string_free(rate_label);
|
||||
|
||||
elements_slightly_rounded_box(canvas, 66, 27, 60, 13);
|
||||
elements_slightly_rounded_box(canvas, 61, 27, 60, 13);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
} else {
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text(canvas, AlignLeft, 35, "Press Start\nto start\nclicking");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
}
|
||||
canvas_draw_icon(canvas, 74, 29, &I_Ok_btn_9x9);
|
||||
|
||||
canvas_draw_icon(canvas, 69, 29, &I_Ok_btn_9x9);
|
||||
|
||||
if(model->running) {
|
||||
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Stop");
|
||||
elements_multiline_text_aligned(canvas, 86, 37, AlignLeft, AlignBottom, "Stop");
|
||||
} else {
|
||||
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Start");
|
||||
elements_multiline_text_aligned(canvas, 86, 37, AlignLeft, AlignBottom, "Start");
|
||||
}
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
|
||||
// Clicks/s
|
||||
char label[20];
|
||||
snprintf(label, sizeof(label), "%d clicks/s", model->rate);
|
||||
elements_multiline_text_aligned(canvas, 28, 37, AlignCenter, AlignBottom, label);
|
||||
|
||||
canvas_draw_icon(canvas, 25, 20, &I_ButtonUp_7x4);
|
||||
canvas_draw_icon(canvas, 25, 44, &I_ButtonDown_7x4);
|
||||
|
||||
// Back
|
||||
canvas_draw_icon(canvas, 74, 49, &I_Pin_back_arrow_10x8);
|
||||
elements_multiline_text_aligned(canvas, 91, 57, AlignLeft, AlignBottom, "Quit");
|
||||
canvas_draw_icon(canvas, 0, 54, &I_Pin_back_arrow_10x8);
|
||||
elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Exit");
|
||||
}
|
||||
|
||||
static void hid_mouse_clicker_timer_callback(void* context) {
|
||||
|
@ -144,6 +144,9 @@ static bool hid_mouse_clicker_input_callback(InputEvent* event, void* context) {
|
|||
rate_changed = true;
|
||||
consumed = true;
|
||||
break;
|
||||
case InputKeyBack:
|
||||
model->running = false;
|
||||
break;
|
||||
default:
|
||||
consumed = true;
|
||||
break;
|
||||
|
|
|
@ -59,9 +59,9 @@ static void hid_movie_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Up
|
||||
if(model->up_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 6, &I_S_UP_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 79, 9, &I_Volup_8x6);
|
||||
|
@ -69,9 +69,9 @@ static void hid_movie_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Down
|
||||
if(model->down_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 36, &I_S_DOWN_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 80, 41, &I_Voldwn_6x6);
|
||||
|
@ -79,9 +79,9 @@ static void hid_movie_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Left
|
||||
if(model->left_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 61, 13, &I_S_LEFT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
hid_movie_draw_arrow(canvas, 65, 28, CanvasDirectionRightToLeft);
|
||||
|
@ -90,9 +90,9 @@ static void hid_movie_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Right
|
||||
if(model->right_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 91, 13, &I_S_RIGHT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
hid_movie_draw_arrow(canvas, 96, 28, CanvasDirectionLeftToRight);
|
||||
|
@ -101,9 +101,9 @@ static void hid_movie_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Ok
|
||||
if(model->ok_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 74, 19, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
hid_movie_draw_arrow(canvas, 80, 28, CanvasDirectionLeftToRight);
|
||||
|
@ -113,9 +113,9 @@ static void hid_movie_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Exit
|
||||
if(model->back_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 107, 33, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 111, 38, &I_Pin_back_arrow_10x10);
|
||||
|
|
|
@ -59,9 +59,9 @@ static void hid_music_macos_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Up
|
||||
if(model->up_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 6, &I_S_UP_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 79, 9, &I_Volup_8x6);
|
||||
|
@ -69,9 +69,9 @@ static void hid_music_macos_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Down
|
||||
if(model->down_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 36, &I_S_DOWN_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 80, 41, &I_Voldwn_6x6);
|
||||
|
@ -79,9 +79,9 @@ static void hid_music_macos_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Left
|
||||
if(model->left_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 61, 13, &I_S_LEFT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
hid_music_macos_draw_arrow(canvas, 67, 28, CanvasDirectionRightToLeft);
|
||||
|
@ -91,9 +91,9 @@ static void hid_music_macos_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Right
|
||||
if(model->right_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 91, 13, &I_S_RIGHT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
hid_music_macos_draw_arrow(canvas, 96, 28, CanvasDirectionLeftToRight);
|
||||
|
@ -103,9 +103,9 @@ static void hid_music_macos_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Ok
|
||||
if(model->ok_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 74, 19, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
hid_music_macos_draw_arrow(canvas, 80, 28, CanvasDirectionLeftToRight);
|
||||
|
@ -115,9 +115,9 @@ static void hid_music_macos_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Exit
|
||||
if(model->back_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 107, 33, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 111, 38, &I_Pin_back_arrow_10x10);
|
||||
|
|
|
@ -45,9 +45,9 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Pause
|
||||
if(model->back_mouse_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 107, 33, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 113, 37, &I_Pause_icon_9x9);
|
||||
|
@ -55,9 +55,9 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Up
|
||||
if(model->up_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 6, &I_S_UP_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 80, 8, &I_Arr_up_7x9);
|
||||
|
@ -65,9 +65,9 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Down
|
||||
if(model->down_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 68, 36, &I_S_DOWN_31x15);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 80, 40, &I_Arr_dwn_7x9);
|
||||
|
@ -75,9 +75,9 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Left
|
||||
if(model->left_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 61, 13, &I_S_LEFT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 64, 25, &I_Voldwn_6x6);
|
||||
|
@ -85,9 +85,9 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Right
|
||||
if(model->right_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 91, 13, &I_S_RIGHT_15x31);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 95, 25, &I_Volup_8x6);
|
||||
|
@ -95,9 +95,9 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
|||
|
||||
// Ok
|
||||
if(model->ok_pressed) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_bitmap_mode(canvas, true);
|
||||
canvas_draw_icon(canvas, 74, 19, &I_Pressed_Button_19x19);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
canvas_set_bitmap_mode(canvas, false);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_icon(canvas, 78, 25, &I_Like_def_11x9);
|
||||
|
|
Loading…
Reference in a new issue