7
7
8
8
enum HidDebugSubmenuIndex {
9
9
HidSubmenuIndexInstructions ,
10
+ HidSubmenuConfigure ,
10
11
HidSubmenuIndexClicker ,
11
12
HidSubmenuIndexCredits ,
12
13
};
@@ -23,6 +24,9 @@ static void hid_submenu_callback(void* context, uint32_t index) {
23
24
} else if (index == HidSubmenuIndexCredits ) {
24
25
app -> view_id = BtHidViewCredits ;
25
26
view_dispatcher_switch_to_view (app -> view_dispatcher , app -> view_id );
27
+ } else if (index == HidSubmenuConfigure ) {
28
+ app -> view_id = BtHidViewConfigure ;
29
+ view_dispatcher_switch_to_view (app -> view_dispatcher , app -> view_id );
26
30
}
27
31
}
28
32
@@ -70,6 +74,8 @@ Hid* hid_alloc() {
70
74
submenu_set_header (app -> submenu , "Cookie clicker" );
71
75
submenu_add_item (
72
76
app -> submenu , "Instructions" , HidSubmenuIndexInstructions , hid_submenu_callback , app );
77
+ submenu_add_item (
78
+ app -> submenu , "Configuration" , HidSubmenuConfigure , hid_submenu_callback , app );
73
79
submenu_add_item (
74
80
app -> submenu , "BT Phone Clicker" , HidSubmenuIndexClicker , hid_submenu_callback , app );
75
81
submenu_add_item (app -> submenu , "Credits" , HidSubmenuIndexCredits , hid_submenu_callback , app );
@@ -80,6 +86,44 @@ Hid* hid_alloc() {
80
86
return app ;
81
87
}
82
88
89
+ void hid_setting_changed (Hid * instance ) {
90
+ hid_cc_set_cursor_position (
91
+ instance -> hid_cc , instance -> offset_x , instance -> offset_y , instance -> offset_repeat );
92
+ }
93
+
94
+ void hid_setting_change_x (VariableItem * item ) {
95
+ FuriString * str = furi_string_alloc ();
96
+ Hid * instance = variable_item_get_context (item );
97
+ uint8_t index = variable_item_get_current_value_index (item );
98
+ instance -> offset_x = index * 10 ;
99
+ furi_string_cat_printf (str , "%d" , instance -> offset_x );
100
+ variable_item_set_current_value_text (item , furi_string_get_cstr (str ));
101
+ furi_string_free (str );
102
+ hid_setting_changed (instance );
103
+ }
104
+
105
+ void hid_setting_change_y (VariableItem * item ) {
106
+ FuriString * str = furi_string_alloc ();
107
+ Hid * instance = variable_item_get_context (item );
108
+ uint8_t index = variable_item_get_current_value_index (item );
109
+ instance -> offset_y = index * 10 ;
110
+ furi_string_cat_printf (str , "%d" , instance -> offset_y );
111
+ variable_item_set_current_value_text (item , furi_string_get_cstr (str ));
112
+ furi_string_free (str );
113
+ hid_setting_changed (instance );
114
+ }
115
+
116
+ void hid_setting_change_repeat (VariableItem * item ) {
117
+ FuriString * str = furi_string_alloc ();
118
+ Hid * instance = variable_item_get_context (item );
119
+ uint8_t index = variable_item_get_current_value_index (item );
120
+ instance -> offset_repeat = index + 1 ;
121
+ furi_string_cat_printf (str , "%d" , instance -> offset_repeat );
122
+ variable_item_set_current_value_text (item , furi_string_get_cstr (str ));
123
+ furi_string_free (str );
124
+ hid_setting_changed (instance );
125
+ }
126
+
83
127
Hid * hid_app_alloc_view (void * context ) {
84
128
furi_assert (context );
85
129
Hid * app = context ;
@@ -112,11 +156,38 @@ Hid* hid_app_alloc_view(void* context) {
112
156
"speed. Click the OK button on\n"
113
157
"the Flipper to enable/\n"
114
158
"disable the clicker.\n"
159
+ "Use the configuration setting\n"
160
+ "to change the location of the\n"
161
+ "clicking!\n"
115
162
"Enjoy!\n" );
116
163
view_set_previous_callback (widget_get_view (app -> widget_instructions ), hid_submenu_view );
117
164
view_dispatcher_add_view (
118
165
app -> view_dispatcher , BtHidViewInstructions , widget_get_view (app -> widget_instructions ));
119
166
167
+ app -> variable_item_list = variable_item_list_alloc ();
168
+ variable_item_list_reset (app -> variable_item_list );
169
+ VariableItem * item =
170
+ variable_item_list_add (app -> variable_item_list , "X offset" , 13 , hid_setting_change_x , app );
171
+ variable_item_set_current_value_index (item , 3 ); // 0,10,20,30,...
172
+ variable_item_set_current_value_text (item , "30" );
173
+ app -> offset_x = 10 ;
174
+ item =
175
+ variable_item_list_add (app -> variable_item_list , "Y offset" , 13 , hid_setting_change_y , app );
176
+ variable_item_set_current_value_index (item , 8 ); // 0,10,20,30,...
177
+ variable_item_set_current_value_text (item , "80" );
178
+ app -> offset_y = 100 ;
179
+ item = variable_item_list_add (
180
+ app -> variable_item_list , "Multiplier" , 20 , hid_setting_change_repeat , app );
181
+ variable_item_set_current_value_index (item , 2 ); // 1,2,3,4,...
182
+ variable_item_set_current_value_text (item , "3" );
183
+ app -> offset_repeat = 2 ;
184
+ view_set_previous_callback (
185
+ variable_item_list_get_view (app -> variable_item_list ), hid_submenu_view );
186
+ view_dispatcher_add_view (
187
+ app -> view_dispatcher ,
188
+ BtHidViewConfigure ,
189
+ variable_item_list_get_view (app -> variable_item_list ));
190
+
120
191
// Clicker view
121
192
app -> hid_cc = hid_cc_alloc (app );
122
193
view_set_previous_callback (hid_cc_get_view (app -> hid_cc ), hid_submenu_view );
@@ -157,6 +228,8 @@ void hid_free(Hid* app) {
157
228
hid_cc_free (app -> hid_cc );
158
229
view_dispatcher_remove_view (app -> view_dispatcher , BtHidViewCredits );
159
230
widget_free (app -> widget_credits );
231
+ view_dispatcher_remove_view (app -> view_dispatcher , BtHidViewConfigure );
232
+ variable_item_list_free (app -> variable_item_list );
160
233
view_dispatcher_remove_view (app -> view_dispatcher , BtHidViewInstructions );
161
234
widget_free (app -> widget_instructions );
162
235
view_dispatcher_remove_view (app -> view_dispatcher , HidViewSubmenu );
0 commit comments