[FL-3770, FL-3680] HID App improvements and little extra (#3518)
* FL-3680: change capitalisation * Replace D-Pad graphic * Fix the bluetooth indicator not showing * Remove exit confirm scene * Fix wrong back button durations * Improve application structure * Improve mouse clicker view * Improve mouse jiggler view * Improve media view * Improve mouse and media views * Improve tiktok view * Reset mouse jiggler state on view exit * Use alpha in mouse and tiktok views * Reset mouse left button state on view exit * Improve button graphics * Improve mouse graphics Co-authored-by: あく <alleteam@gmail.com>
|
@ -12,7 +12,7 @@ void subghz_test_scene_show_only_rx_on_enter(void* context) {
|
||||||
// Setup view
|
// Setup view
|
||||||
Popup* popup = app->popup;
|
Popup* popup = app->popup;
|
||||||
|
|
||||||
const char* header_text = "Transmission is blocked";
|
const char* header_text = "Transmission is Blocked";
|
||||||
const char* message_text = "Transmission on\nthis frequency is\nrestricted in\nyour region";
|
const char* message_text = "Transmission on\nthis frequency is\nrestricted in\nyour region";
|
||||||
if(!furi_hal_region_is_provisioned()) {
|
if(!furi_hal_region_is_provisioned()) {
|
||||||
header_text = "Firmware update needed";
|
header_text = "Firmware update needed";
|
||||||
|
|
|
@ -32,7 +32,7 @@ void bad_usb_scene_error_on_enter(void* context) {
|
||||||
} else if(app->error == BadUsbAppErrorCloseRpc) {
|
} else if(app->error == BadUsbAppErrorCloseRpc) {
|
||||||
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
||||||
widget_add_string_multiline_element(
|
widget_add_string_multiline_element(
|
||||||
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nis active!");
|
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nIs Active!");
|
||||||
widget_add_string_multiline_element(
|
widget_add_string_multiline_element(
|
||||||
app->widget,
|
app->widget,
|
||||||
3,
|
3,
|
||||||
|
|
|
@ -6,7 +6,7 @@ void gpio_scene_usb_uart_close_rpc_on_enter(void* context) {
|
||||||
|
|
||||||
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
||||||
widget_add_string_multiline_element(
|
widget_add_string_multiline_element(
|
||||||
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nis active!");
|
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nIs Active!");
|
||||||
widget_add_string_multiline_element(
|
widget_add_string_multiline_element(
|
||||||
app->widget,
|
app->widget,
|
||||||
3,
|
3,
|
||||||
|
|
|
@ -6,7 +6,7 @@ void infrared_scene_learn_done_on_enter(void* context) {
|
||||||
|
|
||||||
if(infrared->app_state.is_learning_new_remote) {
|
if(infrared->app_state.is_learning_new_remote) {
|
||||||
popup_set_icon(popup, 48, 6, &I_DolphinDone_80x58);
|
popup_set_icon(popup, 48, 6, &I_DolphinDone_80x58);
|
||||||
popup_set_header(popup, "New remote\ncreated!", 0, 0, AlignLeft, AlignTop);
|
popup_set_header(popup, "Success!", 10, 12, AlignLeft, AlignTop);
|
||||||
} else {
|
} else {
|
||||||
popup_set_icon(popup, 36, 5, &I_DolphinSaved_92x58);
|
popup_set_icon(popup, 36, 5, &I_DolphinSaved_92x58);
|
||||||
popup_set_header(popup, "Saved", 15, 19, AlignLeft, AlignBottom);
|
popup_set_header(popup, "Saved", 15, 19, AlignLeft, AlignBottom);
|
||||||
|
|
|
@ -34,7 +34,7 @@ static void infrared_move_view_draw_callback(Canvas* canvas, void* _model) {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(
|
elements_multiline_text_aligned(
|
||||||
canvas, canvas_width(canvas) / 2, 0, AlignCenter, AlignTop, "Select a button to move");
|
canvas, canvas_width(canvas) / 2, 0, AlignCenter, AlignTop, "Select a Button to Move");
|
||||||
|
|
||||||
const size_t btn_number = InfraredMoveViewItemArray_size(model->labels);
|
const size_t btn_number = InfraredMoveViewItemArray_size(model->labels);
|
||||||
const bool show_scrollbar = btn_number > LIST_ITEMS;
|
const bool show_scrollbar = btn_number > LIST_ITEMS;
|
||||||
|
|
|
@ -297,7 +297,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||||
SubGhzCustomEventManagerSet) {
|
SubGhzCustomEventManagerSet) {
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
subghz->variable_item_list,
|
subghz->variable_item_list,
|
||||||
"Bin_RAW:",
|
"Bin_Raw:",
|
||||||
BIN_RAW_COUNT,
|
BIN_RAW_COUNT,
|
||||||
subghz_scene_receiver_config_set_bin_raw,
|
subghz_scene_receiver_config_set_bin_raw,
|
||||||
subghz);
|
subghz);
|
||||||
|
|
|
@ -27,7 +27,7 @@ void u2f_scene_error_on_enter(void* context) {
|
||||||
} else if(app->error == U2fAppErrorCloseRpc) {
|
} else if(app->error == U2fAppErrorCloseRpc) {
|
||||||
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
||||||
widget_add_string_multiline_element(
|
widget_add_string_multiline_element(
|
||||||
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nis active!");
|
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nIs Active!");
|
||||||
widget_add_string_multiline_element(
|
widget_add_string_multiline_element(
|
||||||
app->widget,
|
app->widget,
|
||||||
3,
|
3,
|
||||||
|
|
|
@ -116,7 +116,7 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
submenu_set_header(submenu, is_dummy_app ? ("Dummy Mode app:") : ("Favorite app:"));
|
submenu_set_header(submenu, is_dummy_app ? ("Dummy Mode App") : ("Favorite App"));
|
||||||
submenu_set_selected_item(submenu, pre_select_item); // If set during loop, visual glitch.
|
submenu_set_selected_item(submenu, pre_select_item); // If set during loop, visual glitch.
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||||
|
|
|
@ -25,7 +25,7 @@ void desktop_settings_scene_pin_disable_on_enter(void* context) {
|
||||||
popup_set_context(app->popup, app);
|
popup_set_context(app->popup, app);
|
||||||
popup_set_callback(app->popup, pin_disable_back_callback);
|
popup_set_callback(app->popup, pin_disable_back_callback);
|
||||||
popup_set_icon(app->popup, 0, 2, &I_DolphinMafia_119x62);
|
popup_set_icon(app->popup, 0, 2, &I_DolphinMafia_119x62);
|
||||||
popup_set_header(app->popup, "Deleted", 80, 19, AlignLeft, AlignBottom);
|
popup_set_header(app->popup, "PIN\nDeleted!", 100, 0, AlignCenter, AlignTop);
|
||||||
popup_set_timeout(app->popup, 1500);
|
popup_set_timeout(app->popup, 1500);
|
||||||
popup_enable_timeout(app->popup);
|
popup_enable_timeout(app->popup);
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewIdPopup);
|
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewIdPopup);
|
||||||
|
|
|
@ -22,7 +22,7 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) {
|
||||||
if(!app->settings.pin_code.length) {
|
if(!app->settings.pin_code.length) {
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
"Set Pin",
|
"Set PIN",
|
||||||
SCENE_EVENT_SET_PIN,
|
SCENE_EVENT_SET_PIN,
|
||||||
desktop_settings_scene_pin_menu_submenu_callback,
|
desktop_settings_scene_pin_menu_submenu_callback,
|
||||||
app);
|
app);
|
||||||
|
@ -30,7 +30,7 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) {
|
||||||
} else {
|
} else {
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
"Change Pin",
|
"Change PIN",
|
||||||
SCENE_EVENT_CHANGE_PIN,
|
SCENE_EVENT_CHANGE_PIN,
|
||||||
desktop_settings_scene_pin_menu_submenu_callback,
|
desktop_settings_scene_pin_menu_submenu_callback,
|
||||||
app);
|
app);
|
||||||
|
@ -43,7 +43,7 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) {
|
||||||
app);
|
app);
|
||||||
}
|
}
|
||||||
|
|
||||||
submenu_set_header(app->submenu, "Pin code settings:");
|
submenu_set_header(app->submenu, "PIN Code Settings");
|
||||||
submenu_set_selected_item(app->submenu, app->menu_idx);
|
submenu_set_selected_item(app->submenu, app->menu_idx);
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ void desktop_settings_scene_pin_setup_done_on_enter(void* context) {
|
||||||
desktop_view_pin_input_set_done_callback(app->pin_input_view, pin_setup_done_callback);
|
desktop_view_pin_input_set_done_callback(app->pin_input_view, pin_setup_done_callback);
|
||||||
desktop_view_pin_input_set_pin(app->pin_input_view, &app->settings.pin_code);
|
desktop_view_pin_input_set_pin(app->pin_input_view, &app->settings.pin_code);
|
||||||
desktop_view_pin_input_set_label_button(app->pin_input_view, "Done");
|
desktop_view_pin_input_set_label_button(app->pin_input_view, "Done");
|
||||||
desktop_view_pin_input_set_label_primary(app->pin_input_view, 29, 8, "PIN activated!");
|
desktop_view_pin_input_set_label_primary(app->pin_input_view, 29, 8, "PIN Activated!");
|
||||||
desktop_view_pin_input_set_label_secondary(
|
desktop_view_pin_input_set_label_secondary(
|
||||||
app->pin_input_view, 7, 45, "Remember or write it down");
|
app->pin_input_view, 7, 45, "Remember or write it down");
|
||||||
desktop_view_pin_input_lock_input(app->pin_input_view);
|
desktop_view_pin_input_lock_input(app->pin_input_view);
|
||||||
|
|
|
@ -23,7 +23,7 @@ static void desktop_settings_view_pin_setup_howto_draw(Canvas* canvas, void* mod
|
||||||
elements_button_right(canvas, "Next");
|
elements_button_right(canvas, "Next");
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 64, 0, AlignCenter, AlignTop, "Setting up PIN");
|
elements_multiline_text_aligned(canvas, 64, 0, AlignCenter, AlignTop, "Setting Up PIN");
|
||||||
|
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
elements_multiline_text(canvas, 58, 24, "Prepare to use\narrows as\nPIN symbols");
|
elements_multiline_text(canvas, 58, 24, "Prepare to use\narrows as\nPIN symbols");
|
||||||
|
|
|
@ -10,7 +10,7 @@ void power_settings_scene_power_off_on_enter(void* context) {
|
||||||
PowerSettingsApp* app = context;
|
PowerSettingsApp* app = context;
|
||||||
DialogEx* dialog = app->dialog;
|
DialogEx* dialog = app->dialog;
|
||||||
|
|
||||||
dialog_ex_set_header(dialog, "Turn Off Device?", 64, 2, AlignCenter, AlignTop);
|
dialog_ex_set_header(dialog, "Turn OFF Device?", 64, 2, AlignCenter, AlignTop);
|
||||||
dialog_ex_set_text(
|
dialog_ex_set_text(
|
||||||
dialog, " I will be\nwaiting for\n you here...", 78, 16, AlignLeft, AlignTop);
|
dialog, " I will be\nwaiting for\n you here...", 78, 16, AlignLeft, AlignTop);
|
||||||
dialog_ex_set_icon(dialog, 21, 13, &I_Cry_dolph_55x52);
|
dialog_ex_set_icon(dialog, 21, 13, &I_Cry_dolph_55x52);
|
||||||
|
|
|
@ -15,10 +15,10 @@ void power_settings_scene_reboot_on_enter(void* context) {
|
||||||
PowerSettingsApp* app = context;
|
PowerSettingsApp* app = context;
|
||||||
Submenu* submenu = app->submenu;
|
Submenu* submenu = app->submenu;
|
||||||
|
|
||||||
submenu_set_header(submenu, "Reboot type");
|
submenu_set_header(submenu, "Reboot Type");
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
"Firmware upgrade",
|
"Firmware Upgrade",
|
||||||
PowerSettingsRebootSubmenuIndexDfu,
|
PowerSettingsRebootSubmenuIndexDfu,
|
||||||
power_settings_scene_reboot_submenu_callback,
|
power_settings_scene_reboot_submenu_callback,
|
||||||
app);
|
app);
|
||||||
|
|
Before Width: | Height: | Size: 3.6 KiB |
BIN
applications/system/hid_app/assets/DolphinDone_80x58.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
BIN
applications/system/hid_app/assets/Dpad_49x46.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
applications/system/hid_app/assets/Left_mouse_icon_9x10.png
Normal file
After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.5 KiB |
BIN
applications/system/hid_app/assets/Like_def_13x11.png
Normal file
After Width: | Height: | Size: 600 B |
BIN
applications/system/hid_app/assets/Like_pressed_17x16.png
Normal file
After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 3.6 KiB |
BIN
applications/system/hid_app/assets/Ok_btn_pressed_13x12.png
Normal file
After Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 3.5 KiB |
BIN
applications/system/hid_app/assets/Right_mouse_icon_9x10.png
Normal file
After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 3.5 KiB |
|
@ -4,22 +4,9 @@
|
||||||
#include "views.h"
|
#include "views.h"
|
||||||
#include <notification/notification_messages.h>
|
#include <notification/notification_messages.h>
|
||||||
#include <dolphin/dolphin.h>
|
#include <dolphin/dolphin.h>
|
||||||
#include "hid_icons.h"
|
|
||||||
|
|
||||||
#define TAG "HidApp"
|
#define TAG "HidApp"
|
||||||
|
|
||||||
enum HidDebugSubmenuIndex {
|
|
||||||
HidSubmenuIndexKeynote,
|
|
||||||
HidSubmenuIndexKeynoteVertical,
|
|
||||||
HidSubmenuIndexKeyboard,
|
|
||||||
HidSubmenuIndexMedia,
|
|
||||||
HidSubmenuIndexTikTok,
|
|
||||||
HidSubmenuIndexMouse,
|
|
||||||
HidSubmenuIndexMouseClicker,
|
|
||||||
HidSubmenuIndexMouseJiggler,
|
|
||||||
HidSubmenuIndexRemovePairing,
|
|
||||||
};
|
|
||||||
|
|
||||||
bool hid_custom_event_callback(void* context, uint32_t event) {
|
bool hid_custom_event_callback(void* context, uint32_t event) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
Hid* app = context;
|
Hid* app = context;
|
||||||
|
@ -29,9 +16,7 @@ bool hid_custom_event_callback(void* context, uint32_t event) {
|
||||||
bool hid_back_event_callback(void* context) {
|
bool hid_back_event_callback(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
Hid* app = context;
|
Hid* app = context;
|
||||||
FURI_LOG_D("HID", "Back event");
|
return scene_manager_handle_back_event(app->scene_manager);
|
||||||
scene_manager_next_scene(app->scene_manager, HidSceneExitConfirm);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_hid_remove_pairing(Hid* app) {
|
void bt_hid_remove_pairing(Hid* app) {
|
||||||
|
@ -48,51 +33,12 @@ void bt_hid_remove_pairing(Hid* app) {
|
||||||
furi_hal_bt_start_advertising();
|
furi_hal_bt_start_advertising();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_submenu_callback(void* context, uint32_t index) {
|
|
||||||
furi_assert(context);
|
|
||||||
Hid* app = context;
|
|
||||||
if(index == HidSubmenuIndexKeynote) {
|
|
||||||
app->view_id = HidViewKeynote;
|
|
||||||
hid_keynote_set_orientation(app->hid_keynote, false);
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewKeynote);
|
|
||||||
} else if(index == HidSubmenuIndexKeynoteVertical) {
|
|
||||||
app->view_id = HidViewKeynote;
|
|
||||||
hid_keynote_set_orientation(app->hid_keynote, true);
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewKeynote);
|
|
||||||
} else if(index == HidSubmenuIndexKeyboard) {
|
|
||||||
app->view_id = HidViewKeyboard;
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewKeyboard);
|
|
||||||
} else if(index == HidSubmenuIndexMedia) {
|
|
||||||
app->view_id = HidViewMedia;
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMedia);
|
|
||||||
} 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 == 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 == HidSubmenuIndexRemovePairing) {
|
|
||||||
scene_manager_next_scene(app->scene_manager, HidSceneUnpair);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bt_hid_connection_status_changed_callback(BtStatus status, void* context) {
|
static void bt_hid_connection_status_changed_callback(BtStatus status, void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
Hid* hid = context;
|
Hid* hid = context;
|
||||||
bool connected = (status == BtStatusConnected);
|
const bool connected = (status == BtStatusConnected);
|
||||||
#ifdef HID_TRANSPORT_BLE
|
notification_internal_message(
|
||||||
if(connected) {
|
hid->notifications, connected ? &sequence_set_blue_255 : &sequence_reset_blue);
|
||||||
notification_internal_message(hid->notifications, &sequence_set_blue_255);
|
|
||||||
} else {
|
|
||||||
notification_internal_message(hid->notifications, &sequence_reset_blue);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
hid_keynote_set_connected_status(hid->hid_keynote, connected);
|
hid_keynote_set_connected_status(hid->hid_keynote, connected);
|
||||||
hid_keyboard_set_connected_status(hid->hid_keyboard, connected);
|
hid_keyboard_set_connected_status(hid->hid_keyboard, connected);
|
||||||
hid_media_set_connected_status(hid->hid_media, connected);
|
hid_media_set_connected_status(hid->hid_media, connected);
|
||||||
|
@ -102,12 +48,7 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con
|
||||||
hid_tiktok_set_connected_status(hid->hid_tiktok, connected);
|
hid_tiktok_set_connected_status(hid->hid_tiktok, connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t hid_exit(void* context) {
|
Hid* hid_alloc() {
|
||||||
UNUSED(context);
|
|
||||||
return VIEW_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Hid* hid_alloc(void) {
|
|
||||||
Hid* app = malloc(sizeof(Hid));
|
Hid* app = malloc(sizeof(Hid));
|
||||||
|
|
||||||
// Gui
|
// Gui
|
||||||
|
@ -122,67 +63,18 @@ Hid* hid_alloc(void) {
|
||||||
// View dispatcher
|
// View dispatcher
|
||||||
app->view_dispatcher = view_dispatcher_alloc();
|
app->view_dispatcher = view_dispatcher_alloc();
|
||||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
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_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
|
// Scene Manager
|
||||||
app->scene_manager = scene_manager_alloc(&hid_scene_handlers, app);
|
app->scene_manager = scene_manager_alloc(&hid_scene_handlers, app);
|
||||||
|
|
||||||
// Device Type Submenu view
|
// Device Type Submenu view
|
||||||
app->device_type_submenu = submenu_alloc();
|
app->submenu = submenu_alloc();
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu, "Keynote", HidSubmenuIndexKeynote, hid_submenu_callback, app);
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu,
|
|
||||||
"Keynote Vertical",
|
|
||||||
HidSubmenuIndexKeynoteVertical,
|
|
||||||
hid_submenu_callback,
|
|
||||||
app);
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu, "Keyboard", HidSubmenuIndexKeyboard, hid_submenu_callback, app);
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu, "Media", HidSubmenuIndexMedia, hid_submenu_callback, app);
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu, "Mouse", HidSubmenuIndexMouse, hid_submenu_callback, app);
|
|
||||||
#ifdef HID_TRANSPORT_BLE
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu,
|
|
||||||
"TikTok Controller",
|
|
||||||
HidSubmenuIndexTikTok,
|
|
||||||
hid_submenu_callback,
|
|
||||||
app);
|
|
||||||
#endif
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu,
|
|
||||||
"Mouse Clicker",
|
|
||||||
HidSubmenuIndexMouseClicker,
|
|
||||||
hid_submenu_callback,
|
|
||||||
app);
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu,
|
|
||||||
"Mouse Jiggler",
|
|
||||||
HidSubmenuIndexMouseJiggler,
|
|
||||||
hid_submenu_callback,
|
|
||||||
app);
|
|
||||||
#ifdef HID_TRANSPORT_BLE
|
|
||||||
submenu_add_item(
|
|
||||||
app->device_type_submenu,
|
|
||||||
"Remove Pairing",
|
|
||||||
HidSubmenuIndexRemovePairing,
|
|
||||||
hid_submenu_callback,
|
|
||||||
app);
|
|
||||||
#endif
|
|
||||||
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));
|
|
||||||
app->view_id = HidViewSubmenu;
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
Hid* hid_app_alloc_view(void* context) {
|
view_dispatcher_add_view(app->view_dispatcher, HidViewSubmenu, submenu_get_view(app->submenu));
|
||||||
furi_assert(context);
|
|
||||||
Hid* app = context;
|
|
||||||
|
|
||||||
// Dialog view
|
// Dialog view
|
||||||
app->dialog = dialog_ex_alloc();
|
app->dialog = dialog_ex_alloc();
|
||||||
|
@ -243,7 +135,7 @@ void hid_free(Hid* app) {
|
||||||
#endif
|
#endif
|
||||||
// Free views
|
// Free views
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewSubmenu);
|
view_dispatcher_remove_view(app->view_dispatcher, HidViewSubmenu);
|
||||||
submenu_free(app->device_type_submenu);
|
submenu_free(app->submenu);
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewDialog);
|
view_dispatcher_remove_view(app->view_dispatcher, HidViewDialog);
|
||||||
dialog_ex_free(app->dialog);
|
dialog_ex_free(app->dialog);
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewPopup);
|
view_dispatcher_remove_view(app->view_dispatcher, HidViewPopup);
|
||||||
|
@ -280,18 +172,16 @@ void hid_free(Hid* app) {
|
||||||
int32_t hid_usb_app(void* p) {
|
int32_t hid_usb_app(void* p) {
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
Hid* app = hid_alloc();
|
Hid* app = hid_alloc();
|
||||||
app = hid_app_alloc_view(app);
|
|
||||||
FURI_LOG_D("HID", "Starting as USB app");
|
FURI_LOG_D("HID", "Starting as USB app");
|
||||||
|
|
||||||
FuriHalUsbInterface* usb_mode_prev = furi_hal_usb_get_config();
|
FuriHalUsbInterface* usb_mode_prev = furi_hal_usb_get_config();
|
||||||
furi_hal_usb_unlock();
|
furi_hal_usb_unlock();
|
||||||
furi_check(furi_hal_usb_set_config(&usb_hid, NULL) == true);
|
furi_check(furi_hal_usb_set_config(&usb_hid, NULL) == true);
|
||||||
|
|
||||||
bt_hid_connection_status_changed_callback(BtStatusConnected, app);
|
|
||||||
|
|
||||||
dolphin_deed(DolphinDeedPluginStart);
|
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);
|
view_dispatcher_run(app->view_dispatcher);
|
||||||
|
|
||||||
|
@ -305,7 +195,6 @@ int32_t hid_usb_app(void* p) {
|
||||||
int32_t hid_ble_app(void* p) {
|
int32_t hid_ble_app(void* p) {
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
Hid* app = hid_alloc();
|
Hid* app = hid_alloc();
|
||||||
app = hid_app_alloc_view(app);
|
|
||||||
|
|
||||||
FURI_LOG_D("HID", "Starting as BLE app");
|
FURI_LOG_D("HID", "Starting as BLE app");
|
||||||
|
|
||||||
|
@ -335,7 +224,7 @@ int32_t hid_ble_app(void* p) {
|
||||||
|
|
||||||
dolphin_deed(DolphinDeedPluginStart);
|
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);
|
view_dispatcher_run(app->view_dispatcher);
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,6 @@
|
||||||
|
|
||||||
#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"
|
#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
HidTransportUsb,
|
|
||||||
HidTransportBle,
|
|
||||||
} HidTransport;
|
|
||||||
|
|
||||||
typedef struct Hid Hid;
|
typedef struct Hid Hid;
|
||||||
|
|
||||||
struct Hid {
|
struct Hid {
|
||||||
|
@ -44,7 +39,7 @@ struct Hid {
|
||||||
NotificationApp* notifications;
|
NotificationApp* notifications;
|
||||||
ViewDispatcher* view_dispatcher;
|
ViewDispatcher* view_dispatcher;
|
||||||
SceneManager* scene_manager;
|
SceneManager* scene_manager;
|
||||||
Submenu* device_type_submenu;
|
Submenu* submenu;
|
||||||
DialogEx* dialog;
|
DialogEx* dialog;
|
||||||
Popup* popup;
|
Popup* popup;
|
||||||
HidKeynote* hid_keynote;
|
HidKeynote* hid_keynote;
|
||||||
|
@ -54,10 +49,8 @@ struct Hid {
|
||||||
HidMouseClicker* hid_mouse_clicker;
|
HidMouseClicker* hid_mouse_clicker;
|
||||||
HidMouseJiggler* hid_mouse_jiggler;
|
HidMouseJiggler* hid_mouse_jiggler;
|
||||||
HidTikTok* hid_tiktok;
|
HidTikTok* hid_tiktok;
|
||||||
|
|
||||||
HidTransport transport;
|
|
||||||
uint32_t view_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void bt_hid_remove_pairing(Hid* app);
|
void bt_hid_remove_pairing(Hid* app);
|
||||||
|
|
||||||
void hid_hal_keyboard_press(Hid* instance, uint16_t event);
|
void hid_hal_keyboard_press(Hid* instance, uint16_t event);
|
||||||
|
@ -72,4 +65,4 @@ void hid_hal_mouse_move(Hid* instance, int8_t dx, int8_t dy);
|
||||||
void hid_hal_mouse_scroll(Hid* instance, int8_t delta);
|
void hid_hal_mouse_scroll(Hid* instance, int8_t delta);
|
||||||
void hid_hal_mouse_press(Hid* instance, uint16_t event);
|
void hid_hal_mouse_press(Hid* instance, uint16_t event);
|
||||||
void hid_hal_mouse_release(Hid* instance, uint16_t event);
|
void hid_hal_mouse_release(Hid* instance, uint16_t event);
|
||||||
void hid_hal_mouse_release_all(Hid* instance);
|
void hid_hal_mouse_release_all(Hid* instance);
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
|
ADD_SCENE(hid, start, Start)
|
||||||
ADD_SCENE(hid, main, Main)
|
ADD_SCENE(hid, main, Main)
|
||||||
ADD_SCENE(hid, unpair, Unpair)
|
ADD_SCENE(hid, unpair, Unpair)
|
||||||
ADD_SCENE(hid, exit_confirm, ExitConfirm)
|
|
|
@ -1,45 +0,0 @@
|
||||||
#include "../hid.h"
|
|
||||||
#include "../views.h"
|
|
||||||
|
|
||||||
static void hid_scene_exit_confirm_dialog_callback(DialogExResult result, void* context) {
|
|
||||||
furi_assert(context);
|
|
||||||
Hid* app = context;
|
|
||||||
if(result == DialogExResultLeft) {
|
|
||||||
view_dispatcher_stop(app->view_dispatcher);
|
|
||||||
} else if(result == DialogExResultRight) {
|
|
||||||
scene_manager_previous_scene(app->scene_manager);
|
|
||||||
} else if(result == DialogExResultCenter) {
|
|
||||||
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, HidSceneMain);
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewSubmenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hid_scene_exit_confirm_on_enter(void* context) {
|
|
||||||
Hid* app = context;
|
|
||||||
|
|
||||||
// Exit dialog view
|
|
||||||
dialog_ex_reset(app->dialog);
|
|
||||||
dialog_ex_set_result_callback(app->dialog, hid_scene_exit_confirm_dialog_callback);
|
|
||||||
dialog_ex_set_context(app->dialog, app);
|
|
||||||
dialog_ex_set_left_button_text(app->dialog, "Exit");
|
|
||||||
dialog_ex_set_right_button_text(app->dialog, "Stay");
|
|
||||||
dialog_ex_set_center_button_text(app->dialog, "Menu");
|
|
||||||
dialog_ex_set_header(app->dialog, "Close Current App?", 16, 12, AlignLeft, AlignTop);
|
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewDialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hid_scene_exit_confirm_on_event(void* context, SceneManagerEvent event) {
|
|
||||||
Hid* app = context;
|
|
||||||
bool consumed = false;
|
|
||||||
UNUSED(app);
|
|
||||||
UNUSED(event);
|
|
||||||
|
|
||||||
return consumed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hid_scene_exit_confirm_on_exit(void* context) {
|
|
||||||
Hid* app = context;
|
|
||||||
|
|
||||||
dialog_ex_reset(app->dialog);
|
|
||||||
}
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
void hid_scene_main_on_enter(void* context) {
|
void hid_scene_main_on_enter(void* context) {
|
||||||
Hid* app = context;
|
Hid* app = context;
|
||||||
|
view_dispatcher_switch_to_view(
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);
|
app->view_dispatcher, scene_manager_get_scene_state(app->scene_manager, HidSceneMain));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hid_scene_main_on_event(void* context, SceneManagerEvent event) {
|
bool hid_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||||
|
|
127
applications/system/hid_app/scenes/hid_scene_start.c
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#include "../hid.h"
|
||||||
|
#include "../views.h"
|
||||||
|
|
||||||
|
enum HidSubmenuIndex {
|
||||||
|
HidSubmenuIndexKeynote,
|
||||||
|
HidSubmenuIndexKeynoteVertical,
|
||||||
|
HidSubmenuIndexKeyboard,
|
||||||
|
HidSubmenuIndexMedia,
|
||||||
|
HidSubmenuIndexTikTok,
|
||||||
|
HidSubmenuIndexMouse,
|
||||||
|
HidSubmenuIndexMouseClicker,
|
||||||
|
HidSubmenuIndexMouseJiggler,
|
||||||
|
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, "Media", HidSubmenuIndexMedia, hid_scene_start_submenu_callback, app);
|
||||||
|
submenu_add_item(
|
||||||
|
app->submenu, "Mouse", HidSubmenuIndexMouse, hid_scene_start_submenu_callback, app);
|
||||||
|
#ifdef HID_TRANSPORT_BLE
|
||||||
|
submenu_add_item(
|
||||||
|
app->submenu,
|
||||||
|
"TikTok Controller",
|
||||||
|
HidSubmenuIndexTikTok,
|
||||||
|
hid_scene_start_submenu_callback,
|
||||||
|
app);
|
||||||
|
#endif
|
||||||
|
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);
|
||||||
|
#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 HidSubmenuIndexMedia:
|
||||||
|
view_id = HidViewMedia;
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
}
|
|
@ -29,14 +29,12 @@ void hid_scene_unpair_on_enter(void* context) {
|
||||||
dialog_ex_reset(app->dialog);
|
dialog_ex_reset(app->dialog);
|
||||||
dialog_ex_set_result_callback(app->dialog, hid_scene_unpair_dialog_callback);
|
dialog_ex_set_result_callback(app->dialog, hid_scene_unpair_dialog_callback);
|
||||||
dialog_ex_set_context(app->dialog, app);
|
dialog_ex_set_context(app->dialog, app);
|
||||||
dialog_ex_set_header(app->dialog, "Unpair All Devices?", 64, 3, AlignCenter, AlignTop);
|
dialog_ex_set_header(app->dialog, "Unpair the Device?", 64, 3, AlignCenter, AlignTop);
|
||||||
dialog_ex_set_text(
|
|
||||||
app->dialog, "All previous pairings\nwill be lost!", 64, 22, AlignCenter, AlignTop);
|
|
||||||
dialog_ex_set_left_button_text(app->dialog, "Back");
|
dialog_ex_set_left_button_text(app->dialog, "Back");
|
||||||
dialog_ex_set_right_button_text(app->dialog, "Unpair");
|
dialog_ex_set_right_button_text(app->dialog, "Unpair");
|
||||||
|
|
||||||
// Un-pair success popup view
|
// 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_header(app->popup, "Done", 14, 15, AlignLeft, AlignTop);
|
||||||
popup_set_timeout(app->popup, 1500);
|
popup_set_timeout(app->popup, 1500);
|
||||||
popup_set_context(app->popup, app);
|
popup_set_context(app->popup, app);
|
||||||
|
|
|
@ -23,7 +23,6 @@ typedef struct {
|
||||||
bool ok_pressed;
|
bool ok_pressed;
|
||||||
bool back_pressed;
|
bool back_pressed;
|
||||||
bool connected;
|
bool connected;
|
||||||
HidTransport transport;
|
|
||||||
} HidKeyboardModel;
|
} HidKeyboardModel;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -230,7 +229,8 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidKeyboardModel* model = context;
|
HidKeyboardModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if((!model->connected) && (model->transport == HidTransportBle)) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
|
if(!model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Keyboard");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Keyboard");
|
||||||
|
@ -243,6 +243,7 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) {
|
||||||
canvas, 4, 60, AlignLeft, AlignBottom, "Waiting for Connection...");
|
canvas, 4, 60, AlignLeft, AlignBottom, "Waiting for Connection...");
|
||||||
return; // Dont render the keyboard if we are not yet connected
|
return; // Dont render the keyboard if we are not yet connected
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontKeyboard);
|
canvas_set_font(canvas, FontKeyboard);
|
||||||
// Start shifting the all keys up if on the next row (Scrolling)
|
// Start shifting the all keys up if on the next row (Scrolling)
|
||||||
|
@ -400,13 +401,7 @@ HidKeyboard* hid_keyboard_alloc(Hid* bt_hid) {
|
||||||
view_set_input_callback(hid_keyboard->view, hid_keyboard_input_callback);
|
view_set_input_callback(hid_keyboard->view, hid_keyboard_input_callback);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
hid_keyboard->view,
|
hid_keyboard->view, HidKeyboardModel * model, { model->y = 1; }, true);
|
||||||
HidKeyboardModel * model,
|
|
||||||
{
|
|
||||||
model->transport = bt_hid->transport;
|
|
||||||
model->y = 1;
|
|
||||||
},
|
|
||||||
true);
|
|
||||||
|
|
||||||
return hid_keyboard;
|
return hid_keyboard;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ typedef struct {
|
||||||
bool ok_pressed;
|
bool ok_pressed;
|
||||||
bool back_pressed;
|
bool back_pressed;
|
||||||
bool connected;
|
bool connected;
|
||||||
HidTransport transport;
|
|
||||||
} HidKeynoteModel;
|
} HidKeynoteModel;
|
||||||
|
|
||||||
static void hid_keynote_draw_arrow(Canvas* canvas, uint8_t x, uint8_t y, CanvasDirection dir) {
|
static void hid_keynote_draw_arrow(Canvas* canvas, uint8_t x, uint8_t y, CanvasDirection dir) {
|
||||||
|
@ -40,13 +39,13 @@ static void hid_keynote_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidKeynoteModel* model = context;
|
HidKeynoteModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Keynote");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Keynote");
|
||||||
|
@ -92,12 +91,12 @@ static void hid_keynote_draw_callback(Canvas* canvas, void* context) {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Ok
|
// Ok
|
||||||
canvas_draw_icon(canvas, 63, 25, &I_Space_65x18);
|
canvas_draw_icon(canvas, 63, 24, &I_Space_65x18);
|
||||||
if(model->ok_pressed) {
|
if(model->ok_pressed) {
|
||||||
elements_slightly_rounded_box(canvas, 66, 27, 60, 13);
|
elements_slightly_rounded_box(canvas, 66, 26, 60, 13);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 74, 29, &I_Ok_btn_9x9);
|
canvas_draw_icon(canvas, 74, 28, &I_Ok_btn_9x9);
|
||||||
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Space");
|
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Space");
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
|
@ -116,18 +115,18 @@ static void hid_keynote_draw_vertical_callback(Canvas* canvas, void* context) {
|
||||||
HidKeynoteModel* model = context;
|
HidKeynoteModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
|
||||||
}
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
|
||||||
elements_multiline_text_aligned(canvas, 20, 3, AlignLeft, AlignTop, "Keynote");
|
|
||||||
} else {
|
} else {
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
elements_multiline_text_aligned(canvas, 12, 3, AlignLeft, AlignTop, "Keynote");
|
|
||||||
}
|
}
|
||||||
|
canvas_set_font(canvas, FontPrimary);
|
||||||
|
elements_multiline_text_aligned(canvas, 20, 3, AlignLeft, AlignTop, "Keynote");
|
||||||
|
#else
|
||||||
|
canvas_set_font(canvas, FontPrimary);
|
||||||
|
elements_multiline_text_aligned(canvas, 12, 3, AlignLeft, AlignTop, "Keynote");
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_draw_icon(canvas, 2, 18, &I_Pin_back_arrow_10x8);
|
canvas_draw_icon(canvas, 2, 18, &I_Pin_back_arrow_10x8);
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
@ -274,10 +273,6 @@ HidKeynote* hid_keynote_alloc(Hid* hid) {
|
||||||
view_allocate_model(hid_keynote->view, ViewModelTypeLocking, sizeof(HidKeynoteModel));
|
view_allocate_model(hid_keynote->view, ViewModelTypeLocking, sizeof(HidKeynoteModel));
|
||||||
view_set_draw_callback(hid_keynote->view, hid_keynote_draw_callback);
|
view_set_draw_callback(hid_keynote->view, hid_keynote_draw_callback);
|
||||||
view_set_input_callback(hid_keynote->view, hid_keynote_input_callback);
|
view_set_input_callback(hid_keynote->view, hid_keynote_input_callback);
|
||||||
|
|
||||||
with_view_model(
|
|
||||||
hid_keynote->view, HidKeynoteModel * model, { model->transport = hid->transport; }, true);
|
|
||||||
|
|
||||||
return hid_keynote;
|
return hid_keynote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ typedef struct {
|
||||||
bool down_pressed;
|
bool down_pressed;
|
||||||
bool ok_pressed;
|
bool ok_pressed;
|
||||||
bool connected;
|
bool connected;
|
||||||
HidTransport transport;
|
|
||||||
} HidMediaModel;
|
} HidMediaModel;
|
||||||
|
|
||||||
static void hid_media_draw_arrow(Canvas* canvas, uint8_t x, uint8_t y, CanvasDirection dir) {
|
static void hid_media_draw_arrow(Canvas* canvas, uint8_t x, uint8_t y, CanvasDirection dir) {
|
||||||
|
@ -42,46 +41,46 @@ static void hid_media_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidMediaModel* model = context;
|
HidMediaModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Media");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Media");
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|
||||||
// Keypad circles
|
// Keypad circles
|
||||||
canvas_draw_icon(canvas, 76, 8, &I_Circles_47x47);
|
canvas_draw_icon(canvas, 75, 9, &I_Dpad_49x46);
|
||||||
|
|
||||||
// Up
|
// Up
|
||||||
if(model->up_pressed) {
|
if(model->up_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 93, 9, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 93, 10, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 96, 12, &I_Volup_8x6);
|
canvas_draw_icon(canvas, 96, 13, &I_Volup_8x6);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Down
|
// Down
|
||||||
if(model->down_pressed) {
|
if(model->down_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 93, 41, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 93, 41, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 96, 45, &I_Voldwn_6x6);
|
canvas_draw_icon(canvas, 96, 44, &I_Voldwn_6x6);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
if(model->left_pressed) {
|
if(model->left_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 77, 25, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 77, 25, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
hid_media_draw_arrow(canvas, 82, 31, CanvasDirectionRightToLeft);
|
hid_media_draw_arrow(canvas, 82, 31, CanvasDirectionRightToLeft);
|
||||||
|
@ -90,9 +89,9 @@ static void hid_media_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
if(model->right_pressed) {
|
if(model->right_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 109, 25, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 109, 25, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
hid_media_draw_arrow(canvas, 112, 31, CanvasDirectionLeftToRight);
|
hid_media_draw_arrow(canvas, 112, 31, CanvasDirectionLeftToRight);
|
||||||
|
@ -177,6 +176,8 @@ static bool hid_media_input_callback(InputEvent* event, void* context) {
|
||||||
hid_media_process_release(hid_media, event);
|
hid_media_process_release(hid_media, event);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event->type == InputTypeShort) {
|
} else if(event->type == InputTypeShort) {
|
||||||
|
consumed = true;
|
||||||
|
} else if(event->type == InputTypeLong) {
|
||||||
if(event->key == InputKeyBack) {
|
if(event->key == InputKeyBack) {
|
||||||
hid_hal_consumer_key_release_all(hid_media->hid);
|
hid_hal_consumer_key_release_all(hid_media->hid);
|
||||||
}
|
}
|
||||||
|
@ -193,10 +194,6 @@ HidMedia* hid_media_alloc(Hid* hid) {
|
||||||
view_allocate_model(hid_media->view, ViewModelTypeLocking, sizeof(HidMediaModel));
|
view_allocate_model(hid_media->view, ViewModelTypeLocking, sizeof(HidMediaModel));
|
||||||
view_set_draw_callback(hid_media->view, hid_media_draw_callback);
|
view_set_draw_callback(hid_media->view, hid_media_draw_callback);
|
||||||
view_set_input_callback(hid_media->view, hid_media_input_callback);
|
view_set_input_callback(hid_media->view, hid_media_input_callback);
|
||||||
|
|
||||||
with_view_model(
|
|
||||||
hid_media->view, HidMediaModel * model, { model->transport = hid->transport; }, true);
|
|
||||||
|
|
||||||
return hid_media;
|
return hid_media;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
|
||||||
typedef struct Hid Hid;
|
typedef struct Hid Hid;
|
||||||
|
|
||||||
typedef struct HidMedia HidMedia;
|
typedef struct HidMedia HidMedia;
|
||||||
|
|
||||||
HidMedia* hid_media_alloc(Hid* hid);
|
HidMedia* hid_media_alloc(Hid* hid);
|
||||||
|
|
|
@ -20,7 +20,6 @@ typedef struct {
|
||||||
bool left_mouse_held;
|
bool left_mouse_held;
|
||||||
bool right_mouse_pressed;
|
bool right_mouse_pressed;
|
||||||
bool connected;
|
bool connected;
|
||||||
HidTransport transport;
|
|
||||||
} HidMouseModel;
|
} HidMouseModel;
|
||||||
|
|
||||||
static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
@ -28,13 +27,13 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidMouseModel* model = context;
|
HidMouseModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse");
|
||||||
|
@ -49,23 +48,23 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keypad circles
|
// Keypad circles
|
||||||
canvas_draw_icon(canvas, 64, 8, &I_Circles_47x47);
|
canvas_draw_icon(canvas, 63, 9, &I_Dpad_49x46);
|
||||||
|
|
||||||
// Up
|
// Up
|
||||||
if(model->up_pressed) {
|
if(model->up_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 81, 9, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 81, 10, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 84, 10, &I_Pin_arrow_up_7x9);
|
canvas_draw_icon(canvas, 84, 12, &I_Pin_arrow_up_7x9);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Down
|
// Down
|
||||||
if(model->down_pressed) {
|
if(model->down_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 81, 41, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 81, 41, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 84, 43, &I_Pin_arrow_down_7x9);
|
canvas_draw_icon(canvas, 84, 43, &I_Pin_arrow_down_7x9);
|
||||||
|
@ -73,9 +72,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
if(model->left_pressed) {
|
if(model->left_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 65, 25, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 65, 25, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 67, 28, &I_Pin_arrow_left_9x7);
|
canvas_draw_icon(canvas, 67, 28, &I_Pin_arrow_left_9x7);
|
||||||
|
@ -83,9 +82,9 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
if(model->right_pressed) {
|
if(model->right_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 97, 25, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 97, 25, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 99, 28, &I_Pin_arrow_right_9x7);
|
canvas_draw_icon(canvas, 99, 28, &I_Pin_arrow_right_9x7);
|
||||||
|
@ -93,16 +92,16 @@ static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
|
||||||
// Ok
|
// Ok
|
||||||
if(model->left_mouse_pressed) {
|
if(model->left_mouse_pressed) {
|
||||||
canvas_draw_icon(canvas, 81, 25, &I_Ok_btn_pressed_13x13);
|
canvas_draw_icon(canvas, 81, 26, &I_Ok_btn_pressed_13x12);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 83, 27, &I_Left_mouse_icon_9x9);
|
canvas_draw_icon(canvas, 83, 27, &I_Left_mouse_icon_9x10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
if(model->right_mouse_pressed) {
|
if(model->right_mouse_pressed) {
|
||||||
canvas_draw_icon(canvas, 108, 48, &I_Ok_btn_pressed_13x13);
|
canvas_draw_icon(canvas, 108, 49, &I_Ok_btn_pressed_13x12);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 110, 50, &I_Right_mouse_icon_9x9);
|
canvas_draw_icon(canvas, 110, 50, &I_Right_mouse_icon_9x10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +184,15 @@ static bool hid_mouse_input_callback(InputEvent* event, void* context) {
|
||||||
|
|
||||||
if(event->type == InputTypeLong && event->key == InputKeyBack) {
|
if(event->type == InputTypeLong && event->key == InputKeyBack) {
|
||||||
hid_hal_mouse_release_all(hid_mouse->hid);
|
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 {
|
} else {
|
||||||
hid_mouse_process(hid_mouse, event);
|
hid_mouse_process(hid_mouse, event);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
@ -201,10 +209,6 @@ HidMouse* hid_mouse_alloc(Hid* hid) {
|
||||||
view_allocate_model(hid_mouse->view, ViewModelTypeLocking, sizeof(HidMouseModel));
|
view_allocate_model(hid_mouse->view, ViewModelTypeLocking, sizeof(HidMouseModel));
|
||||||
view_set_draw_callback(hid_mouse->view, hid_mouse_draw_callback);
|
view_set_draw_callback(hid_mouse->view, hid_mouse_draw_callback);
|
||||||
view_set_input_callback(hid_mouse->view, hid_mouse_input_callback);
|
view_set_input_callback(hid_mouse->view, hid_mouse_input_callback);
|
||||||
|
|
||||||
with_view_model(
|
|
||||||
hid_mouse->view, HidMouseModel * model, { model->transport = hid->transport; }, true);
|
|
||||||
|
|
||||||
return hid_mouse;
|
return hid_mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ typedef struct {
|
||||||
bool connected;
|
bool connected;
|
||||||
bool running;
|
bool running;
|
||||||
int rate;
|
int rate;
|
||||||
HidTransport transport;
|
|
||||||
} HidMouseClickerModel;
|
} HidMouseClickerModel;
|
||||||
|
|
||||||
static void hid_mouse_clicker_start_or_restart_timer(void* context) {
|
static void hid_mouse_clicker_start_or_restart_timer(void* context) {
|
||||||
|
@ -44,46 +43,46 @@ static void hid_mouse_clicker_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidMouseClickerModel* model = context;
|
HidMouseClickerModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse Clicker");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse Clicker");
|
||||||
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|
||||||
// Ok
|
// Ok
|
||||||
canvas_draw_icon(canvas, 63, 25, &I_Space_65x18);
|
canvas_draw_icon(canvas, 58, 25, &I_Space_65x18);
|
||||||
|
|
||||||
if(model->running) {
|
if(model->running) {
|
||||||
canvas_set_font(canvas, FontPrimary);
|
elements_slightly_rounded_box(canvas, 61, 27, 60, 13);
|
||||||
|
|
||||||
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);
|
|
||||||
canvas_set_color(canvas, ColorWhite);
|
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) {
|
if(model->running) {
|
||||||
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Stop");
|
elements_multiline_text_aligned(canvas, 86, 37, AlignLeft, AlignBottom, "Stop");
|
||||||
} else {
|
} 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);
|
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
|
// Back
|
||||||
canvas_draw_icon(canvas, 74, 49, &I_Pin_back_arrow_10x8);
|
canvas_draw_icon(canvas, 0, 54, &I_Pin_back_arrow_10x8);
|
||||||
elements_multiline_text_aligned(canvas, 91, 57, AlignLeft, AlignBottom, "Quit");
|
elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_mouse_clicker_timer_callback(void* context) {
|
static void hid_mouse_clicker_timer_callback(void* context) {
|
||||||
|
@ -145,6 +144,9 @@ static bool hid_mouse_clicker_input_callback(InputEvent* event, void* context) {
|
||||||
rate_changed = true;
|
rate_changed = true;
|
||||||
consumed = true;
|
consumed = true;
|
||||||
break;
|
break;
|
||||||
|
case InputKeyBack:
|
||||||
|
model->running = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
consumed = true;
|
consumed = true;
|
||||||
break;
|
break;
|
||||||
|
@ -179,10 +181,7 @@ HidMouseClicker* hid_mouse_clicker_alloc(Hid* hid) {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
hid_mouse_clicker->view,
|
hid_mouse_clicker->view,
|
||||||
HidMouseClickerModel * model,
|
HidMouseClickerModel * model,
|
||||||
{
|
{ model->rate = DEFAULT_CLICK_RATE; },
|
||||||
model->transport = hid->transport;
|
|
||||||
model->rate = DEFAULT_CLICK_RATE;
|
|
||||||
},
|
|
||||||
true);
|
true);
|
||||||
|
|
||||||
return hid_mouse_clicker;
|
return hid_mouse_clicker;
|
||||||
|
|
|
@ -16,7 +16,6 @@ typedef struct {
|
||||||
bool connected;
|
bool connected;
|
||||||
bool running;
|
bool running;
|
||||||
uint8_t counter;
|
uint8_t counter;
|
||||||
HidTransport transport;
|
|
||||||
} HidMouseJigglerModel;
|
} HidMouseJigglerModel;
|
||||||
|
|
||||||
static void hid_mouse_jiggler_draw_callback(Canvas* canvas, void* context) {
|
static void hid_mouse_jiggler_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
@ -24,38 +23,38 @@ static void hid_mouse_jiggler_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidMouseJigglerModel* model = context;
|
HidMouseJigglerModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse Jiggler");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse Jiggler");
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
|
||||||
elements_multiline_text(canvas, AlignLeft, 35, "Press Start\nto jiggle");
|
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|
||||||
// Ok
|
// Ok
|
||||||
canvas_draw_icon(canvas, 63, 25, &I_Space_65x18);
|
canvas_draw_icon(canvas, 32, 25, &I_Space_65x18);
|
||||||
|
|
||||||
if(model->running) {
|
if(model->running) {
|
||||||
elements_slightly_rounded_box(canvas, 66, 27, 60, 13);
|
elements_slightly_rounded_box(canvas, 35, 27, 60, 13);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 74, 29, &I_Ok_btn_9x9);
|
|
||||||
|
canvas_draw_icon(canvas, 43, 29, &I_Ok_btn_9x9);
|
||||||
|
|
||||||
if(model->running) {
|
if(model->running) {
|
||||||
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Stop");
|
elements_multiline_text_aligned(canvas, 60, 37, AlignLeft, AlignBottom, "Stop");
|
||||||
} else {
|
} else {
|
||||||
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Start");
|
elements_multiline_text_aligned(canvas, 60, 37, AlignLeft, AlignBottom, "Start");
|
||||||
}
|
}
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Back
|
// Back
|
||||||
canvas_draw_icon(canvas, 74, 49, &I_Pin_back_arrow_10x8);
|
canvas_draw_icon(canvas, 0, 54, &I_Pin_back_arrow_10x8);
|
||||||
elements_multiline_text_aligned(canvas, 91, 57, AlignLeft, AlignBottom, "Quit");
|
elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_mouse_jiggler_timer_callback(void* context) {
|
static void hid_mouse_jiggler_timer_callback(void* context) {
|
||||||
|
@ -95,13 +94,25 @@ static bool hid_mouse_jiggler_input_callback(InputEvent* event, void* context) {
|
||||||
|
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
|
||||||
if(event->type == InputTypeShort && event->key == InputKeyOk) {
|
if(event->type == InputTypeShort) {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
hid_mouse_jiggler->view,
|
hid_mouse_jiggler->view,
|
||||||
HidMouseJigglerModel * model,
|
HidMouseJigglerModel * model,
|
||||||
{ model->running = !model->running; },
|
{
|
||||||
|
switch(event->key) {
|
||||||
|
case InputKeyOk:
|
||||||
|
model->running = !model->running;
|
||||||
|
consumed = true;
|
||||||
|
break;
|
||||||
|
case InputKeyBack:
|
||||||
|
model->running = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
consumed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
true);
|
true);
|
||||||
consumed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
|
@ -124,12 +135,6 @@ HidMouseJiggler* hid_mouse_jiggler_alloc(Hid* hid) {
|
||||||
hid_mouse_jiggler->timer = furi_timer_alloc(
|
hid_mouse_jiggler->timer = furi_timer_alloc(
|
||||||
hid_mouse_jiggler_timer_callback, FuriTimerTypePeriodic, hid_mouse_jiggler);
|
hid_mouse_jiggler_timer_callback, FuriTimerTypePeriodic, hid_mouse_jiggler);
|
||||||
|
|
||||||
with_view_model(
|
|
||||||
hid_mouse_jiggler->view,
|
|
||||||
HidMouseJigglerModel * model,
|
|
||||||
{ model->transport = hid->transport; },
|
|
||||||
true);
|
|
||||||
|
|
||||||
return hid_mouse_jiggler;
|
return hid_mouse_jiggler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ typedef struct {
|
||||||
bool ok_pressed;
|
bool ok_pressed;
|
||||||
bool connected;
|
bool connected;
|
||||||
bool is_cursor_set;
|
bool is_cursor_set;
|
||||||
HidTransport transport;
|
|
||||||
} HidTikTokModel;
|
} HidTikTokModel;
|
||||||
|
|
||||||
static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
@ -27,46 +26,46 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
||||||
HidTikTokModel* model = context;
|
HidTikTokModel* model = context;
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if(model->transport == HidTransportBle) {
|
#ifdef HID_TRANSPORT_BLE
|
||||||
if(model->connected) {
|
if(model->connected) {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "TikTok");
|
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "TikTok");
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|
||||||
// Keypad circles
|
// Keypad circles
|
||||||
canvas_draw_icon(canvas, 76, 8, &I_Circles_47x47);
|
canvas_draw_icon(canvas, 75, 9, &I_Dpad_49x46);
|
||||||
|
|
||||||
// Up
|
// Up
|
||||||
if(model->up_pressed) {
|
if(model->up_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 93, 9, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 93, 10, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 96, 11, &I_Arr_up_7x9);
|
canvas_draw_icon(canvas, 96, 12, &I_Arr_up_7x9);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Down
|
// Down
|
||||||
if(model->down_pressed) {
|
if(model->down_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 93, 41, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 93, 41, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 96, 44, &I_Arr_dwn_7x9);
|
canvas_draw_icon(canvas, 96, 43, &I_Arr_dwn_7x9);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
if(model->left_pressed) {
|
if(model->left_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 77, 25, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 77, 25, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 81, 29, &I_Voldwn_6x6);
|
canvas_draw_icon(canvas, 81, 29, &I_Voldwn_6x6);
|
||||||
|
@ -74,19 +73,21 @@ static void hid_tiktok_draw_callback(Canvas* canvas, void* context) {
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
if(model->right_pressed) {
|
if(model->right_pressed) {
|
||||||
canvas_set_bitmap_mode(canvas, 1);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
canvas_draw_icon(canvas, 109, 25, &I_Pressed_Button_13x13);
|
canvas_draw_icon(canvas, 110, 25, &I_Pressed_Button_13x13);
|
||||||
canvas_set_bitmap_mode(canvas, 0);
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
}
|
}
|
||||||
canvas_draw_icon(canvas, 111, 29, &I_Volup_8x6);
|
canvas_draw_icon(canvas, 112, 29, &I_Volup_8x6);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
// Ok
|
// Ok
|
||||||
if(model->ok_pressed) {
|
if(model->ok_pressed) {
|
||||||
canvas_draw_icon(canvas, 91, 23, &I_Like_pressed_17x17);
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
|
canvas_draw_icon(canvas, 91, 24, &I_Like_pressed_17x16);
|
||||||
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, 94, 27, &I_Like_def_11x9);
|
canvas_draw_icon(canvas, 93, 27, &I_Like_def_13x11);
|
||||||
}
|
}
|
||||||
// Exit
|
// Exit
|
||||||
canvas_draw_icon(canvas, 0, 54, &I_Pin_back_arrow_10x8);
|
canvas_draw_icon(canvas, 0, 54, &I_Pin_back_arrow_10x8);
|
||||||
|
@ -211,9 +212,6 @@ HidTikTok* hid_tiktok_alloc(Hid* bt_hid) {
|
||||||
view_set_draw_callback(hid_tiktok->view, hid_tiktok_draw_callback);
|
view_set_draw_callback(hid_tiktok->view, hid_tiktok_draw_callback);
|
||||||
view_set_input_callback(hid_tiktok->view, hid_tiktok_input_callback);
|
view_set_input_callback(hid_tiktok->view, hid_tiktok_input_callback);
|
||||||
|
|
||||||
with_view_model(
|
|
||||||
hid_tiktok->view, HidTikTokModel * model, { model->transport = bt_hid->transport; }, true);
|
|
||||||
|
|
||||||
return hid_tiktok;
|
return hid_tiktok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|