Skip to content

Commit 56aa9a9

Browse files
committed
Fix compatibility with new firmwares
1 parent e6120e5 commit 56aa9a9

File tree

6 files changed

+31
-38
lines changed

6 files changed

+31
-38
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.3 (2024-08-15)
4+
5+
**Fix new firmwares compatibility**
6+
37
## v1.2 (2024-06-05)
48

59
**Support multiple IMU models**

air_mouse.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ AirMouse* air_mouse_app_alloc() {
6161

6262
// View dispatcher
6363
app->view_dispatcher = view_dispatcher_alloc();
64-
view_dispatcher_enable_queue(app->view_dispatcher);
6564
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
6665

6766
// Submenu view
@@ -126,6 +125,8 @@ AirMouse* air_mouse_app_alloc() {
126125
app->view_id = AirMouseViewSubmenu;
127126
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);
128127

128+
view_dispatcher_set_tick_event_callback(app->view_dispatcher, NULL, furi_ms_to_ticks(10));
129+
129130
return app;
130131
}
131132

application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ App(
66
stack_size=10 * 1024,
77
fap_category="GPIO",
88
fap_icon="icon.png",
9-
fap_version="1.2",
9+
fap_version="1.3",
1010
fap_libs=["ble_profile"],
1111
sources=["*.c", "*.cc"],
1212
fap_private_libs=[

build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

views/bt_mouse.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ void bt_mouse_connection_status_changed_callback(BtStatus status, void* context)
150150
if(bt_mouse->connected) {
151151
notification_internal_message(bt_mouse->notifications, &sequence_set_blue_255);
152152
tracking_begin();
153-
view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
154153
} else {
155154
tracking_end();
156155
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
@@ -255,6 +254,11 @@ void bt_mouse_thread_stop(BtMouse* bt_mouse) {
255254
bt_mouse->thread = NULL;
256255
}
257256

257+
void bt_mouse_tick_event_callback(void* context) {
258+
furi_assert(context);
259+
tracking_step(bt_mouse_move, context);
260+
}
261+
258262
void bt_mouse_enter_callback(void* context) {
259263
furi_assert(context);
260264
BtMouse* bt_mouse = context;
@@ -272,6 +276,9 @@ void bt_mouse_enter_callback(void* context) {
272276
furi_assert(bt_mouse->hid);
273277
furi_hal_bt_start_advertising();
274278
bt_mouse_thread_start(bt_mouse);
279+
280+
view_dispatcher_set_event_callback_context(bt_mouse->view_dispatcher, bt_mouse);
281+
view_dispatcher_set_tick_event_callback(bt_mouse->view_dispatcher, bt_mouse_tick_event_callback, furi_ms_to_ticks(10));
275282
}
276283

277284
void bt_mouse_remove_pairing(void) {
@@ -291,22 +298,12 @@ void bt_mouse_remove_pairing(void) {
291298
furi_record_close(RECORD_BT);
292299
}
293300

294-
bool bt_mouse_custom_callback(uint32_t event, void* context) {
295-
UNUSED(event);
296-
furi_assert(context);
297-
BtMouse* bt_mouse = context;
298-
299-
tracking_step(bt_mouse_move, context);
300-
furi_delay_ms(3); // Magic! Removing this will break the buttons
301-
302-
view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
303-
return true;
304-
}
305-
306301
void bt_mouse_exit_callback(void* context) {
307302
furi_assert(context);
308303
BtMouse* bt_mouse = context;
309304

305+
view_dispatcher_set_tick_event_callback(bt_mouse->view_dispatcher, NULL, FuriWaitForever);
306+
310307
bt_mouse_thread_stop(bt_mouse);
311308
tracking_end();
312309
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
@@ -336,7 +333,6 @@ BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) {
336333
view_set_draw_callback(bt_mouse->view, bt_mouse_draw_callback);
337334
view_set_input_callback(bt_mouse->view, bt_mouse_input_callback);
338335
view_set_enter_callback(bt_mouse->view, bt_mouse_enter_callback);
339-
view_set_custom_callback(bt_mouse->view, bt_mouse_custom_callback);
340336
view_set_exit_callback(bt_mouse->view, bt_mouse_exit_callback);
341337
return bt_mouse;
342338
}

views/usb_mouse.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ static bool usb_mouse_input_callback(InputEvent* event, void* context) {
7575
return consumed;
7676
}
7777

78+
bool usb_mouse_move(int8_t dx, int8_t dy, void* context) {
79+
UNUSED(context);
80+
return furi_hal_hid_mouse_move(dx, dy);
81+
}
82+
83+
void usb_mouse_tick_event_callback(void* context) {
84+
furi_assert(context);
85+
tracking_step(usb_mouse_move, context);
86+
}
87+
7888
void usb_mouse_enter_callback(void* context) {
7989
furi_assert(context);
8090
UsbMouse* usb_mouse = context;
@@ -85,30 +95,16 @@ void usb_mouse_enter_callback(void* context) {
8595

8696
tracking_begin();
8797

88-
view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0);
89-
}
90-
91-
bool usb_mouse_move(int8_t dx, int8_t dy, void* context) {
92-
UNUSED(context);
93-
return furi_hal_hid_mouse_move(dx, dy);
94-
}
95-
96-
bool usb_mouse_custom_callback(uint32_t event, void* context) {
97-
UNUSED(event);
98-
furi_assert(context);
99-
UsbMouse* usb_mouse = context;
100-
101-
tracking_step(usb_mouse_move, context);
102-
furi_delay_ms(3); // Magic! Removing this will break the buttons
103-
104-
view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0);
105-
return true;
98+
view_dispatcher_set_event_callback_context(usb_mouse->view_dispatcher, usb_mouse);
99+
view_dispatcher_set_tick_event_callback(usb_mouse->view_dispatcher, usb_mouse_tick_event_callback, furi_ms_to_ticks(10));
106100
}
107101

108102
void usb_mouse_exit_callback(void* context) {
109103
furi_assert(context);
110104
UsbMouse* usb_mouse = context;
111105

106+
view_dispatcher_set_tick_event_callback(usb_mouse->view_dispatcher, NULL, FuriWaitForever);
107+
112108
tracking_end();
113109

114110
furi_hal_usb_set_config(usb_mouse->usb_mode_prev, NULL);
@@ -122,7 +118,6 @@ UsbMouse* usb_mouse_alloc(ViewDispatcher* view_dispatcher) {
122118
view_set_draw_callback(usb_mouse->view, usb_mouse_draw_callback);
123119
view_set_input_callback(usb_mouse->view, usb_mouse_input_callback);
124120
view_set_enter_callback(usb_mouse->view, usb_mouse_enter_callback);
125-
view_set_custom_callback(usb_mouse->view, usb_mouse_custom_callback);
126121
view_set_exit_callback(usb_mouse->view, usb_mouse_exit_callback);
127122
return usb_mouse;
128123
}

0 commit comments

Comments
 (0)