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:
@@ -488,7 +488,7 @@ local function readtag(mfkey, aeskey )
|
||||
|
||||
for blockNo = 0, numBlocks-1 do
|
||||
|
||||
if core.ukbhit() then
|
||||
if core.kbd_enter_pressed() then
|
||||
print("[fail] aborted by user")
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -206,7 +206,7 @@ local function main(args)
|
||||
if x then core.console(cmd) end
|
||||
end
|
||||
|
||||
if core.ukbhit() then
|
||||
if core.kbd_enter_pressed() then
|
||||
print('aborted by user')
|
||||
break
|
||||
end
|
||||
|
||||
@@ -186,7 +186,7 @@ local function main(args)
|
||||
for cardnum = baseid, endid do
|
||||
local card = cardHex(cardnum, facility)
|
||||
print('Press enter to program card '..cardnum..':'..facility..' (hex: '..card..')')
|
||||
--This would be better with 'press any key', but we'll take what we can get.
|
||||
--This would be better with 'press Enter', but we'll take what we can get.
|
||||
io.read()
|
||||
core.console( ('lf hid clone %s'):format(card) )
|
||||
end
|
||||
|
||||
@@ -208,7 +208,7 @@ local function perform_check(numsectors)
|
||||
|
||||
for sector = 0, #keys do
|
||||
-- Check if user aborted
|
||||
if core.ukbhit() then
|
||||
if core.kbd_enter_pressed() then
|
||||
print('Aborted by user')
|
||||
break
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ end
|
||||
-- @return if successfull: an table containing card info
|
||||
-- @return if unsuccessfull : nil, error
|
||||
local function wait_for_mifare()
|
||||
while not core.ukbhit() do
|
||||
while not core.kbd_enter_pressed() do
|
||||
res, err = lib14a.read()
|
||||
if res then return res end
|
||||
-- err means that there was no response from card
|
||||
@@ -161,7 +161,7 @@ local function main(args)
|
||||
|
||||
while not _exit do
|
||||
if print_message then
|
||||
print('Waiting for card or press any key to stop')
|
||||
print('Waiting for card or press Enter to stop')
|
||||
print_message = false
|
||||
end
|
||||
res, err = wait_for_mifare()
|
||||
|
||||
@@ -198,7 +198,7 @@ local function main(args)
|
||||
|
||||
io.flush()
|
||||
|
||||
if core.ukbhit() then
|
||||
if core.kbd_enter_pressed() then
|
||||
print("aborted by user")
|
||||
break
|
||||
end
|
||||
|
||||
@@ -118,7 +118,7 @@ local function main(args)
|
||||
|
||||
core.clearCommandBuffer()
|
||||
|
||||
if core.ukbhit() then
|
||||
if core.kbd_enter_pressed() then
|
||||
print('aborted by user')
|
||||
break
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user