BadUSB/BLE bugs fixes and improve writing speed#2192
BadUSB/BLE bugs fixes and improve writing speed#2192mokapi47 wants to merge 23 commits intoBruceDevices:devfrom
Conversation
| // Set appropriate delay for this STRING command - 5ms instead of defaultStringDelay | ||
| int currentDelay = (nextStringDelay >= 0) ? nextStringDelay : 5; |
There was a problem hiding this comment.
This needs to be left as defaultStringDelay this variable is initially set from the devices configured delay
static int defaultStringDelay = bruceConfig.badUSBBLEKeyDelay; // Default delay for all STRING commands
Then can be overridden by DEFAULT_STRING_DELAY and DEFAULTSTRINGDELAY.
There was a problem hiding this comment.
I'm sorry, but that's precisely the whole point of my PR: to significantly reduce the delay between writing each character with STRING, because for me it's far too slow. I tried implementing what you suggested, but when I change that value in my device settings to 5ms (as I forced in the code), it simply doesn't work. So I'll leave it as I had it for now. In the meantime, feel free to suggest other ways to fix this.
There was a problem hiding this comment.
Please can you send the script you are using to test.
There was a problem hiding this comment.
The entire script is on this GitHub repository : https://github.com/mokapi47/firmware/tree/dev_BadUSB/BLE
There was a problem hiding this comment.
I know where the source code it.
What BadUSB script are you using to test this? So I can test using the same thing.
There was a problem hiding this comment.
I'm running STRING tests to check the writing speed, and hard tests to see if the script can be stopped. I also need to review the script stopping mechanisms I've set up, as they don't work for STRINGS. Here's the one I'm using for STRING writing speed :
DELAY 250
STRING i like potatoes, I go to Burger King every day, this sentence is just a test sentence \ ,;:?./
Don't pay attention, I just put something random.
|
For your information, I will be implementing a new parameter to change the key string delay value in the advanced badUSB/BLE settings. |
This is not true. In Which sets this in
Which is then used here to write each key. Turn your Config Key Delay down to 5ms and you will see it being much faster. Over USB I even managed to get it lower than this but you might get some missed key strokes. In the code I am questioning you have removed the The setting for this is pulled from the Key Delay:
So if you set to 5ms in the config you end up with what you have suggested but your solution also removes the ability to configure the delay between keys. Being able to configure this is very important for BadBLE which needs to operate slower. |
… BLE ONLY WORK !!
|
I did indeed make a careless mistake; I've corrected it and implemented a parameter to manage the key delay time in milliseconds. However, I'm not finished yet; only the BadBLE function is working. I'll complete the rest properly tomorrow. |
|
@mokapi47 is this ready for review yet? |
Normally yes. |


I've also reduced the delays between keystrokes (for the STRING, for example) because it was set to 50ms, which made it extremely slow to type. I've reduced this to 5ms, and it works perfectly. Typing "example" now takes ~20ms instead of 400-500ms, which is about 17 times faster. I've also changed the command delay from 75ms to 10ms.
Main changes:
Default delay: 100ms → 5ms (20x faster)
I used such a low value because most code already contains delays, so there's no need to add even more delays. For me, this is better and faster for most uses.
Delay between characters: 50ms → 5ms (25x faster)
For me, a value of 50 ms per character is too low; using this value, I noticed that it is quite slow to write STRINGS, so I lowered it because it seems logical to make it faster to write characters.
Command delay: 75ms → 10ms (7.5x faster)
Again, this is better for me because it reduces the delays between lines, so it's much faster.
I've obviously done extensive testing. To ensure stability and that everything works perfectly, you now have a BadUSB/BLE that works super fast, without errors, and most importantly, can be stopped at any time.
I've noticed that lately, many people are complaining about BadUSB/BLE not stopping when there are long delays or large repeats. So, I've changed some functions in the code, so that there is much more verification if the button is pressed.