mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 15:26:13 +08:00
clarify BUTTON macro usages
This commit is contained in:
parent
3f71be870b
commit
4dac94c772
|
@ -501,7 +501,7 @@ failtag:
|
|||
LED_A_INV();
|
||||
}
|
||||
|
||||
if (BUTTON_HELD(10) > 0) {
|
||||
if (BUTTON_HELD(10) == BUTTON_HOLD) {
|
||||
WDT_HIT();
|
||||
DbprintfEx(FLAG_NEWLINE, "\t\t\t[ READING FLASH ]");
|
||||
ReadLastTagFromFlash();
|
||||
|
|
|
@ -222,9 +222,9 @@ void RunMod(void) {
|
|||
// Was our button held down or pressed?
|
||||
int button_pressed = BUTTON_HELD(1000);
|
||||
|
||||
if (button_pressed == 1) //Holding down the button
|
||||
if (button_pressed == BUTTON_HOLD) //Holding down the button
|
||||
break;
|
||||
else if (button_pressed == -1) { //Pressing one time change between reading & emulation
|
||||
else if (button_pressed == BUTTON_SINGLE_CLICK) { //Pressing one time change between reading & emulation
|
||||
if (state == STATE_READ) {
|
||||
if (chktoken == true && token[0] != 0x00) { //Only change to emulation if it saved a track 2 in memory
|
||||
state = STATE_EMU;
|
||||
|
|
|
@ -222,8 +222,8 @@ void RunMod(void) {
|
|||
// exit from Standalone Mode, send a usbcommand.
|
||||
if (data_available()) return;
|
||||
|
||||
int button_action = BUTTON_HELD(1000);
|
||||
if (button_action == 0) { // No button action, proceed with sim
|
||||
int button_pressed = BUTTON_HELD(1000);
|
||||
if (button_pressed == BUTTON_NO_CLICK) { // No button action, proceed with sim
|
||||
|
||||
uint8_t flags = FLAG_4B_UID_IN_DATA;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0}; // in case there is a read command received we shouldn't break
|
||||
|
@ -259,12 +259,12 @@ void RunMod(void) {
|
|||
SimulateIso14443aTag(1, flags, data);
|
||||
}
|
||||
|
||||
} else if (button_action == BUTTON_SINGLE_CLICK) {
|
||||
} else if (button_pressed == BUTTON_SINGLE_CLICK) {
|
||||
selected = (selected + 1) % OPTS;
|
||||
Dbprintf("Done playing. Switching to record mode on bank %d", selected);
|
||||
iGotoRecord = 1;
|
||||
break;
|
||||
} else if (button_action == BUTTON_HOLD) {
|
||||
} else if (button_pressed == BUTTON_HOLD) {
|
||||
Dbprintf("Playtime over. Begin cloning...");
|
||||
iGotoClone = 1;
|
||||
break;
|
||||
|
|
|
@ -215,13 +215,12 @@ static int ButeEMTag(uint64_t originalCard, int slot) {
|
|||
direction = -1;
|
||||
}
|
||||
|
||||
uint64_t currentCard;
|
||||
while (cardnum > 1 && cardnum < 65535) {
|
||||
WDT_HIT();
|
||||
if (data_available()) break;
|
||||
|
||||
cardnum = cardnum + direction;
|
||||
currentCard = PackEmID(originalCard, cardnum);
|
||||
uint64_t currentCard = PackEmID(originalCard, cardnum);
|
||||
Dbprintf("[=] >> Simulating card id %"PRIx64" <<", currentCard);
|
||||
ConstructEM410xEmulBuf(ReversQuads(currentCard));
|
||||
SimulateTagLowFrequencyEx(buflen, 0, 1, bruteforceSpeed[bruteforceSpeedCurrent] * 10000);
|
||||
|
|
|
@ -141,12 +141,12 @@ void RunMod(void) {
|
|||
switch (state) {
|
||||
case 0:
|
||||
// Select mode
|
||||
if (button_pressed == 1) {
|
||||
if (button_pressed == BUTTON_HOLD) {
|
||||
// Long press - switch to simulate mode
|
||||
SpinUp(100);
|
||||
LED_Slot(selected);
|
||||
state = 2;
|
||||
} else if (button_pressed < 0) {
|
||||
} else if (button_pressed == BUTTON_SINGLE_CLICK) {
|
||||
// Click - switch to next slot
|
||||
selected = (selected + 1) % slots_count;
|
||||
LED_Slot(selected);
|
||||
|
@ -154,12 +154,12 @@ void RunMod(void) {
|
|||
break;
|
||||
case 1:
|
||||
// Read mode.
|
||||
if (button_pressed > 0) {
|
||||
if (button_pressed == BUTTON_HOLD) {
|
||||
// Long press - switch to read mode
|
||||
SpinUp(100);
|
||||
LED_Slot(selected);
|
||||
state = 3;
|
||||
} else if (button_pressed < 0) {
|
||||
} else if (button_pressed == BUTTON_SINGLE_CLICK) {
|
||||
// Click - exit to select mode
|
||||
CmdEM410xdemod(1, &high[selected], &low[selected], 0);
|
||||
FlashLEDs(100, 5);
|
||||
|
@ -171,12 +171,12 @@ void RunMod(void) {
|
|||
break;
|
||||
case 2:
|
||||
// Simulate mode
|
||||
if (button_pressed > 0) {
|
||||
if (button_pressed == BUTTON_HOLD) {
|
||||
// Long press - switch to read mode
|
||||
SpinDown(100);
|
||||
LED_Slot(selected);
|
||||
state = 1;
|
||||
} else if (button_pressed < 0) {
|
||||
} else if (button_pressed == BUTTON_SINGLE_CLICK) {
|
||||
// Click - start simulating. Click again to exit from simulate mode
|
||||
LED_Slot(selected);
|
||||
ConstructEM410xEmulBuf(ReversQuads(low[selected]));
|
||||
|
@ -188,12 +188,12 @@ void RunMod(void) {
|
|||
break;
|
||||
case 3:
|
||||
// Write tag mode
|
||||
if (button_pressed > 0) {
|
||||
if (button_pressed == BUTTON_HOLD) {
|
||||
// Long press - switch to select mode
|
||||
SpinDown(100);
|
||||
LED_Slot(selected);
|
||||
state = 0;
|
||||
} else if (button_pressed < 0) {
|
||||
} else if (button_pressed == BUTTON_SINGLE_CLICK) {
|
||||
// Click - write ID to tag
|
||||
WriteEM410x(0, (uint32_t)(low[selected] >> 32), (uint32_t)(low[selected] & 0xffffffff));
|
||||
LED_Slot(selected);
|
||||
|
|
|
@ -85,7 +85,7 @@ void RunMod(void) {
|
|||
// so next button push begins playing what we recorded
|
||||
playing = 0;
|
||||
cardRead = 1;
|
||||
} else if (button_pressed > 0 && cardRead == 1) {
|
||||
} else if (button_pressed == BUTTON_HOLD && cardRead == 1) {
|
||||
LEDsoff();
|
||||
LED(selected + 1, 0);
|
||||
LED(LED_A, 0);
|
||||
|
@ -109,7 +109,7 @@ void RunMod(void) {
|
|||
}
|
||||
|
||||
// Change where to record (or begin playing)
|
||||
else if (button_pressed) {
|
||||
else if (button_pressed != BUTTON_NO_CLICK) {
|
||||
// Next option if we were previously playing
|
||||
if (playing)
|
||||
selected = (selected + 1) % OPTS;
|
||||
|
@ -131,7 +131,7 @@ void RunMod(void) {
|
|||
CmdHIDsimTAG(0, high[selected], low[selected], 0, 0);
|
||||
DbpString("[=] done playing");
|
||||
|
||||
if (BUTTON_HELD(1000) > 0)
|
||||
if (BUTTON_HELD(1000) == BUTTON_HOLD)
|
||||
goto out;
|
||||
|
||||
/* We pressed a button so ignore it here with a delay */
|
||||
|
@ -169,7 +169,7 @@ void RunMod(void) {
|
|||
|
||||
// Needed for exiting from proxbrute when button is pressed
|
||||
if (BUTTON_PRESS()) {
|
||||
if (BUTTON_HELD(1000) > 0) {
|
||||
if (BUTTON_HELD(1000) == BUTTON_HOLD) {
|
||||
goto out;
|
||||
} else {
|
||||
while (BUTTON_PRESS()) {
|
||||
|
@ -199,7 +199,7 @@ void RunMod(void) {
|
|||
|
||||
// Needed for exiting from proxbrute when button is pressed
|
||||
if (BUTTON_PRESS()) {
|
||||
if (BUTTON_HELD(1000) > 0) {
|
||||
if (BUTTON_HELD(1000) == BUTTON_HOLD) {
|
||||
goto out;
|
||||
} else {
|
||||
while (BUTTON_PRESS()) { WDT_HIT(); }
|
||||
|
@ -220,7 +220,7 @@ void RunMod(void) {
|
|||
}
|
||||
|
||||
DbpString("[=] done bruteforcing");
|
||||
if (BUTTON_HELD(1000) > 0)
|
||||
if (BUTTON_HELD(1000) == BUTTON_HOLD)
|
||||
goto out;
|
||||
|
||||
/* We pressed a button so ignore it here with a delay */
|
||||
|
|
|
@ -56,11 +56,6 @@ void RunMod(void) {
|
|||
int button_pressed = BUTTON_HELD(280);
|
||||
if (button_pressed != BUTTON_HOLD)
|
||||
continue;
|
||||
/*
|
||||
#define BUTTON_NO_CLICK 0
|
||||
#define BUTTON_SINGLE_CLICK -1
|
||||
#define BUTTON_DOUBLE_CLICK -2
|
||||
*/
|
||||
|
||||
if (state == STATE_READ) {
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void RunMod(void) {
|
|||
|
||||
Dbprintf("button %d", button_pressed);
|
||||
|
||||
if (button_pressed)
|
||||
if (button_pressed != BUTTON_NO_CLICK)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue