Ivan Podogov 1 год назад
Родитель
Сommit
ac42fcbb13
3 измененных файлов с 13 добавлено и 8 удалено
  1. 1 0
      tracking/sensors/mean_filter.h
  2. 1 0
      tracking/sensors/median_filter.h
  3. 11 8
      views/bt_mouse.c

+ 1 - 0
tracking/sensors/mean_filter.h

@@ -17,6 +17,7 @@
 #define CARDBOARD_SDK_SENSORS_MEAN_FILTER_H_
 
 #include <deque>
+#include <cstddef>
 
 #include "../util/vector.h"
 

+ 1 - 0
tracking/sensors/median_filter.h

@@ -17,6 +17,7 @@
 #define CARDBOARD_SDK_SENSORS_MEDIAN_FILTER_H_
 
 #include <deque>
+#include <cstddef>
 
 #include "../util/vector.h"
 

+ 11 - 8
views/bt_mouse.c

@@ -3,8 +3,9 @@
 
 #include <furi.h>
 #include <furi_hal_bt.h>
-#include <furi_hal_bt_hid.h>
 #include <furi_hal_usb_hid.h>
+#include <profiles/serial_profile.h>
+#include <extra_profiles/hid_profile.h>
 #include <bt/bt_service/bt.h>
 #include <gui/elements.h>
 #include <notification/notification.h>
@@ -18,6 +19,7 @@ typedef struct ButtonEvent {
 #define BTN_EVT_QUEUE_SIZE 32
 
 struct BtMouse {
+    FuriHalBleProfileBase* hid;
     View* view;
     ViewDispatcher* view_dispatcher;
     Bt* bt;
@@ -118,7 +120,7 @@ static bool bt_mouse_input_callback(InputEvent* event, void* context) {
     bool consumed = false;
 
     if(event->type == InputTypeLong && event->key == InputKeyBack) {
-        furi_hal_bt_hid_mouse_release_all();
+        ble_profile_hid_mouse_release_all(bt_mouse->hid);
     } else {
         bt_mouse_process(bt_mouse, event);
         consumed = true;
@@ -203,18 +205,18 @@ static int32_t bt_mouse_thread_callback(void* context) {
 
             if(bt_mouse->connected && send_buttons) {
                 if(event.state) {
-                    furi_hal_bt_hid_mouse_press(event.button);
+                    ble_profile_hid_mouse_press(bt_mouse->hid, event.button);
                 } else {
-                    furi_hal_bt_hid_mouse_release(event.button);
+                    ble_profile_hid_mouse_release(bt_mouse->hid, event.button);
                 }
             }
 
             if(bt_mouse->connected && (dx != 0 || dy != 0)) {
-                furi_hal_bt_hid_mouse_move(dx, dy);
+                ble_profile_hid_mouse_move(bt_mouse->hid, dx, dy);
             }
 
             if(bt_mouse->connected && wheel != 0) {
-                furi_hal_bt_hid_mouse_scroll(wheel);
+                ble_profile_hid_mouse_scroll(bt_mouse->hid, wheel);
             }
         }
     }
@@ -253,7 +255,8 @@ void bt_mouse_enter_callback(void* context) {
     bt_mouse->notifications = furi_record_open(RECORD_NOTIFICATION);
     bt_set_status_changed_callback(
         bt_mouse->bt, bt_mouse_connection_status_changed_callback, bt_mouse);
-    furi_assert(bt_set_profile(bt_mouse->bt, BtProfileHidKeyboard));
+    bt_mouse->hid = bt_profile_start(bt_mouse->bt, ble_profile_hid, NULL);
+    furi_assert(bt_mouse->hid);
     furi_hal_bt_start_advertising();
     bt_mouse_thread_start(bt_mouse);
 }
@@ -279,7 +282,7 @@ void bt_mouse_exit_callback(void* context) {
     notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
 
     furi_hal_bt_stop_advertising();
-    bt_set_profile(bt_mouse->bt, BtProfileSerial);
+    bt_profile_restore_default(bt_mouse->bt);
 
     furi_record_close(RECORD_NOTIFICATION);
     bt_mouse->notifications = NULL;