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