mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 20:43:07 +00:00
Merge remote-tracking branch 'remotes/origin/dev' into hedger/toochain_29
# Conflicts: # scripts/toolchain/fbtenv.sh
This commit is contained in:
commit
b38d2e8d84
13 changed files with 333 additions and 45 deletions
27
.github/workflows/reindex.yml
vendored
27
.github/workflows/reindex.yml
vendored
|
@ -1,15 +1,32 @@
|
|||
name: 'Reindex'
|
||||
name: 'Post-release hooks'
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [prereleased,released]
|
||||
types: [prereleased, released]
|
||||
|
||||
jobs:
|
||||
reindex:
|
||||
name: 'Reindex updates'
|
||||
name: 'Post-release hooks'
|
||||
runs-on: [self-hosted, FlipperZeroShell]
|
||||
steps:
|
||||
- name: Trigger reindex
|
||||
- name: 'Checkout code'
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 'Trigger reindex'
|
||||
run: |
|
||||
curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \
|
||||
"${{ secrets.INDEXER_URL }}"/firmware/reindex
|
||||
"${{ secrets.INDEXER_URL }}"/firmware/reindex;
|
||||
|
||||
- name: 'Send release notification'
|
||||
if: ${{ github.event.action == 'released' }}
|
||||
run: |
|
||||
echo '${{ secrets.FIREBASE_TOKEN }}' > firebase-token.json;
|
||||
python3 -m pip install firebase-admin==6.4.0;
|
||||
python3 scripts/send_firebase_notification.py \
|
||||
"--version=${{ github.event.release.name }}" \
|
||||
"--token=firebase-token.json";
|
||||
|
||||
- name: 'Remove firebase token'
|
||||
if: always()
|
||||
run: |
|
||||
rm -rf firebase-token.json;
|
||||
|
|
|
@ -827,3 +827,27 @@ type: raw
|
|||
frequency: 38000
|
||||
duty_cycle: 0.33
|
||||
data: 9011 4388 557 1617 532 1617 532 489 533 489 558 464 558 440 582 440 582 1593 556 466 556 466 556 1594 556 467 555 1595 555 1595 529 1620 554 1596 554 467 554 468 555 1595 579 443 581 1569 581 441 581 441 580 442 581 1569 581 1569 581 441 581 1569 580 441 581 1569 581 1569 581 1570 579 42152 8957 2159 556
|
||||
# PLUS U5/V3-200R Standby
|
||||
name: Power
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9033 4255 562 543 564 1701 562 1674 563 567 565 541 564 567 565 567 537 1700 564 1700 537 568 564 1699 564 541 565 1699 565 540 565 567 565 570 535 567 565 567 565 1673 564 567 565 1673 564 567 565 540 618 514 565 1700 563 1674 564 567 564 1674 563 569 563 1672 565 1700 589 1648 564
|
||||
# PLUS U5/V3-200R Mute
|
||||
name: Mute
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9034 4255 564 567 564 1671 566 1699 564 540 565 567 565 540 564 566 566 1699 563 1672 567 565 566 1673 565 567 565 1672 565 566 566 539 565 567 565 1698 539 566 566 1698 564 541 565 565 567 1672 565 566 566 1672 565 567 565 1699 538 566 566 1698 564 1673 566 566 565 1672 566 566 566
|
||||
# PLUS U5/V3-200R 1/Volume up
|
||||
name: Vol_up
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9035 4254 565 566 565 1672 566 1699 564 539 567 566 566 540 564 567 565 1698 539 1698 566 566 564 1673 565 566 565 1672 565 566 566 539 566 566 566 567 563 541 565 566 566 538 566 566 566 1671 566 566 566 1697 565 1675 563 1699 563 1674 565 1699 538 1700 564 565 565 1674 564 567 565
|
||||
# PLUS U5/V3-200R 3/Volume down
|
||||
name: Vol_dn
|
||||
type: raw
|
||||
frequency: 38000
|
||||
duty_cycle: 0.330000
|
||||
data: 9010 4253 564 566 566 1671 566 1699 565 565 539 568 564 566 565 539 566 1699 565 1672 565 566 566 1672 564 567 565 1672 565 567 565 567 564 541 564 1698 566 539 565 567 565 567 562 542 565 1699 564 539 567 1699 565 540 564 1698 566 1672 565 1698 566 1672 565 567 565 1671 565 566 566
|
||||
|
|
BIN
applications/system/hid_app/assets/DolphinNice_96x59.png
Normal file
BIN
applications/system/hid_app/assets/DolphinNice_96x59.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
|
@ -4,6 +4,7 @@
|
|||
#include "views.h"
|
||||
#include <notification/notification_messages.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include "hid_icons.h"
|
||||
|
||||
#define TAG "HidApp"
|
||||
|
||||
|
@ -19,7 +20,22 @@ enum HidDebugSubmenuIndex {
|
|||
HidSubmenuIndexRemovePairing,
|
||||
};
|
||||
|
||||
static void bt_hid_remove_pairing(Bt* bt) {
|
||||
bool hid_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
bool hid_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
FURI_LOG_D("HID", "Back event");
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneExitConfirm);
|
||||
return true;
|
||||
}
|
||||
|
||||
void bt_hid_remove_pairing(Hid* app) {
|
||||
Bt* bt = app->bt;
|
||||
bt_disconnect(bt);
|
||||
|
||||
// Wait 2nd core to update nvm storage
|
||||
|
@ -62,7 +78,7 @@ static void hid_submenu_callback(void* context, uint32_t index) {
|
|||
app->view_id = HidViewMouseJiggler;
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseJiggler);
|
||||
} else if(index == HidSubmenuIndexRemovePairing) {
|
||||
bt_hid_remove_pairing(app->bt);
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneUnpair);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,23 +102,6 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con
|
|||
hid_tiktok_set_connected_status(hid->hid_tiktok, connected);
|
||||
}
|
||||
|
||||
static void hid_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) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id); // Show last view
|
||||
} else if(result == DialogExResultCenter) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewSubmenu);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t hid_exit_confirm_view(void* context) {
|
||||
UNUSED(context);
|
||||
return HidViewExitConfirm;
|
||||
}
|
||||
|
||||
static uint32_t hid_exit(void* context) {
|
||||
UNUSED(context);
|
||||
return VIEW_NONE;
|
||||
|
@ -124,6 +123,12 @@ Hid* hid_alloc() {
|
|||
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);
|
||||
|
||||
// Scene Manager
|
||||
app->scene_manager = scene_manager_alloc(&hid_scene_handlers, app);
|
||||
|
||||
// Device Type Submenu view
|
||||
app->device_type_submenu = submenu_alloc();
|
||||
submenu_add_item(
|
||||
|
@ -172,58 +177,48 @@ Hid* hid_alloc() {
|
|||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, HidViewSubmenu, submenu_get_view(app->device_type_submenu));
|
||||
app->view_id = HidViewSubmenu;
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);
|
||||
return app;
|
||||
}
|
||||
|
||||
Hid* hid_app_alloc_view(void* context) {
|
||||
furi_assert(context);
|
||||
Hid* app = context;
|
||||
|
||||
// Dialog view
|
||||
app->dialog = dialog_ex_alloc();
|
||||
dialog_ex_set_result_callback(app->dialog, hid_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_add_view(
|
||||
app->view_dispatcher, HidViewExitConfirm, dialog_ex_get_view(app->dialog));
|
||||
view_dispatcher_add_view(app->view_dispatcher, HidViewDialog, dialog_ex_get_view(app->dialog));
|
||||
|
||||
// Popup view
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, HidViewPopup, popup_get_view(app->popup));
|
||||
|
||||
// Keynote view
|
||||
app->hid_keynote = hid_keynote_alloc(app);
|
||||
view_set_previous_callback(hid_keynote_get_view(app->hid_keynote), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, HidViewKeynote, hid_keynote_get_view(app->hid_keynote));
|
||||
|
||||
// Keyboard view
|
||||
app->hid_keyboard = hid_keyboard_alloc(app);
|
||||
view_set_previous_callback(hid_keyboard_get_view(app->hid_keyboard), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, HidViewKeyboard, hid_keyboard_get_view(app->hid_keyboard));
|
||||
|
||||
// Media view
|
||||
app->hid_media = hid_media_alloc(app);
|
||||
view_set_previous_callback(hid_media_get_view(app->hid_media), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, HidViewMedia, hid_media_get_view(app->hid_media));
|
||||
|
||||
// TikTok view
|
||||
app->hid_tiktok = hid_tiktok_alloc(app);
|
||||
view_set_previous_callback(hid_tiktok_get_view(app->hid_tiktok), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, BtHidViewTikTok, hid_tiktok_get_view(app->hid_tiktok));
|
||||
|
||||
// Mouse view
|
||||
app->hid_mouse = hid_mouse_alloc(app);
|
||||
view_set_previous_callback(hid_mouse_get_view(app->hid_mouse), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, HidViewMouse, hid_mouse_get_view(app->hid_mouse));
|
||||
|
||||
// Mouse clicker view
|
||||
app->hid_mouse_clicker = hid_mouse_clicker_alloc(app);
|
||||
view_set_previous_callback(
|
||||
hid_mouse_clicker_get_view(app->hid_mouse_clicker), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
HidViewMouseClicker,
|
||||
|
@ -231,8 +226,6 @@ Hid* hid_app_alloc_view(void* context) {
|
|||
|
||||
// Mouse jiggler view
|
||||
app->hid_mouse_jiggler = hid_mouse_jiggler_alloc(app);
|
||||
view_set_previous_callback(
|
||||
hid_mouse_jiggler_get_view(app->hid_mouse_jiggler), hid_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
HidViewMouseJiggler,
|
||||
|
@ -251,8 +244,10 @@ void hid_free(Hid* app) {
|
|||
// Free views
|
||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewSubmenu);
|
||||
submenu_free(app->device_type_submenu);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewExitConfirm);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewDialog);
|
||||
dialog_ex_free(app->dialog);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewPopup);
|
||||
popup_free(app->popup);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewKeynote);
|
||||
hid_keynote_free(app->hid_keynote);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, HidViewKeyboard);
|
||||
|
@ -267,6 +262,7 @@ void hid_free(Hid* app) {
|
|||
hid_mouse_jiggler_free(app->hid_mouse_jiggler);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewTikTok);
|
||||
hid_tiktok_free(app->hid_tiktok);
|
||||
scene_manager_free(app->scene_manager);
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
// Close records
|
||||
|
@ -285,6 +281,8 @@ 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);
|
||||
|
@ -293,6 +291,8 @@ int32_t hid_usb_app(void* p) {
|
|||
|
||||
dolphin_deed(DolphinDeedPluginStart);
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneMain);
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
furi_hal_usb_set_config(usb_mode_prev, NULL);
|
||||
|
@ -307,6 +307,8 @@ int32_t hid_ble_app(void* p) {
|
|||
Hid* app = hid_alloc();
|
||||
app = hid_app_alloc_view(app);
|
||||
|
||||
FURI_LOG_D("HID", "Starting as BLE app");
|
||||
|
||||
bt_disconnect(app->bt);
|
||||
|
||||
// Wait 2nd core to update nvm storage
|
||||
|
@ -333,6 +335,8 @@ int32_t hid_ble_app(void* p) {
|
|||
|
||||
dolphin_deed(DolphinDeedPluginStart);
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, HidSceneMain);
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
bt_set_status_changed_callback(app->bt, NULL, NULL);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <gui/gui.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <notification/notification.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
|
@ -25,6 +26,8 @@
|
|||
#include "views/hid_mouse_jiggler.h"
|
||||
#include "views/hid_tiktok.h"
|
||||
|
||||
#include "scenes/hid_scene.h"
|
||||
|
||||
#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"
|
||||
|
||||
typedef enum {
|
||||
|
@ -40,8 +43,10 @@ struct Hid {
|
|||
Gui* gui;
|
||||
NotificationApp* notifications;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
Submenu* device_type_submenu;
|
||||
DialogEx* dialog;
|
||||
Popup* popup;
|
||||
HidKeynote* hid_keynote;
|
||||
HidKeyboard* hid_keyboard;
|
||||
HidMedia* hid_media;
|
||||
|
@ -53,6 +58,7 @@ struct Hid {
|
|||
HidTransport transport;
|
||||
uint32_t view_id;
|
||||
};
|
||||
void bt_hid_remove_pairing(Hid* app);
|
||||
|
||||
void hid_hal_keyboard_press(Hid* instance, uint16_t event);
|
||||
void hid_hal_keyboard_release(Hid* instance, uint16_t event);
|
||||
|
|
30
applications/system/hid_app/scenes/hid_scene.c
Normal file
30
applications/system/hid_app/scenes/hid_scene.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "hid_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const hid_on_enter_handlers[])(void*) = {
|
||||
#include "hid_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const hid_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "hid_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const hid_on_exit_handlers[])(void* context) = {
|
||||
#include "hid_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers hid_scene_handlers = {
|
||||
.on_enter_handlers = hid_on_enter_handlers,
|
||||
.on_event_handlers = hid_on_event_handlers,
|
||||
.on_exit_handlers = hid_on_exit_handlers,
|
||||
.scene_num = HidSceneNum,
|
||||
};
|
29
applications/system/hid_app/scenes/hid_scene.h
Normal file
29
applications/system/hid_app/scenes/hid_scene.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) HidScene##id,
|
||||
typedef enum {
|
||||
#include "hid_scene_config.h"
|
||||
HidSceneNum,
|
||||
} HidScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers hid_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "hid_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "hid_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "hid_scene_config.h"
|
||||
#undef ADD_SCENE
|
3
applications/system/hid_app/scenes/hid_scene_config.h
Normal file
3
applications/system/hid_app/scenes/hid_scene_config.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
ADD_SCENE(hid, main, Main)
|
||||
ADD_SCENE(hid, unpair, Unpair)
|
||||
ADD_SCENE(hid, exit_confirm, ExitConfirm)
|
45
applications/system/hid_app/scenes/hid_scene_exit_confirm.c
Normal file
45
applications/system/hid_app/scenes/hid_scene_exit_confirm.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#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);
|
||||
}
|
22
applications/system/hid_app/scenes/hid_scene_main.c
Normal file
22
applications/system/hid_app/scenes/hid_scene_main.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "../hid.h"
|
||||
#include "../views.h"
|
||||
|
||||
void hid_scene_main_on_enter(void* context) {
|
||||
Hid* app = context;
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);
|
||||
}
|
||||
|
||||
bool hid_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
Hid* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void hid_scene_main_on_exit(void* context) {
|
||||
Hid* app = context;
|
||||
UNUSED(app);
|
||||
}
|
63
applications/system/hid_app/scenes/hid_scene_unpair.c
Normal file
63
applications/system/hid_app/scenes/hid_scene_unpair.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include "../hid.h"
|
||||
#include "../views.h"
|
||||
#include "hid_icons.h"
|
||||
|
||||
static void hid_scene_unpair_dialog_callback(DialogExResult result, void* context) {
|
||||
Hid* app = context;
|
||||
|
||||
if(result == DialogExResultRight) {
|
||||
// Unpair all devices
|
||||
bt_hid_remove_pairing(app);
|
||||
|
||||
// Show popup
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewPopup);
|
||||
} else if(result == DialogExResultLeft) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
}
|
||||
}
|
||||
|
||||
void hid_scene_unpair_popup_callback(void* context) {
|
||||
Hid* app = context;
|
||||
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
}
|
||||
|
||||
void hid_scene_unpair_on_enter(void* context) {
|
||||
Hid* app = context;
|
||||
|
||||
// Un-pair dialog view
|
||||
dialog_ex_reset(app->dialog);
|
||||
dialog_ex_set_result_callback(app->dialog, hid_scene_unpair_dialog_callback);
|
||||
dialog_ex_set_context(app->dialog, app);
|
||||
dialog_ex_set_header(app->dialog, "Unpair All Devices?", 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_right_button_text(app->dialog, "Unpair");
|
||||
|
||||
// Un-pair success popup view
|
||||
popup_set_icon(app->popup, 32, 5, &I_DolphinNice_96x59);
|
||||
popup_set_header(app->popup, "Done", 14, 15, AlignLeft, AlignTop);
|
||||
popup_set_timeout(app->popup, 1500);
|
||||
popup_set_context(app->popup, app);
|
||||
popup_set_callback(app->popup, hid_scene_unpair_popup_callback);
|
||||
popup_enable_timeout(app->popup);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewDialog);
|
||||
}
|
||||
|
||||
bool hid_scene_unpair_on_event(void* context, SceneManagerEvent event) {
|
||||
Hid* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void hid_scene_unpair_on_exit(void* context) {
|
||||
Hid* app = context;
|
||||
|
||||
dialog_ex_reset(app->dialog);
|
||||
popup_reset(app->popup);
|
||||
}
|
|
@ -7,5 +7,6 @@ typedef enum {
|
|||
HidViewMouseClicker,
|
||||
HidViewMouseJiggler,
|
||||
BtHidViewTikTok,
|
||||
HidViewExitConfirm,
|
||||
HidViewDialog,
|
||||
HidViewPopup,
|
||||
} HidView;
|
44
scripts/send_firebase_notification.py
Normal file
44
scripts/send_firebase_notification.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
import argparse
|
||||
import logging
|
||||
from firebase_admin import messaging, credentials, initialize_app
|
||||
|
||||
|
||||
class FirebaseNotifications:
|
||||
def __init__(self, service_account_file):
|
||||
try:
|
||||
cred = credentials.Certificate(service_account_file)
|
||||
self.firebase_app = initialize_app(cred)
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
raise e
|
||||
|
||||
def send(self, title, body, condition):
|
||||
try:
|
||||
message = messaging.Message(
|
||||
notification=messaging.Notification(title=title, body=body),
|
||||
condition=condition,
|
||||
)
|
||||
messaging.send(message, app=self.firebase_app)
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
raise e
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--token_file", help="Firebase token file", required=True)
|
||||
parser.add_argument(
|
||||
"--version", help="Firmware version to notify with", required=True
|
||||
)
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
notification = FirebaseNotifications(args.token_file)
|
||||
notification.send(
|
||||
title="Firmware Update Available",
|
||||
body=f"New firmware version is ready to install: {args.version}",
|
||||
condition="'flipper_update_firmware_release' in topics",
|
||||
)
|
Loading…
Reference in a new issue