bad_kb_app_i.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. #include "bad_kb_app.h"
  3. #include "scenes/bad_kb_scene.h"
  4. #include "helpers/ducky_script.h"
  5. #include "helpers/ble_hid.h"
  6. #include "bad_kb_paths.h"
  7. #include <gui/gui.h>
  8. #include <assets_icons.h>
  9. #include <gui/view_dispatcher.h>
  10. #include <gui/scene_manager.h>
  11. #include <gui/modules/submenu.h>
  12. #include <dialogs/dialogs.h>
  13. #include <notification/notification_messages.h>
  14. #include <gui/modules/variable_item_list.h>
  15. #include <gui/modules/text_input.h>
  16. #include <gui/modules/byte_input.h>
  17. #include <gui/modules/loading.h>
  18. #include <gui/modules/widget.h>
  19. #include "views/bad_kb_view.h"
  20. #include <furi_hal_usb.h>
  21. #define BAD_KB_APP_SCRIPT_EXTENSION ".txt"
  22. #define BAD_KB_APP_LAYOUT_EXTENSION ".kl"
  23. extern uint8_t BAD_KB_BOUND_MAC[GAP_MAC_ADDR_SIZE]; // For remember mode
  24. typedef enum BadKbCustomEvent {
  25. BadKbAppCustomEventTextInputDone,
  26. BadKbAppCustomEventByteInputDone,
  27. BadKbCustomEventErrorBack
  28. } BadKbCustomEvent;
  29. typedef enum {
  30. BadKbAppErrorNoFiles,
  31. } BadKbAppError;
  32. typedef struct {
  33. BleProfileHidParams ble;
  34. FuriHalUsbHidConfig usb;
  35. } BadKbConfig;
  36. typedef enum {
  37. BadKbConnModeNone,
  38. BadKbConnModeUsb,
  39. BadKbConnModeBt,
  40. } BadKbConnMode;
  41. struct BadKbApp {
  42. Gui* gui;
  43. ViewDispatcher* view_dispatcher;
  44. SceneManager* scene_manager;
  45. NotificationApp* notifications;
  46. DialogsApp* dialogs;
  47. Widget* widget;
  48. VariableItemList* var_item_list;
  49. TextInput* text_input;
  50. ByteInput* byte_input;
  51. Loading* loading;
  52. char bt_name_buf[FURI_HAL_BT_ADV_NAME_LENGTH];
  53. uint8_t bt_mac_buf[GAP_MAC_ADDR_SIZE];
  54. char usb_name_buf[32];
  55. uint16_t usb_vidpid_buf[2];
  56. BadKbAppError error;
  57. FuriString* file_path;
  58. FuriString* keyboard_layout;
  59. BadKb* bad_kb_view;
  60. BadKbScript* bad_kb_script;
  61. Bt* bt;
  62. bool is_bt;
  63. BadKbConfig config; // User options
  64. BadKbConfig id_config; // ID and BT_ID values
  65. bool set_bt_id;
  66. bool set_usb_id;
  67. bool has_bt_id;
  68. bool has_usb_id;
  69. FuriHalBleProfileBase* ble_hid;
  70. FuriHalUsbInterface* prev_usb_mode;
  71. BleProfileHidParams cur_ble_cfg;
  72. FuriHalUsbHidConfig* cur_usb_cfg;
  73. BadKbConnMode conn_mode;
  74. FuriThread* conn_init_thread;
  75. };
  76. typedef enum {
  77. BadKbAppViewWidget,
  78. BadKbAppViewWork,
  79. BadKbAppViewVarItemList,
  80. BadKbAppViewByteInput,
  81. BadKbAppViewTextInput,
  82. BadKbAppViewLoading,
  83. } BadKbAppView;
  84. void bad_kb_app_show_loading_popup(BadKbApp* app, bool show);
  85. void bad_kb_load_settings(BadKbApp* app);
  86. int32_t bad_kb_conn_apply(BadKbApp* app);
  87. void bad_kb_conn_reset(BadKbApp* app);
  88. void bad_kb_config_refresh(BadKbApp* app);
  89. void bad_kb_config_adjust(BadKbConfig* cfg);