Update TOTP / run fbt format

This commit is contained in:
MX
2023-05-01 20:55:09 +03:00
parent 2eac821f7f
commit 0ef37df4ae
3 changed files with 25 additions and 24 deletions

View File

@@ -21,7 +21,6 @@ int min(int a, int b) {
#define WorldSizeY 6 #define WorldSizeY 6
#define BombRange 1 #define BombRange 1
typedef struct { typedef struct {
FuriMutex* mutex; FuriMutex* mutex;
} BomberState; } BomberState;
@@ -105,7 +104,7 @@ void init() {
} }
} }
world.running = 1; world.running = 1;
world.bombs_count =0; world.bombs_count = 0;
vibration = false; vibration = false;
for(int j = max(0, player.y - BombRange); j < min(WorldSizeY, player.y + BombRange + 1); j++) { for(int j = max(0, player.y - BombRange); j < min(WorldSizeY, player.y + BombRange + 1); j++) {
world.matrix[j][player.x] = 0; world.matrix[j][player.x] = 0;
@@ -191,7 +190,6 @@ static const NotificationSequence vibr1 = {
NULL, NULL,
}; };
void intToStr(int num, char* str) { void intToStr(int num, char* str) {
int i = 0, sign = 0; int i = 0, sign = 0;
@@ -344,7 +342,7 @@ static void draw_callback(Canvas* canvas, void* ctx) {
if(world.player->x == world.endx && world.player->y == world.endy) { if(world.player->x == world.endx && world.player->y == world.endy) {
if(world.level == 20) { if(world.level == 20) {
canvas_draw_str(canvas, 30, 35, "You win!"); canvas_draw_str(canvas, 30, 35, "You win!");
}else{ } else {
canvas_draw_str(canvas, 30, 35, "Next level!"); canvas_draw_str(canvas, 30, 35, "Next level!");
char str[20]; char str[20];
intToStr(world.level, str); intToStr(world.level, str);
@@ -427,24 +425,24 @@ int32_t bomberduck_app(void* p) {
if(world.running) { if(world.running) {
if(event.key == InputKeyUp) { if(event.key == InputKeyUp) {
if(world.player->y > 0 && if(world.player->y > 0 &&
world.matrix[world.player->y - 1][world.player->x] == 0) world.matrix[world.player->y - 1][world.player->x] == 0)
world.player->y--; world.player->y--;
} }
if(event.key == InputKeyDown) { if(event.key == InputKeyDown) {
if(world.player->y < WorldSizeY - 1 && if(world.player->y < WorldSizeY - 1 &&
world.matrix[world.player->y + 1][world.player->x] == 0) world.matrix[world.player->y + 1][world.player->x] == 0)
world.player->y++; world.player->y++;
} }
if(event.key == InputKeyLeft) { if(event.key == InputKeyLeft) {
world.player->side = 0; world.player->side = 0;
if(world.player->x > 0 && if(world.player->x > 0 &&
world.matrix[world.player->y][world.player->x - 1] == 0) world.matrix[world.player->y][world.player->x - 1] == 0)
world.player->x--; world.player->x--;
} }
if(event.key == InputKeyRight) { if(event.key == InputKeyRight) {
world.player->side = 1; world.player->side = 1;
if(world.player->x < WorldSizeX - 1 && if(world.player->x < WorldSizeX - 1 &&
world.matrix[world.player->y][world.player->x + 1] == 0) world.matrix[world.player->y][world.player->x + 1] == 0)
world.player->x++; world.player->x++;
} }
} }
@@ -459,7 +457,7 @@ int32_t bomberduck_app(void* p) {
notification_message(notification, &end); notification_message(notification, &end);
world.running = 0; world.running = 0;
world.level += 1; world.level += 1;
if(world.level%5==0){ if(world.level % 5 == 0) {
DOLPHIN_DEED(DolphinDeedPluginGameWin); DOLPHIN_DEED(DolphinDeedPluginGameWin);
} }
} }
@@ -524,13 +522,18 @@ int32_t bomberduck_app(void* p) {
world.bombs[j] = world.bombs[j + 1]; world.bombs[j] = world.bombs[j + 1];
} }
world.bombs_count--; world.bombs_count--;
} else if(furi_get_tick() - world.bombs[i].planted > (unsigned long)max((3000 - world.level * 150)*2/3, 666)&&world.matrix[world.bombs[i].y][world.bombs[i].x]!=5) { } else if(
world.matrix[world.bombs[i].y][world.bombs[i].x] = 5; furi_get_tick() - world.bombs[i].planted >
vibration=true; (unsigned long)max((3000 - world.level * 150) * 2 / 3, 666) &&
world.matrix[world.bombs[i].y][world.bombs[i].x] != 5) {
world.matrix[world.bombs[i].y][world.bombs[i].x] = 5;
vibration = true;
} else if(furi_get_tick() - world.bombs[i].planted > (unsigned long)max((3000 - world.level * 150)/3, 333)&& world.matrix[world.bombs[i].y][world.bombs[i].x]!=4) { } else if(
world.matrix[world.bombs[i].y][world.bombs[i].x] = 4; furi_get_tick() - world.bombs[i].planted >
(unsigned long)max((3000 - world.level * 150) / 3, 333) &&
world.matrix[world.bombs[i].y][world.bombs[i].x] != 4) {
world.matrix[world.bombs[i].y][world.bombs[i].x] = 4;
} }
} }
for(int e = 0; e < world.enemies_count; e++) { for(int e = 0; e < world.enemies_count; e++) {
@@ -618,7 +621,7 @@ int32_t bomberduck_app(void* p) {
} }
} }
} }
if(vibration){ if(vibration) {
notification_message(notification, &vibr1); notification_message(notification, &vibr1);
} }
} }

View File

@@ -109,7 +109,6 @@ static void hid_ytshorts_draw_callback(Canvas* canvas, void* context) {
elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Hold to exit"); elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Hold to exit");
} }
static void hid_ytshorts_reset_cursor(HidYTShorts* hid_ytshorts) { static void hid_ytshorts_reset_cursor(HidYTShorts* hid_ytshorts) {
// Set cursor to the phone's left up corner // Set cursor to the phone's left up corner
// Delays to guarantee one packet per connection interval // Delays to guarantee one packet per connection interval

View File

@@ -30,7 +30,7 @@ static uint32_t get_keypress_delay(TokenAutomationFeature features) {
} }
static void totp_type_code_worker_press_key( static void totp_type_code_worker_press_key(
uint8_t key, uint16_t key,
TOTP_AUTOMATION_KEY_HANDLER key_press_fn, TOTP_AUTOMATION_KEY_HANDLER key_press_fn,
TOTP_AUTOMATION_KEY_HANDLER key_release_fn, TOTP_AUTOMATION_KEY_HANDLER key_release_fn,
TokenAutomationFeature features) { TokenAutomationFeature features) {
@@ -47,8 +47,6 @@ void totp_type_code_worker_execute_automation(
TokenAutomationFeature features) { TokenAutomationFeature features) {
furi_delay_ms(500); furi_delay_ms(500);
uint8_t i = 0; uint8_t i = 0;
totp_type_code_worker_press_key(
HID_KEYBOARD_CAPS_LOCK, key_press_fn, key_release_fn, features);
while(i < code_buffer_size && code_buffer[i] != 0) { while(i < code_buffer_size && code_buffer[i] != 0) {
uint8_t char_index = CONVERT_CHAR_TO_DIGIT(code_buffer[i]); uint8_t char_index = CONVERT_CHAR_TO_DIGIT(code_buffer[i]);
@@ -58,7 +56,11 @@ void totp_type_code_worker_execute_automation(
if(char_index > 35) break; if(char_index > 35) break;
uint8_t hid_kb_key = hid_number_keys[char_index]; uint16_t hid_kb_key = hid_number_keys[char_index];
if(char_index > 9) {
hid_kb_key |= KEY_MOD_LEFT_SHIFT;
}
totp_type_code_worker_press_key(hid_kb_key, key_press_fn, key_release_fn, features); totp_type_code_worker_press_key(hid_kb_key, key_press_fn, key_release_fn, features);
furi_delay_ms(get_keystroke_delay(features)); furi_delay_ms(get_keystroke_delay(features));
i++; i++;
@@ -74,7 +76,4 @@ void totp_type_code_worker_execute_automation(
furi_delay_ms(get_keystroke_delay(features)); furi_delay_ms(get_keystroke_delay(features));
totp_type_code_worker_press_key(HID_KEYBOARD_TAB, key_press_fn, key_release_fn, features); totp_type_code_worker_press_key(HID_KEYBOARD_TAB, key_press_fn, key_release_fn, features);
} }
totp_type_code_worker_press_key(
HID_KEYBOARD_CAPS_LOCK, key_press_fn, key_release_fn, features);
} }