From 91368a45388498c0c73be44f1afae2f8e6c705e5 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 19 Nov 2023 23:42:25 +0000 Subject: [PATCH] Format --- .../hex_viewer/helpers/hex_viewer_haptic.c | 9 +- .../hex_viewer/helpers/hex_viewer_haptic.h | 1 - .../hex_viewer/helpers/hex_viewer_led.c | 12 +- .../hex_viewer/helpers/hex_viewer_led.h | 1 - .../hex_viewer/helpers/hex_viewer_speaker.c | 5 +- .../scenes/hex_viewer_scene_settings.c | 22 +- applications/system/hid_app/views/hid_ptt.c | 190 ++++++++++-------- 7 files changed, 126 insertions(+), 114 deletions(-) diff --git a/applications/system/hex_viewer/helpers/hex_viewer_haptic.c b/applications/system/hex_viewer/helpers/hex_viewer_haptic.c index b23eabbf1..b3d230468 100644 --- a/applications/system/hex_viewer/helpers/hex_viewer_haptic.c +++ b/applications/system/hex_viewer/helpers/hex_viewer_haptic.c @@ -1,10 +1,9 @@ #include "hex_viewer_haptic.h" #include "../hex_viewer.h" - void hex_viewer_play_happy_bump(void* context) { HexViewer* app = context; - if (app->haptic != 1) { + if(app->haptic != 1) { return; } notification_message(app->notification, &sequence_set_vibro_on); @@ -14,7 +13,7 @@ void hex_viewer_play_happy_bump(void* context) { void hex_viewer_play_bad_bump(void* context) { HexViewer* app = context; - if (app->haptic != 1) { + if(app->haptic != 1) { return; } notification_message(app->notification, &sequence_set_vibro_on); @@ -24,10 +23,10 @@ void hex_viewer_play_bad_bump(void* context) { void hex_viewer_play_long_bump(void* context) { HexViewer* app = context; - if (app->haptic != 1) { + if(app->haptic != 1) { return; } - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) { notification_message(app->notification, &sequence_set_vibro_on); furi_thread_flags_wait(0, FuriFlagWaitAny, 50); notification_message(app->notification, &sequence_reset_vibro); diff --git a/applications/system/hex_viewer/helpers/hex_viewer_haptic.h b/applications/system/hex_viewer/helpers/hex_viewer_haptic.h index c9eccb17e..ade33bc78 100644 --- a/applications/system/hex_viewer/helpers/hex_viewer_haptic.h +++ b/applications/system/hex_viewer/helpers/hex_viewer_haptic.h @@ -5,4 +5,3 @@ void hex_viewer_play_happy_bump(void* context); void hex_viewer_play_bad_bump(void* context); void hex_viewer_play_long_bump(void* context); - diff --git a/applications/system/hex_viewer/helpers/hex_viewer_led.c b/applications/system/hex_viewer/helpers/hex_viewer_led.c index 454c3c414..d52fa5622 100644 --- a/applications/system/hex_viewer/helpers/hex_viewer_led.c +++ b/applications/system/hex_viewer/helpers/hex_viewer_led.c @@ -1,11 +1,9 @@ #include "hex_viewer_led.h" #include "../hex_viewer.h" - - void hex_viewer_led_set_rgb(void* context, int red, int green, int blue) { HexViewer* app = context; - if (app->led != 1) { + if(app->led != 1) { return; } NotificationMessage notification_led_message_1; @@ -26,7 +24,8 @@ void hex_viewer_led_set_rgb(void* context, int red, int green, int blue) { NULL, }; notification_message(app->notification, ¬ification_sequence); - furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set + furi_thread_flags_wait( + 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set } void hex_viewer_led_reset(void* context) { @@ -34,6 +33,7 @@ void hex_viewer_led_reset(void* context) { notification_message(app->notification, &sequence_reset_red); notification_message(app->notification, &sequence_reset_green); notification_message(app->notification, &sequence_reset_blue); - - furi_thread_flags_wait(0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set + + furi_thread_flags_wait( + 0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set } diff --git a/applications/system/hex_viewer/helpers/hex_viewer_led.h b/applications/system/hex_viewer/helpers/hex_viewer_led.h index 060749f0c..ba0e1cdad 100644 --- a/applications/system/hex_viewer/helpers/hex_viewer_led.h +++ b/applications/system/hex_viewer/helpers/hex_viewer_led.h @@ -3,4 +3,3 @@ void hex_viewer_led_set_rgb(void* context, int red, int green, int blue); void hex_viewer_led_reset(void* context); - diff --git a/applications/system/hex_viewer/helpers/hex_viewer_speaker.c b/applications/system/hex_viewer/helpers/hex_viewer_speaker.c index f834a565f..4ee3de8dc 100644 --- a/applications/system/hex_viewer/helpers/hex_viewer_speaker.c +++ b/applications/system/hex_viewer/helpers/hex_viewer_speaker.c @@ -5,19 +5,18 @@ void hex_viewer_play_input_sound(void* context) { HexViewer* app = context; - if (app->speaker != 1) { + if(app->speaker != 1) { return; } float volume = 1.0f; if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { furi_hal_speaker_start(NOTE_INPUT, volume); } - } void hex_viewer_stop_all_sound(void* context) { HexViewer* app = context; - if (app->speaker != 1) { + if(app->speaker != 1) { return; } if(furi_hal_speaker_is_mine()) { diff --git a/applications/system/hex_viewer/scenes/hex_viewer_scene_settings.c b/applications/system/hex_viewer/scenes/hex_viewer_scene_settings.c index f9c4cafbc..70a8b3a41 100644 --- a/applications/system/hex_viewer/scenes/hex_viewer_scene_settings.c +++ b/applications/system/hex_viewer/scenes/hex_viewer_scene_settings.c @@ -43,7 +43,6 @@ const uint32_t settings_value[2] = { HexViewerSettingsOn, }; - static void hex_viewer_scene_settings_set_haptic(VariableItem* item) { HexViewer* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -85,33 +84,21 @@ void hex_viewer_scene_settings_on_enter(void* context) { // Vibro on/off item = variable_item_list_add( - app->variable_item_list, - "Vibro/Haptic:", - 2, - hex_viewer_scene_settings_set_haptic, - app); + app->variable_item_list, "Vibro/Haptic:", 2, hex_viewer_scene_settings_set_haptic, app); value_index = value_index_uint32(app->haptic, haptic_value, 2); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, haptic_text[value_index]); // Sound on/off item = variable_item_list_add( - app->variable_item_list, - "Sound:", - 2, - hex_viewer_scene_settings_set_speaker, - app); + app->variable_item_list, "Sound:", 2, hex_viewer_scene_settings_set_speaker, app); value_index = value_index_uint32(app->speaker, speaker_value, 2); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, speaker_text[value_index]); // LED Effects on/off item = variable_item_list_add( - app->variable_item_list, - "LED FX:", - 2, - hex_viewer_scene_settings_set_led, - app); + app->variable_item_list, "LED FX:", 2, hex_viewer_scene_settings_set_led, app); value_index = value_index_uint32(app->led, led_value, 2); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, led_text[value_index]); @@ -126,7 +113,7 @@ void hex_viewer_scene_settings_on_enter(void* context) { value_index = value_index_uint32(app->save_settings, settings_value, 2); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, settings_text[value_index]); - + view_dispatcher_switch_to_view(app->view_dispatcher, HexViewerViewIdSettings); } @@ -135,7 +122,6 @@ bool hex_viewer_scene_settings_on_event(void* context, SceneManagerEvent event) UNUSED(app); bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { - } return consumed; } diff --git a/applications/system/hid_app/views/hid_ptt.c b/applications/system/hid_app/views/hid_ptt.c index 2506b55c8..3670cb219 100644 --- a/applications/system/hid_app/views/hid_ptt.c +++ b/applications/system/hid_app/views/hid_ptt.c @@ -68,11 +68,12 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { const uint8_t y_os = 88; const uint8_t x_os = 7; // elements_slightly_rounded_box(canvas, model->is_mac_os ? 0 : 26, y_os, model->is_mac_os ? 21 : 26, 11); - elements_slightly_rounded_box(canvas, model->is_mac_os ? x_os : x_os + 26, y_os, model->is_mac_os ? 21 : 26, 11); + elements_slightly_rounded_box( + canvas, model->is_mac_os ? x_os : x_os + 26, y_os, model->is_mac_os ? 21 : 26, 11); canvas_set_color(canvas, model->is_mac_os ? ColorWhite : ColorBlack); elements_multiline_text_aligned(canvas, x_os + 2, y_os + 1, AlignLeft, AlignTop, "Mac"); canvas_set_color(canvas, ColorBlack); - if (model->appIndex != HidPttAppIndexFaceTime) { + if(model->appIndex != HidPttAppIndexFaceTime) { elements_multiline_text_aligned(canvas, x_os + 23, y_os + 2, AlignLeft, AlignTop, "|"); canvas_set_color(canvas, model->is_mac_os ? ColorBlack : ColorWhite); elements_multiline_text_aligned(canvas, x_os + 28, y_os + 2, AlignLeft, AlignTop, "Linux"); @@ -83,7 +84,7 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { const uint8_t y_mic = 102; canvas_draw_icon(canvas, 19, y_mic - 1, &I_Pin_back_arrow_rotated_8x10); elements_multiline_text_aligned(canvas, 0, y_mic, AlignLeft, AlignTop, "Hold to sync"); - elements_multiline_text_aligned(canvas, 20, y_mic+10, AlignLeft, AlignTop, "mic status"); + elements_multiline_text_aligned(canvas, 20, y_mic + 10, AlignLeft, AlignTop, "mic status"); // Exit label canvas_draw_icon(canvas, 20, 121, &I_ButtonLeft_4x7); @@ -104,7 +105,7 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { canvas_set_color(canvas, ColorWhite); } if(model->ptt_pressed) { - if (model->appIndex != HidPttAppIndexFaceTime) { + if(model->appIndex != HidPttAppIndexFaceTime) { elements_multiline_text_aligned(canvas, x_2 + 4, y_1 + 5, AlignLeft, AlignTop, "OS"); } } else { @@ -125,13 +126,13 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { // Left canvas_draw_icon(canvas, x_1, y_2, &I_Button_18x18); - if(model->left_pressed) { + if(model->left_pressed) { elements_slightly_rounded_box(canvas, x_1 + 3, y_2 + 2, 13, 13); canvas_set_color(canvas, ColorWhite); } - if (model->ptt_pressed) { + if(model->ptt_pressed) { canvas_draw_icon(canvas, x_1 + 7, y_2 + 5, &I_ButtonLeft_4x7); - } else { + } else { canvas_draw_icon(canvas, x_1 + 4, y_2 + 5, &I_Pin_back_arrow_10x8); } canvas_set_color(canvas, ColorBlack); @@ -143,7 +144,7 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { canvas_set_color(canvas, ColorWhite); } if(!model->ptt_pressed) { - if (model->appIndex != HidPttAppIndexFaceTime) { + if(model->appIndex != HidPttAppIndexFaceTime) { canvas_draw_icon(canvas, x_3 + 11, y_2 + 5, &I_ButtonLeft_4x7); canvas_draw_box(canvas, x_3 + 4, y_2 + 5, 7, 7); } @@ -161,8 +162,8 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { } canvas_draw_icon(canvas, x_mic + 5, 0 + 4, &I_Mic_btn_8x10); if(model->muted && !model->ptt_pressed) { - canvas_draw_line(canvas, x_mic + 3, 2 , x_mic + 3 + 13, 2 + 13); - canvas_draw_line(canvas, x_mic + 2, 2 , x_mic + 2 + 13, 2 + 13); + canvas_draw_line(canvas, x_mic + 3, 2, x_mic + 3 + 13, 2 + 13); + canvas_draw_line(canvas, x_mic + 2, 2, x_mic + 2 + 13, 2 + 13); canvas_draw_line(canvas, x_mic + 3, 2 + 13, x_mic + 3 + 13, 2); canvas_draw_line(canvas, x_mic + 2, 2 + 13, x_mic + 2 + 13, 2); } @@ -172,102 +173,125 @@ static void hid_ptt_draw_callback(Canvas* canvas, void* context) { const uint8_t x_ptt_margin = 4; const uint8_t x_ptt_width = 17; const uint8_t x_ptt = x_1 + 19; - canvas_draw_icon(canvas, x_ptt , y_2 , &I_BtnFrameLeft_3x18); - canvas_draw_icon(canvas, x_ptt + x_ptt_width + 3 + x_ptt_margin, y_2 , &I_BtnFrameRight_2x18); - canvas_draw_line(canvas, x_ptt + 3 , y_2 , x_ptt + x_ptt_width + 2 + x_ptt_margin, y_2); - canvas_draw_line(canvas, x_ptt + 3 , y_2 + 16, x_ptt + x_ptt_width + 2 + x_ptt_margin, y_2 + 16); - canvas_draw_line(canvas, x_ptt + 3 , y_2 + 17, x_ptt + x_ptt_width + 2 + x_ptt_margin, y_2 + 17); + canvas_draw_icon(canvas, x_ptt, y_2, &I_BtnFrameLeft_3x18); + canvas_draw_icon(canvas, x_ptt + x_ptt_width + 3 + x_ptt_margin, y_2, &I_BtnFrameRight_2x18); + canvas_draw_line(canvas, x_ptt + 3, y_2, x_ptt + x_ptt_width + 2 + x_ptt_margin, y_2); + canvas_draw_line( + canvas, x_ptt + 3, y_2 + 16, x_ptt + x_ptt_width + 2 + x_ptt_margin, y_2 + 16); + canvas_draw_line( + canvas, x_ptt + 3, y_2 + 17, x_ptt + x_ptt_width + 2 + x_ptt_margin, y_2 + 17); if(model->ptt_pressed) { elements_slightly_rounded_box(canvas, x_ptt + 3, y_2 + 2, x_ptt_width + x_ptt_margin, 13); canvas_set_color(canvas, ColorWhite); } canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned(canvas, x_ptt + 2 + x_ptt_margin / 2, y_2 + 13, AlignLeft, AlignBottom, "PTT"); + elements_multiline_text_aligned( + canvas, x_ptt + 2 + x_ptt_margin / 2, y_2 + 13, AlignLeft, AlignBottom, "PTT"); canvas_set_font(canvas, FontSecondary); } -static void hid_ptt_trigger_mute(HidPtt* hid_ptt, HidPttModel * model) { +static void hid_ptt_trigger_mute(HidPtt* hid_ptt, HidPttModel* model) { if(model->appIndex == HidPttAppIndexGoogleMeet && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_D); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_D ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_D); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_D); } else if(model->appIndex == HidPttAppIndexGoogleMeet && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_D); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_D ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_D); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_D); } else if(model->appIndex == HidPttAppIndexZoom && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_A); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_A ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_A); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_A); } else if(model->appIndex == HidPttAppIndexFaceTime) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); } else if(model->appIndex == HidPttAppIndexSkype && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); } else if(model->appIndex == HidPttAppIndexSkype && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); } } -static void hid_ptt_trigger_camera(HidPtt* hid_ptt, HidPttModel * model) { +static void hid_ptt_trigger_camera(HidPtt* hid_ptt, HidPttModel* model) { if(model->appIndex == HidPttAppIndexGoogleMeet && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_E); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_E ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_E); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI | HID_KEYBOARD_E); } else if(model->appIndex == HidPttAppIndexGoogleMeet && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_E); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_E ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_E); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_E); } else if(model->appIndex == HidPttAppIndexZoom && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_V); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_V ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_V); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_V); } else if(model->appIndex == HidPttAppIndexZoom && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_ALT | HID_KEYBOARD_V); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_ALT | HID_KEYBOARD_V ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_ALT | HID_KEYBOARD_V); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_ALT | HID_KEYBOARD_V); } else if(model->appIndex == HidPttAppIndexSkype && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K); } else if(model->appIndex == HidPttAppIndexSkype && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_CTRL| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_CTRL | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_CTRL | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_K); } } -static void hid_ptt_start_ptt(HidPtt* hid_ptt, HidPttModel * model) { +static void hid_ptt_start_ptt(HidPtt* hid_ptt, HidPttModel* model) { if(model->appIndex == HidPttAppIndexGoogleMeet) { hid_hal_keyboard_press(hid_ptt->hid, HID_KEYBOARD_SPACEBAR); } else if(model->appIndex == HidPttAppIndexZoom) { hid_hal_keyboard_press(hid_ptt->hid, HID_KEYBOARD_SPACEBAR); } else if(model->appIndex == HidPttAppIndexFaceTime) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); } else if(model->appIndex == HidPttAppIndexSkype && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); } else if(model->appIndex == HidPttAppIndexSkype && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); } } -static void hid_ptt_stop_ptt(HidPtt* hid_ptt, HidPttModel * model) { +static void hid_ptt_stop_ptt(HidPtt* hid_ptt, HidPttModel* model) { if(model->appIndex == HidPttAppIndexGoogleMeet) { hid_hal_keyboard_release(hid_ptt->hid, HID_KEYBOARD_SPACEBAR); } else if(model->appIndex == HidPttAppIndexZoom) { hid_hal_keyboard_release(hid_ptt->hid, HID_KEYBOARD_SPACEBAR); } else if(model->appIndex == HidPttAppIndexFaceTime) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); } else if(model->appIndex == HidPttAppIndexSkype && model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_GUI| KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M ); + hid_hal_keyboard_press( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); + hid_hal_keyboard_release( + hid_ptt->hid, KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT | HID_KEYBOARD_M); } else if(model->appIndex == HidPttAppIndexSkype && !model->is_mac_os) { - hid_hal_keyboard_press( hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); - hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M ); + hid_hal_keyboard_press(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); + hid_hal_keyboard_release(hid_ptt->hid, KEY_MOD_LEFT_CTRL | HID_KEYBOARD_M); } } // Supports only ±1 -static void hid_ptt_shift_app(HidPttModel * model, int shift) { - int i = (short) model->appIndex; - if (i + shift >= HidPttAppIndexSize) { +static void hid_ptt_shift_app(HidPttModel* model, int shift) { + int i = (short)model->appIndex; + if(i + shift >= HidPttAppIndexSize) { model->appIndex = 0; } else if(i + shift <= 0) { model->appIndex = HidPttAppIndexSize - 1; @@ -275,7 +299,7 @@ static void hid_ptt_shift_app(HidPttModel * model, int shift) { model->appIndex += shift; } // Avoid showing facetime if not macos - if (model->appIndex == HidPttAppIndexFaceTime && !model->is_mac_os) { + if(model->appIndex == HidPttAppIndexFaceTime && !model->is_mac_os) { hid_ptt_shift_app(model, shift); } } @@ -288,37 +312,38 @@ static void hid_ptt_process(HidPtt* hid_ptt, InputEvent* event) { if(event->type == InputTypePress) { if(event->key == InputKeyUp) { model->up_pressed = true; - if (!model->ptt_pressed){ + if(!model->ptt_pressed) { hid_hal_consumer_key_press(hid_ptt->hid, HID_CONSUMER_VOLUME_INCREMENT); } else { - if (model->appIndex != HidPttAppIndexFaceTime) { + if(model->appIndex != HidPttAppIndexFaceTime) { model->is_mac_os = !model->is_mac_os; - notification_message(hid_ptt->hid->notifications, &sequence_single_vibro); + notification_message( + hid_ptt->hid->notifications, &sequence_single_vibro); } } } else if(event->key == InputKeyDown) { model->down_pressed = true; - if (!model->ptt_pressed){ + if(!model->ptt_pressed) { hid_hal_consumer_key_press(hid_ptt->hid, HID_CONSUMER_VOLUME_DECREMENT); } else { - hid_ptt_shift_app(model, - 1); + hid_ptt_shift_app(model, -1); notification_message(hid_ptt->hid->notifications, &sequence_single_vibro); } } else if(event->key == InputKeyLeft) { model->left_pressed = true; - if (model->ptt_pressed){ + if(model->ptt_pressed) { hid_ptt_shift_app(model, 1); notification_message(hid_ptt->hid->notifications, &sequence_single_vibro); } } else if(event->key == InputKeyRight) { model->right_pressed = true; - if (model->ptt_pressed){ - hid_ptt_shift_app(model, - 1); + if(model->ptt_pressed) { + hid_ptt_shift_app(model, -1); notification_message(hid_ptt->hid->notifications, &sequence_single_vibro); } } else if(event->key == InputKeyOk) { model->ptt_pressed = true; - if (model->muted) { + if(model->muted) { hid_ptt_start_ptt(hid_ptt, model); } } else if(event->key == InputKeyBack) { @@ -327,12 +352,12 @@ static void hid_ptt_process(HidPtt* hid_ptt, InputEvent* event) { } else if(event->type == InputTypeRelease) { if(event->key == InputKeyUp) { model->up_pressed = false; - if (!model->ptt_pressed){ + if(!model->ptt_pressed) { hid_hal_consumer_key_release(hid_ptt->hid, HID_CONSUMER_VOLUME_INCREMENT); } } else if(event->key == InputKeyDown) { model->down_pressed = false; - if (!model->ptt_pressed){ + if(!model->ptt_pressed) { hid_hal_consumer_key_release(hid_ptt->hid, HID_CONSUMER_VOLUME_DECREMENT); } } else if(event->key == InputKeyLeft) { @@ -342,7 +367,7 @@ static void hid_ptt_process(HidPtt* hid_ptt, InputEvent* event) { } else if(event->key == InputKeyOk) { model->ptt_pressed = false; - if (model->muted) { + if(model->muted) { hid_ptt_stop_ptt(hid_ptt, model); } else { hid_ptt_trigger_mute(hid_ptt, model); @@ -352,31 +377,33 @@ static void hid_ptt_process(HidPtt* hid_ptt, InputEvent* event) { model->mic_pressed = false; } } else if(event->type == InputTypeShort) { - if(event->key == InputKeyBack && !model->ptt_pressed ) { // no changes if PTT is pressed + if(event->key == InputKeyBack && + !model->ptt_pressed) { // no changes if PTT is pressed model->muted = !model->muted; hid_ptt_trigger_mute(hid_ptt, model); } else if(event->key == InputKeyRight) { - if (!model->ptt_pressed){ + if(!model->ptt_pressed) { hid_ptt_trigger_camera(hid_ptt, model); } } } else if(event->type == InputTypeLong) { if(event->key == InputKeyLeft) { model->left_pressed = false; - if (!model->ptt_pressed){ + if(!model->ptt_pressed) { hid_hal_keyboard_release_all(hid_ptt->hid); - view_dispatcher_switch_to_view(hid_ptt->hid->view_dispatcher, HidViewSubmenu); + view_dispatcher_switch_to_view( + hid_ptt->hid->view_dispatcher, HidViewSubmenu); // sequence_double_vibro to notify that we quit PTT notification_message(hid_ptt->hid->notifications, &sequence_double_vibro); } - } else if(event->key == InputKeyBack && !model->ptt_pressed ) { // no changes if PTT is pressed + } else if(event->key == InputKeyBack && !model->ptt_pressed) { // no changes if PTT is pressed // Change local mic status model->muted = !model->muted; notification_message(hid_ptt->hid->notifications, &sequence_single_vibro); } } //LED - if (model->muted && !model->ptt_pressed) { + if(model->muted && !model->ptt_pressed) { notification_message(hid_ptt->hid->notifications, &sequence_reset_red); } else { notification_message(hid_ptt->hid->notifications, &sequence_set_red_255); @@ -404,11 +431,14 @@ HidPtt* hid_ptt_alloc(Hid* hid) { view_set_orientation(hid_ptt->view, ViewOrientationVerticalFlip); with_view_model( - hid_ptt->view, HidPttModel * model, { + hid_ptt->view, + HidPttModel * model, + { model->transport = hid->transport; model->muted = true; // assume we're muted model->is_mac_os = true; - }, true); + }, + true); return hid_ptt; }