add key sequence function

This commit is contained in:
hathach committed 2017-01-21 01:29:51 +07:00
1 parent ce76cc5405
commit 37584ebf7f
2 files changed
+22

No files matched your search

@@ -456,3 +456,24 @@ err_t BLEHid::keyRelease(void)
return keyboardReport(&report);
}
err_t BLEHid::keySequence(const char* str, int ms)
{
// Send each key in sequence
char ch;
while( (ch = *str++) != 0 )
{
char lookahead = *str;
keyPress(ch);
delay(ms);
/* Only need to empty report if the next character is NULL or the same with
* the current one, or no need to send */
if ( lookahead == ch || lookahead == 0 )
{
keyRelease();
delay(ms);
}
}
}
@@ -96,6 +96,7 @@ class BLEHid : public BLEService
err_t keyboardReport(hid_keyboard_report_t* report);
err_t keyPress(char ch);
err_t keyRelease(void);
err_t keySequence(const char* str, int ms=5);
};
//--------------------------------------------------------------------+