From 052f4f8679e19a0627b9c3e8732c01589ba1b9af Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Sun, 11 Jun 2023 15:16:07 -0500 Subject: [PATCH] fix initialization. add speed. --- .../.flipcorg/gallery/configure.png | Bin 8601 -> 9792 bytes hid/hid_cookie/hid.c | 33 ++++++++++++--- hid/hid_cookie/hid.h | 1 + hid/hid_cookie/views/hid_cc.c | 38 ++++++++++-------- hid/hid_cookie/views/hid_cc.h | 2 +- 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/hid/hid_cookie/.flipcorg/gallery/configure.png b/hid/hid_cookie/.flipcorg/gallery/configure.png index d27d6a55c008922e9068b272caf789800e56b8c8..843c882ea99fef14b1974a79f5082bf827077044 100644 GIT binary patch literal 9792 zcmbtacU+U#8jjT~ZLOlU3Rr};RH?FBKtUlyYZVtzK|ryO5U>p$N1 zF$@M#z2ZL=7hyJX>3{N}3U^~diemHpgvi&5L5#tyXtoWKnABYGE(day`RkiNt z2JQF{q($|zwC0`enI9CVZ}f>?Q&{X$wqvp_a3p!3((@|kjB{leki@KlTK6 zz6*yo>2l3<4Y}o~+~-s>S+C(0XYOHd`3c8NHHs)Zktw@joYB&o-_ z*z=7Jmf1P0z^3BtCpXD?BdYFLm?#)I?>FpBn2IhA8FZ=4L~7^C$3%l6kI!ib41}Aev>9XGA?%{h}Vr+dj^tM|otHiYwmM+R8%s5%j}cualYd zPE6j`W}1guyGdR=dM1MZ;A&(y)*z1Ot$XSh8SX%Eb?9ec>#FR#jfku+5S9PD}k}FGMYme^BOysNw}Sgnzo*A$mJ}!9Wy|WGVy|wyl~Nr)6*>bHmt{k z?i9Do*mSFLh33v*eW9b=fK|brEQ@z1u?M?&;qf{oOjuz00*N|&u8t_k#@?r&G@bTC zu9agFnEpI!8O{8;d6Z&f=jSG6o%l=&eZXw;d6(xF@SunJ!AcJ@)x9$^?R!qr&@YdK z%=6Tb)y5eLd6{%#=;-`Rrd9C8Q~M0-C|wqv-o)WH|N1UPiwfj}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sSmTB%X|y|W?V zy`MfCD@QtwXB0#!1MU*W8*sci&>O8^ib^PcDG(ULkE}(y!4k-BV-gsysS>J+;EVqoXV)(D{d_#l|F*4|Pc{jslCOgok_Td*IL*gnc*AQD*3-3eS?rG1W-f5Qj3f7$+UaBG13P+n$=ficx76aUCsd|U} zX`V<5g1xoeI6(FM{+cDqvoFAou!6d|^F&lKA_$8{?>T8T#blt<&lniYW^h`_fzP!o z;F}vyfcIrjglB=7p9SJ{_6GUd2eUSJ-u$rxCGK-9uzh$D z`%Q&gkRn~pAq3T;cwn;;vBT2W4P56Vhm#m7nxPbOfqwz22E8%=q)3W~bykK30m~qG ze@jod%Da(QXmiLSV~v^=W=zFOYWD6bYvk565^&tpY<^#{T(~Y$EllDx#7;XVO_>LE zzKPg(c0e-=FmT&TX|PT#0WLj>fmCmmJXA^ZA27quItGvL|3U0a>a>dIkzJOiE}|B* z{Zt}v!VDyCuxD>S#?z@3fmQT)M2i12_#$xG~ zI?X^X!U--2wDD1)vPBmCYcJu&_314SY65GU^73cgSvNRx4{D55NNJorp&@Phc^9uj z@bs`)(i03BBX04p>N&XEZtccN)slqd^>nIWA&Qa!)N&0@u(F1l>*56bspart=)F; EzfN3WmjD0& diff --git a/hid/hid_cookie/hid.c b/hid/hid_cookie/hid.c index 7caace5..eb72a04 100644 --- a/hid/hid_cookie/hid.c +++ b/hid/hid_cookie/hid.c @@ -88,7 +88,11 @@ Hid* hid_alloc() { void hid_setting_changed(Hid* instance) { hid_cc_set_cursor_position( - instance->hid_cc, instance->offset_x, instance->offset_y, instance->offset_repeat); + instance->hid_cc, + instance->offset_x, + instance->offset_y, + instance->offset_repeat, + instance->offset_speed); } void hid_setting_change_x(VariableItem* item) { @@ -124,6 +128,17 @@ void hid_setting_change_repeat(VariableItem* item) { hid_setting_changed(instance); } +void hid_setting_change_speed(VariableItem* item) { + FuriString* str = furi_string_alloc(); + Hid* instance = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + instance->offset_speed = index * 10 + 1; + furi_string_cat_printf(str, "%d", instance->offset_speed); + variable_item_set_current_value_text(item, furi_string_get_cstr(str)); + furi_string_free(str); + hid_setting_changed(instance); +} + Hid* hid_app_alloc_view(void* context) { furi_assert(context); Hid* app = context; @@ -168,19 +183,24 @@ Hid* hid_app_alloc_view(void* context) { variable_item_list_reset(app->variable_item_list); VariableItem* item = variable_item_list_add(app->variable_item_list, "X offset", 13, hid_setting_change_x, app); - variable_item_set_current_value_index(item, 3); // 0,10,20,30,... - variable_item_set_current_value_text(item, "30"); - app->offset_x = 10; + variable_item_set_current_value_index(item, 5); // 0,10,20,30,... + variable_item_set_current_value_text(item, "40"); + app->offset_x = 40; item = variable_item_list_add(app->variable_item_list, "Y offset", 13, hid_setting_change_y, app); variable_item_set_current_value_index(item, 8); // 0,10,20,30,... variable_item_set_current_value_text(item, "80"); - app->offset_y = 100; + app->offset_y = 80; item = variable_item_list_add( app->variable_item_list, "Multiplier", 20, hid_setting_change_repeat, app); variable_item_set_current_value_index(item, 2); // 1,2,3,4,... variable_item_set_current_value_text(item, "3"); - app->offset_repeat = 2; + app->offset_repeat = 3; + item = variable_item_list_add( + app->variable_item_list, "CursorSpeed", 50, hid_setting_change_speed, app); + variable_item_set_current_value_index(item, 5); // 1,2,3,4,... + variable_item_set_current_value_text(item, "50"); + app->offset_speed = 50; view_set_previous_callback( variable_item_list_get_view(app->variable_item_list), hid_submenu_view); view_dispatcher_add_view( @@ -192,6 +212,7 @@ Hid* hid_app_alloc_view(void* context) { app->hid_cc = hid_cc_alloc(app); view_set_previous_callback(hid_cc_get_view(app->hid_cc), hid_submenu_view); view_dispatcher_add_view(app->view_dispatcher, BtHidViewClicker, hid_cc_get_view(app->hid_cc)); + hid_setting_changed(app); // Credits view app->widget_credits = widget_alloc(); diff --git a/hid/hid_cookie/hid.h b/hid/hid_cookie/hid.h index b4bc5fe..acb96c8 100644 --- a/hid/hid_cookie/hid.h +++ b/hid/hid_cookie/hid.h @@ -36,6 +36,7 @@ struct Hid { HidCC* hid_cc; uint32_t view_id; uint8_t offset_repeat; + uint8_t offset_speed; uint8_t offset_x; uint8_t offset_y; }; diff --git a/hid/hid_cookie/views/hid_cc.c b/hid/hid_cookie/views/hid_cc.c index 31976e9..989a193 100644 --- a/hid/hid_cookie/views/hid_cc.c +++ b/hid/hid_cookie/views/hid_cc.c @@ -20,9 +20,10 @@ typedef struct { bool is_cursor_set; float timer_duration; bool timer_click_enabled; - uint8_t click_x; - uint8_t click_y; - uint8_t click_loop; + uint8_t move_x; + uint8_t move_y; + uint8_t move_loop; + uint8_t move_speed; } HidCCModel; static void hid_cc_draw_callback(Canvas* canvas, void* context) { @@ -111,21 +112,23 @@ static void hid_cc_tick_callback(void* context) { } static void hid_cc_reset_cursor(HidCC* hid_cc) { - // Set cursor to the phone's left up corner - // Delays to guarantee one packet per connection interval - for(size_t i = 0; i < 8; i++) { - hid_hal_mouse_move(hid_cc->hid, -127, -127); - furi_delay_ms(50); - } - + FURI_LOG_I("HID", "Reset cursor!"); // Move cursor from the corner with_view_model( hid_cc->view, HidCCModel * model, { - for(size_t i = 0; i < model->click_loop; i++) { - hid_hal_mouse_move(hid_cc->hid, model->click_x, model->click_y); - furi_delay_ms(50); + // Set cursor to the phone's left up corner + // Delays to guarantee one packet per connection interval + for(size_t i = 0; i < 20; i++) { + hid_hal_mouse_move(hid_cc->hid, -127, -127); + furi_delay_ms(model->move_speed); + } + + FURI_LOG_I("HID", "%d %d", model->move_x, model->move_y); + for(size_t i = 0; i < model->move_loop; i++) { + hid_hal_mouse_move(hid_cc->hid, model->move_x, model->move_y); + furi_delay_ms(model->move_speed); } }, true); @@ -207,15 +210,16 @@ static bool hid_cc_input_callback(InputEvent* event, void* context) { return consumed; } -void hid_cc_set_cursor_position(HidCC* hid_cc, uint8_t x, uint8_t y, uint8_t repeat) { +void hid_cc_set_cursor_position(HidCC* hid_cc, uint8_t x, uint8_t y, uint8_t repeat, uint8_t speed) { furi_assert(hid_cc); with_view_model( hid_cc->view, HidCCModel * model, { - model->click_x = x; - model->click_y = y; - model->click_loop = repeat; + model->move_x = x; + model->move_y = y; + model->move_loop = repeat; + model->move_speed = speed; }, true); } diff --git a/hid/hid_cookie/views/hid_cc.h b/hid/hid_cookie/views/hid_cc.h index 3f19494..3f0f952 100644 --- a/hid/hid_cookie/views/hid_cc.h +++ b/hid/hid_cookie/views/hid_cc.h @@ -13,4 +13,4 @@ View* hid_cc_get_view(HidCC* hid_cc); void hid_cc_set_connected_status(HidCC* hid_cc, bool connected); -void hid_cc_set_cursor_position(HidCC* hid_cc, uint8_t x, uint8_t y, uint8_t repeat); \ No newline at end of file +void hid_cc_set_cursor_position(HidCC* hid_cc, uint8_t x, uint8_t y, uint8_t repeat, uint8_t speed); \ No newline at end of file