Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
SubGhz Back to exit, Battery on power off menu, Acceleration for BT/U…
Browse files Browse the repository at this point in the history
…SB Mouse (#428)
  • Loading branch information
Willy-JL authored Oct 24, 2023
2 parents 4bbdbcf + 5d368f2 commit 3102b77
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void power_settings_scene_power_off_on_enter(void* context) {
dialog, " I will be\nwaiting for\n you here", 78, 16, AlignLeft, AlignTop);
}
dialog_ex_set_icon(dialog, 21, 13, &I_Cry_dolph_55x52);
dialog_ex_set_left_button_text(dialog, "Back");
dialog_ex_set_left_button_text(dialog, "Battery");
dialog_ex_set_right_button_text(dialog, "OFF");
dialog_ex_set_result_callback(dialog, power_settings_scene_power_off_dialog_callback);
dialog_ex_set_context(dialog, app);
Expand All @@ -34,10 +34,7 @@ bool power_settings_scene_power_off_on_event(void* context, SceneManagerEvent ev

if(event.type == SceneManagerEventTypeCustom) {
if(event.event == DialogExResultLeft) {
if(!scene_manager_previous_scene(app->scene_manager)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
}
scene_manager_next_scene(app->scene_manager, PowerSettingsAppSceneBatteryInfo);
} else if(event.event == DialogExResultRight) {
power_off(app->power);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ static bool battery_info_input_callback(InputEvent* event, void* context) {

BatteryInfo* battery_info = context;

if(event->type == InputTypeShort) {
bool about_battery;
with_view_model(
battery_info->view, BatteryInfoModel * model, { about_battery = model->alt; }, false);
if(about_battery && event->type == InputTypeShort) {
if(event->key == InputKeyLeft) {
event->key = InputKeyBack;
} else if(event->key == InputKeyRight) {
Expand Down
19 changes: 15 additions & 4 deletions applications/system/hid_app/views/hid_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef struct {
bool left_mouse_held;
bool right_mouse_pressed;
bool connected;
uint8_t acceleration;
HidTransport transport;
} HidMouseModel;

Expand Down Expand Up @@ -119,6 +120,11 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
hid_mouse->view,
HidMouseModel * model,
{
model->acceleration = (event->type == InputTypePress) ? 1 :
(event->type == InputTypeRelease) ? 0 :
(model->acceleration >= 20) ? 20 :
model->acceleration + 1;

if(event->key == InputKeyBack) {
if(event->type == InputTypeShort) {
hid_hal_mouse_press(hid_mouse->hid, HID_MOUSE_BTN_RIGHT);
Expand Down Expand Up @@ -150,7 +156,8 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->right_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_SHORT, 0);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_LONG, 0);
for(uint8_t i = model->acceleration; i > 1; i -= 2)
hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_LONG, 0);
} else if(event->type == InputTypeRelease) {
model->right_pressed = false;
}
Expand All @@ -159,7 +166,8 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->left_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_SHORT, 0);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_LONG, 0);
for(uint8_t i = model->acceleration; i > 1; i -= 2)
hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_LONG, 0);
} else if(event->type == InputTypeRelease) {
model->left_pressed = false;
}
Expand All @@ -168,7 +176,9 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->down_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_SHORT);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_LONG);
for(uint8_t i = model->acceleration; i > 1; i -= 2)
hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_LONG);

} else if(event->type == InputTypeRelease) {
model->down_pressed = false;
}
Expand All @@ -177,7 +187,8 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->up_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_SHORT);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_LONG);
for(uint8_t i = model->acceleration; i > 1; i -= 2)
hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_LONG);
} else if(event->type == InputTypeRelease) {
model->up_pressed = false;
}
Expand Down
27 changes: 18 additions & 9 deletions applications/system/subghz_remote/views/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,30 @@ bool subrem_view_remote_input(InputEvent* event, void* context) {
furi_assert(context);
SubRemViewRemote* subrem_view_remote = context;

if(event->key == InputKeyBack && event->type == InputTypeLong) {
subrem_view_remote->callback(SubRemCustomEventViewRemoteBack, subrem_view_remote->context);
return true;
} else if(event->key == InputKeyBack && event->type == InputTypeShort) {
if(event->key == InputKeyBack && event->type == InputTypePress) {
bool is_stopping = false;
with_view_model(
subrem_view_remote->view,
SubRemViewRemoteModel * model,
{ model->pressed_btn = 0; },
{
if(model->state == SubRemViewRemoteStateSending) {
is_stopping = true;
model->pressed_btn = 0;
}
},
true);
subrem_view_remote->callback(
SubRemCustomEventViewRemoteForcedStop, subrem_view_remote->context);
return true;
} else if(event->key == InputKeyBack) {

//Cant send exit the app inside that with_model,locks the model and the app will hang and not unload!
if(is_stopping)
subrem_view_remote->callback(
SubRemCustomEventViewRemoteForcedStop, subrem_view_remote->context);
else
subrem_view_remote->callback(
SubRemCustomEventViewRemoteBack, subrem_view_remote->context);

return true;
}

// BACK button processing end

if(event->key == InputKeyUp && event->type == InputTypePress) {
Expand Down

0 comments on commit 3102b77

Please sign in to comment.