Replace ukbhit by kbd_enter_pressed, not requiring tcgetattr:

Note that it behaves differently now
* it looks for Enter key only, not any key
* it "eats" the input, no need for (void)getchar() after it
* it works the same no matter the value of ICANON
* the mingw version has been adapted to act the similarly

This should fix its usage on Android where tcgetattr always returns -1
This commit is contained in:
Philippe Teuwen 2019-07-11 13:01:34 +02:00
commit 844d732297
27 changed files with 90 additions and 126 deletions

View file

@ -40,7 +40,7 @@ static int usage_hf_sniff() {
static int usage_hf_tune() {
PrintAndLogEx(NORMAL, "Usage: hf tune [<iter>]");
PrintAndLogEx(NORMAL, "Continuously measure HF antenna tuning.");
PrintAndLogEx(NORMAL, "Press button or keyboard to interrupt.");
PrintAndLogEx(NORMAL, "Press button or Enter to interrupt.");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " <iter> - number of iterations (default: infinite)");
PrintAndLogEx(NORMAL, "");
@ -98,7 +98,7 @@ int CmdHFTune(const char *Cmd) {
int iter = param_get32ex(Cmd, 0, 0, 10);
PacketResponseNG resp;
PrintAndLogEx(SUCCESS, "Measuring HF antenna, click button or press a key to exit");
PrintAndLogEx(SUCCESS, "Measuring HF antenna, click button or press Enter to exit");
clearCommandBuffer();
uint8_t mode[] = {1};
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));
@ -109,9 +109,7 @@ int CmdHFTune(const char *Cmd) {
mode[0] = 2;
// loop forever (till button pressed) if iter = 0 (default)
for (uint8_t i = 0; iter == 0 || i < iter; i++) {
if (ukbhit()) { // abort by keyboard press
int gc = getchar();
(void)gc;
if (kbd_enter_pressed()) { // abort by keyboard press
break;
}
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));