Merge remote-tracking branch 'ofw/dev' into mntm-dev

This commit is contained in:
Willy-JL
2025-04-01 11:08:02 +00:00
5 changed files with 49 additions and 31 deletions

View File

@@ -85,6 +85,7 @@
- OFW: Added naming for DESFire cards + fix MF3ICD40 cards unable to be read (by @Demae)
- OFW: FeliCa Protocol Expose Read Block API and Allow Specifying Service (by @zinongli)
- OFW: Enable MFUL sync poller to be provided with passwords (by @GMMan)
- OFW: BadKB: Support arbitrary key combinations (by @portasynthinca3)
- UL: Power: Moved Charge Cap to Power Settings as Charge Limit option (by @Dmitry422)
- Infrared:
- OFW: Add Fujitsu ASTG12LVCC to AC Universal Remote (by @KereruA0i)

View File

@@ -42,11 +42,8 @@ static const uint8_t numpad_keys[10] = {
};
uint32_t ducky_get_command_len(const char* line) {
uint32_t len = strlen(line);
for(uint32_t i = 0; i < len; i++) {
if(line[i] == ' ') return i;
}
return 0;
char* first_space = strchr(line, ' ');
return first_space ? (first_space - line) : 0;
}
bool ducky_is_line_end(const char chr) {
@@ -182,42 +179,46 @@ static bool ducky_string_next(BadUsbScript* bad_usb) {
static int32_t ducky_parse_line(BadUsbScript* bad_usb, FuriString* line) {
uint32_t line_len = furi_string_size(line);
const char* line_tmp = furi_string_get_cstr(line);
const char* line_cstr = furi_string_get_cstr(line);
if(line_len == 0) {
return SCRIPT_STATE_NEXT_LINE; // Skip empty lines
}
FURI_LOG_D(WORKER_TAG, "line:%s", line_tmp);
FURI_LOG_D(WORKER_TAG, "line:%s", line_cstr);
// Ducky Lang Functions
int32_t cmd_result = ducky_execute_cmd(bad_usb, line_tmp);
int32_t cmd_result = ducky_execute_cmd(bad_usb, line_cstr);
if(cmd_result != SCRIPT_STATE_CMD_UNKNOWN) {
return cmd_result;
}
// Mouse Keys
uint16_t key = ducky_get_mouse_keycode_by_name(line_tmp);
uint16_t key = ducky_get_mouse_keycode_by_name(line_cstr);
if(key != HID_MOUSE_INVALID) {
bad_usb->hid->mouse_press(bad_usb->hid_inst, key);
bad_usb->hid->mouse_release(bad_usb->hid_inst, key);
return 0;
}
// Special keys + modifiers
key = ducky_get_keycode(bad_usb, line_tmp, false);
if(key == HID_KEYBOARD_NONE) {
return ducky_error(bad_usb, "No keycode defined for %s", line_tmp);
}
if((key & 0xFF00) != 0) {
// It's a modifier key
uint32_t offset = ducky_get_command_len(line_tmp) + 1;
// ducky_get_command_len() returns 0 without space, so check for != 1
if(offset != 1 && line_len > offset) {
// It's also a key combination
line_tmp = &line_tmp[offset];
key |= ducky_get_keycode(bad_usb, line_tmp, true);
}
// Parse chain of modifiers linked by spaces and hyphens
uint16_t modifiers = 0;
while(1) {
key = ducky_get_next_modifier_keycode_by_name(&line_cstr);
if(key == HID_KEYBOARD_NONE) break;
modifiers |= key;
char next_char = *line_cstr;
if(next_char == ' ' || next_char == '-') line_cstr++;
}
// Main key
char next_char = *line_cstr;
uint16_t main_key = ducky_get_keycode_by_name(line_cstr);
if(!main_key && next_char) main_key = BADUSB_ASCII_TO_KEY(bad_usb, next_char);
key = modifiers | main_key;
if(key == 0 && next_char) ducky_error(bad_usb, "No keycode defined for %s", line_cstr);
bad_usb->hid->kb_press(bad_usb->hid_inst, key);
bad_usb->hid->kb_release(bad_usb->hid_inst, key);
return 0;

View File

@@ -56,6 +56,8 @@ uint32_t ducky_get_command_len(const char* line);
bool ducky_is_line_end(const char chr);
uint16_t ducky_get_next_modifier_keycode_by_name(const char** param);
uint16_t ducky_get_keycode_by_name(const char* param);
uint16_t ducky_get_media_keycode_by_name(const char* param);

View File

@@ -6,21 +6,16 @@ typedef struct {
uint16_t keycode;
} DuckyKey;
static const DuckyKey ducky_keys[] = {
{"CTRL-ALT", KEY_MOD_LEFT_CTRL | KEY_MOD_LEFT_ALT},
{"CTRL-SHIFT", KEY_MOD_LEFT_CTRL | KEY_MOD_LEFT_SHIFT},
{"ALT-SHIFT", KEY_MOD_LEFT_ALT | KEY_MOD_LEFT_SHIFT},
{"ALT-GUI", KEY_MOD_LEFT_ALT | KEY_MOD_LEFT_GUI},
{"GUI-SHIFT", KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_SHIFT},
{"GUI-CTRL", KEY_MOD_LEFT_GUI | KEY_MOD_LEFT_CTRL},
static const DuckyKey ducky_modifier_keys[] = {
{"CTRL", KEY_MOD_LEFT_CTRL},
{"CONTROL", KEY_MOD_LEFT_CTRL},
{"SHIFT", KEY_MOD_LEFT_SHIFT},
{"ALT", KEY_MOD_LEFT_ALT},
{"GUI", KEY_MOD_LEFT_GUI},
{"WINDOWS", KEY_MOD_LEFT_GUI},
};
static const DuckyKey ducky_keys[] = {
{"DOWNARROW", HID_KEYBOARD_DOWN_ARROW},
{"DOWN", HID_KEYBOARD_DOWN_ARROW},
{"LEFTARROW", HID_KEYBOARD_LEFT_ARROW},
@@ -119,6 +114,23 @@ static const DuckyKey ducky_mouse_keys[] = {
{"WHEEL_CLICK", HID_MOUSE_BTN_WHEEL},
};
uint16_t ducky_get_next_modifier_keycode_by_name(const char** param) {
const char* input_str = *param;
for(size_t i = 0; i < COUNT_OF(ducky_modifier_keys); i++) {
size_t key_cmd_len = strlen(ducky_modifier_keys[i].name);
if((strncmp(input_str, ducky_modifier_keys[i].name, key_cmd_len) == 0)) {
char next_char_after_key = input_str[key_cmd_len];
if(ducky_is_line_end(next_char_after_key) || (next_char_after_key == '-')) {
*param = &input_str[key_cmd_len];
return ducky_modifier_keys[i].keycode;
}
}
}
return HID_KEYBOARD_NONE;
}
uint16_t ducky_get_keycode_by_name(const char* param) {
for(size_t i = 0; i < COUNT_OF(ducky_keys); i++) {
size_t key_cmd_len = strlen(ducky_keys[i].name);

View File

@@ -215,6 +215,8 @@ Adds a child to the `View`.
**Parameters**
- `child`: the child to add, e.g. `{ element: "button", button: "right", text: "Back" }`
The format of the `child` parameter depends on the type of View that you're working with. Look in the View documentation.
### View.resetChildren()
Removes all children from the `View`.