@@ -48,14 +48,26 @@ static int32_t ducky_fnc_strdelay(BadKbScript* bad_kb, const char* line, int32_t
48
48
return 0 ;
49
49
}
50
50
51
+ static int32_t ducky_fnc_defstrdelay (BadKbScript * bad_kb , const char * line , int32_t param ) {
52
+ UNUSED (param );
53
+
54
+ line = & line [ducky_get_command_len (line ) + 1 ];
55
+ bool state = ducky_get_number (line , & bad_kb -> defstringdelay );
56
+ if (!state ) {
57
+ return ducky_error (bad_kb , "Invalid number %s" , line );
58
+ }
59
+ return 0 ;
60
+ }
61
+
51
62
static int32_t ducky_fnc_string (BadKbScript * bad_kb , const char * line , int32_t param ) {
52
63
line = & line [ducky_get_command_len (line ) + 1 ];
53
64
furi_string_set_str (bad_kb -> string_print , line );
54
65
if (param == 1 ) {
55
66
furi_string_cat (bad_kb -> string_print , "\n" );
56
67
}
57
68
58
- if (bad_kb -> stringdelay == 0 ) { // stringdelay not set - run command immediately
69
+ if (bad_kb -> stringdelay == 0 &&
70
+ bad_kb -> defstringdelay == 0 ) { // stringdelay not set - run command immediately
59
71
bool state = ducky_string (bad_kb , furi_string_get_cstr (bad_kb -> string_print ));
60
72
if (!state ) {
61
73
return ducky_error (bad_kb , "Invalid string %s" , line );
@@ -161,6 +173,49 @@ static int32_t ducky_fnc_release(BadKbScript* bad_kb, const char* line, int32_t
161
173
return 0 ;
162
174
}
163
175
176
+ static int32_t ducky_fnc_media (BadKbScript * bad_kb , const char * line , int32_t param ) {
177
+ UNUSED (param );
178
+
179
+ line = & line [ducky_get_command_len (line ) + 1 ];
180
+ uint16_t key = ducky_get_media_keycode_by_name (line );
181
+ if (key == HID_CONSUMER_UNASSIGNED ) {
182
+ return ducky_error (bad_kb , "No keycode defined for %s" , line );
183
+ }
184
+ if (bad_kb -> bt ) {
185
+ ble_profile_hid_kb_press (bad_kb -> app -> ble_hid , key );
186
+ furi_delay_ms (bt_timeout );
187
+ ble_profile_hid_kb_release (bad_kb -> app -> ble_hid , key );
188
+ } else {
189
+ furi_hal_hid_kb_press (key );
190
+ furi_hal_hid_kb_release (key );
191
+ }
192
+ return 0 ;
193
+ }
194
+
195
+ static int32_t ducky_fnc_globe (BadKbScript * bad_kb , const char * line , int32_t param ) {
196
+ UNUSED (param );
197
+
198
+ line = & line [ducky_get_command_len (line ) + 1 ];
199
+ uint16_t key = ducky_get_keycode (bad_kb , line , true);
200
+ if (key == HID_KEYBOARD_NONE ) {
201
+ return ducky_error (bad_kb , "No keycode defined for %s" , line );
202
+ }
203
+
204
+ if (bad_kb -> bt ) {
205
+ ble_profile_hid_consumer_key_press (bad_kb -> app -> ble_hid , HID_CONSUMER_FN_GLOBE );
206
+ ble_profile_hid_kb_press (bad_kb -> app -> ble_hid , key );
207
+ furi_delay_ms (bt_timeout );
208
+ ble_profile_hid_kb_release (bad_kb -> app -> ble_hid , key );
209
+ ble_profile_hid_consumer_key_release (bad_kb -> app -> ble_hid , HID_CONSUMER_FN_GLOBE );
210
+ } else {
211
+ furi_hal_hid_consumer_key_press (HID_CONSUMER_FN_GLOBE );
212
+ furi_hal_hid_kb_press (key );
213
+ furi_hal_hid_kb_release (key );
214
+ furi_hal_hid_consumer_key_release (HID_CONSUMER_FN_GLOBE );
215
+ }
216
+ return 0 ;
217
+ }
218
+
164
219
static int32_t ducky_fnc_waitforbutton (BadKbScript * bad_kb , const char * line , int32_t param ) {
165
220
UNUSED (param );
166
221
UNUSED (bad_kb );
@@ -180,6 +235,8 @@ static const DuckyCmd ducky_commands[] = {
180
235
{"DEFAULTDELAY" , ducky_fnc_defdelay , -1 },
181
236
{"STRINGDELAY" , ducky_fnc_strdelay , -1 },
182
237
{"STRING_DELAY" , ducky_fnc_strdelay , -1 },
238
+ {"DEFAULT_STRING_DELAY" , ducky_fnc_defstrdelay , -1 },
239
+ {"DEFAULTSTRINGDELAY" , ducky_fnc_defstrdelay , -1 },
183
240
{"REPEAT" , ducky_fnc_repeat , -1 },
184
241
{"SYSRQ" , ducky_fnc_sysrq , -1 },
185
242
{"ALTCHAR" , ducky_fnc_altchar , -1 },
@@ -188,6 +245,8 @@ static const DuckyCmd ducky_commands[] = {
188
245
{"HOLD" , ducky_fnc_hold , -1 },
189
246
{"RELEASE" , ducky_fnc_release , -1 },
190
247
{"WAIT_FOR_BUTTON_PRESS" , ducky_fnc_waitforbutton , -1 },
248
+ {"MEDIA" , ducky_fnc_media , -1 },
249
+ {"GLOBE" , ducky_fnc_globe , -1 },
191
250
};
192
251
193
252
#define TAG "BadKb"
0 commit comments