Skip to content

Commit

Permalink
Fix compatibility with new firmwares
Browse files Browse the repository at this point in the history
  • Loading branch information
ginkage committed Aug 15, 2024
1 parent e6120e5 commit 56aa9a9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.3 (2024-08-15)

**Fix new firmwares compatibility**

## v1.2 (2024-06-05)

**Support multiple IMU models**
Expand Down
3 changes: 2 additions & 1 deletion air_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ AirMouse* air_mouse_app_alloc() {

// View dispatcher
app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(app->view_dispatcher);
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

// Submenu view
Expand Down Expand Up @@ -126,6 +125,8 @@ AirMouse* air_mouse_app_alloc() {
app->view_id = AirMouseViewSubmenu;
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);

view_dispatcher_set_tick_event_callback(app->view_dispatcher, NULL, furi_ms_to_ticks(10));

return app;
}

Expand Down
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ App(
stack_size=10 * 1024,
fap_category="GPIO",
fap_icon="icon.png",
fap_version="1.2",
fap_version="1.3",
fap_libs=["ble_profile"],
sources=["*.c", "*.cc"],
fap_private_libs=[
Expand Down
3 changes: 0 additions & 3 deletions build.sh

This file was deleted.

24 changes: 10 additions & 14 deletions views/bt_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ void bt_mouse_connection_status_changed_callback(BtStatus status, void* context)
if(bt_mouse->connected) {
notification_internal_message(bt_mouse->notifications, &sequence_set_blue_255);
tracking_begin();
view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
} else {
tracking_end();
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
Expand Down Expand Up @@ -255,6 +254,11 @@ void bt_mouse_thread_stop(BtMouse* bt_mouse) {
bt_mouse->thread = NULL;
}

void bt_mouse_tick_event_callback(void* context) {
furi_assert(context);
tracking_step(bt_mouse_move, context);
}

void bt_mouse_enter_callback(void* context) {
furi_assert(context);
BtMouse* bt_mouse = context;
Expand All @@ -272,6 +276,9 @@ void bt_mouse_enter_callback(void* context) {
furi_assert(bt_mouse->hid);
furi_hal_bt_start_advertising();
bt_mouse_thread_start(bt_mouse);

view_dispatcher_set_event_callback_context(bt_mouse->view_dispatcher, bt_mouse);
view_dispatcher_set_tick_event_callback(bt_mouse->view_dispatcher, bt_mouse_tick_event_callback, furi_ms_to_ticks(10));
}

void bt_mouse_remove_pairing(void) {
Expand All @@ -291,22 +298,12 @@ void bt_mouse_remove_pairing(void) {
furi_record_close(RECORD_BT);
}

bool bt_mouse_custom_callback(uint32_t event, void* context) {
UNUSED(event);
furi_assert(context);
BtMouse* bt_mouse = context;

tracking_step(bt_mouse_move, context);
furi_delay_ms(3); // Magic! Removing this will break the buttons

view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
return true;
}

void bt_mouse_exit_callback(void* context) {
furi_assert(context);
BtMouse* bt_mouse = context;

view_dispatcher_set_tick_event_callback(bt_mouse->view_dispatcher, NULL, FuriWaitForever);

bt_mouse_thread_stop(bt_mouse);
tracking_end();
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
Expand Down Expand Up @@ -336,7 +333,6 @@ BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) {
view_set_draw_callback(bt_mouse->view, bt_mouse_draw_callback);
view_set_input_callback(bt_mouse->view, bt_mouse_input_callback);
view_set_enter_callback(bt_mouse->view, bt_mouse_enter_callback);
view_set_custom_callback(bt_mouse->view, bt_mouse_custom_callback);
view_set_exit_callback(bt_mouse->view, bt_mouse_exit_callback);
return bt_mouse;
}
Expand Down
33 changes: 14 additions & 19 deletions views/usb_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ static bool usb_mouse_input_callback(InputEvent* event, void* context) {
return consumed;
}

bool usb_mouse_move(int8_t dx, int8_t dy, void* context) {
UNUSED(context);
return furi_hal_hid_mouse_move(dx, dy);
}

void usb_mouse_tick_event_callback(void* context) {
furi_assert(context);
tracking_step(usb_mouse_move, context);
}

void usb_mouse_enter_callback(void* context) {
furi_assert(context);
UsbMouse* usb_mouse = context;
Expand All @@ -85,30 +95,16 @@ void usb_mouse_enter_callback(void* context) {

tracking_begin();

view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0);
}

bool usb_mouse_move(int8_t dx, int8_t dy, void* context) {
UNUSED(context);
return furi_hal_hid_mouse_move(dx, dy);
}

bool usb_mouse_custom_callback(uint32_t event, void* context) {
UNUSED(event);
furi_assert(context);
UsbMouse* usb_mouse = context;

tracking_step(usb_mouse_move, context);
furi_delay_ms(3); // Magic! Removing this will break the buttons

view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0);
return true;
view_dispatcher_set_event_callback_context(usb_mouse->view_dispatcher, usb_mouse);
view_dispatcher_set_tick_event_callback(usb_mouse->view_dispatcher, usb_mouse_tick_event_callback, furi_ms_to_ticks(10));
}

void usb_mouse_exit_callback(void* context) {
furi_assert(context);
UsbMouse* usb_mouse = context;

view_dispatcher_set_tick_event_callback(usb_mouse->view_dispatcher, NULL, FuriWaitForever);

tracking_end();

furi_hal_usb_set_config(usb_mouse->usb_mode_prev, NULL);
Expand All @@ -122,7 +118,6 @@ UsbMouse* usb_mouse_alloc(ViewDispatcher* view_dispatcher) {
view_set_draw_callback(usb_mouse->view, usb_mouse_draw_callback);
view_set_input_callback(usb_mouse->view, usb_mouse_input_callback);
view_set_enter_callback(usb_mouse->view, usb_mouse_enter_callback);
view_set_custom_callback(usb_mouse->view, usb_mouse_custom_callback);
view_set_exit_callback(usb_mouse->view, usb_mouse_exit_callback);
return usb_mouse;
}
Expand Down

0 comments on commit 56aa9a9

Please sign in to comment.