1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 20:49:49 +04:00
This commit is contained in:
clipboard1
2023-05-02 22:25:33 +05:00
31 changed files with 1003 additions and 51 deletions

View File

@@ -1,27 +1,14 @@
### New changes
* Power + BLE: DeepSleep + required ble stack upgrade added back, all known issues was fixed in OFW, no issues was found during our tests
* Desktop: Allow locking without pin using Up menu on desktop (Short click on `Lock` = Without PIN / Long = With PIN)
* RFID: Add confirmation message before running `Clear T5577 Password`
* RFID: Add more user friendly RAW emulation via UI [(by Dan Caprita)](https://forum.flipperzero.one/t/electra-intercom/6368/43)
* SubGHz: Fixed `Frequency Analyzer` issues, fixed `Read` mode issues
* SubGHz: Fix NFC crash when using external CC1101 radio module
* SubGHz: Fix multiple external CC1101 radio module issues, (int callbacks, SPI handlers init/reinit)
* SubGHz: Using scene manager function in add manually (by @gid9798 | PR #437)
* Plugins: ESP32: WiFi Marauder - add icon for log files in logs browser
* Plugins: Update **ESP32: WiFi Marauder companion** plugin [(by 0xchocolate)](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion) merged [PR by @tcpassos](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion/pull/11)
* NFC: Temp fix for Detect reader not collecting nonces
* Desktop: Temp fix for old backlight bug when locking by holding up arrow
* IR: Add Sharp and Vizio to Universal TV remote
* BLE Info: Show version instead of branch
* Plugins: Add new game - Bomberduck (by @leo-need-more-coffee | PR #450)
* Plugins: Fix `SWD Probe` plugin GPIO pins state reset on exit
* Plugins: Bluetooth Remote - new UI (by @krolchonok | PR #447)
* Plugins: Update **TOTP (Authenticator)** [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator)
* Plugins: Fix RFID Fuzzer and iButton Fuzzer crashes
* Plugins: iButton Fuzzer default keys update (by @team-orangeBlue)
* Infrared: Updated infrared assets (by @amec0e | PR #441)
* Docs: Update **How To Install** images (by @krolchonok | PR #436)
* OFW PR 2620: NFC: Fix reading Mifare Classic cards with unusual access conditions and fix emulation of unknown keys (by Astrrra)
* OFW PR 2616: Picopass: remove spaces in CSN (by bettse)
* OFW PR 2604: WS: add protocol "Wendox W6726" (by Skorpionm)
* OFW PR 2607: BadUSB: command parser fix (by nminaylov)
* OFW: Keep HSI16 working in stop mode.
* OFW: FuriHal: use proper divider for core2 when transition to sleep, remove extra stop mode transition checks, cleanup code. Furi: proper assert and check messages.
* OFW: Don't reboot on crash in debug builds
* OFW: cubewb: downgraded to v1.15.0
* Docs: Update HowToInstall (by @krolchonok | PR #443)
* OFW PR 2627: Add HID mouse auto-clicker (by @rwl4)
#### [🎲 Download latest extra apps pack](https://github.com/xMasterX/all-the-plugins/archive/refs/heads/main.zip)

View File

@@ -176,6 +176,7 @@ Games:
- Solitaire [(by teeebor)](https://github.com/teeebor/flipper_games)
- BlackJack [(by teeebor)](https://github.com/teeebor/flipper_games)
- 2048 game [(by eugene-kirzhanov)](https://github.com/eugene-kirzhanov/flipper-zero-2048-game)
- Bomberduck [(by leo-need-more-coffee)](https://github.com/leo-need-more-coffee/flipperzero-bomberduck)
# Instructions

View File

@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2023 лень
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,2 @@
# flipperzero-bomberduck
Bomberman clone on flipper zero!

View File

@@ -0,0 +1,14 @@
App(
appid="bomberduck",
name="Bomberduck",
apptype=FlipperAppType.EXTERNAL,
entry_point="bomberduck_app",
requires=[
"gui",
],
stack_size=1 * 1024,
order=90,
fap_icon="bomb.png",
fap_category="Games",
fap_icon_assets="assets",
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,648 @@
#include <stdio.h>
#include <furi.h>
#include <gui/gui.h>
#include <input/input.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <gui/canvas_i.h>
#include "bomberduck_icons.h"
#include <dolphin/dolphin.h>
int max(int a, int b) {
return (a > b) ? a : b;
}
int min(int a, int b) {
return (a < b) ? a : b;
}
#define WorldSizeX 12
#define WorldSizeY 6
#define BombRange 1
typedef struct {
FuriMutex* mutex;
} BomberState;
typedef struct {
int row;
int col;
} Cell;
typedef struct {
Cell cells[WorldSizeY * WorldSizeX];
int front;
int rear;
} Queue;
void enqueue(Queue* q, Cell c) {
q->cells[q->rear] = c;
q->rear++;
}
Cell dequeue(Queue* q) {
Cell c = q->cells[q->front];
q->front++;
return c;
}
bool is_empty(Queue* q) {
return q->front == q->rear;
}
typedef struct {
int x;
int y;
int planted;
} Bomb;
typedef struct {
int x;
int y;
bool side;
} Player;
typedef struct {
int x;
int y;
int last;
bool side;
int level;
} Enemy;
typedef struct {
int matrix[WorldSizeY][WorldSizeX];
Player* player;
bool running;
int level;
Enemy enemies[10];
int enemies_count;
Bomb bombs[100];
int bombs_count;
int endx;
int endy;
} World;
Player player = {0, 0, 1};
World world = {{{0}}, &player, 1, 0, {}, 0, {}, 0, 0, 0};
bool vibration = false;
void init() {
player.x = 1;
player.y = 1;
world.endx = 4 + rand() % 8;
world.endy = rand() % 6;
for(int i = 0; i < WorldSizeY; i++) {
for(int j = 0; j < WorldSizeX; j++) {
world.matrix[i][j] = rand() % 3;
}
}
world.running = 1;
world.bombs_count = 0;
vibration = false;
for(int j = max(0, player.y - BombRange); j < min(WorldSizeY, player.y + BombRange + 1); j++) {
world.matrix[j][player.x] = 0;
}
for(int j = max(0, player.x - BombRange); j < min(WorldSizeX, player.x + BombRange + 1); j++) {
world.matrix[player.y][j] = 0;
}
world.enemies_count = 0;
for(int j = 0; j < rand() % 4 + world.level / 5; j++) {
Enemy enemy;
enemy.x = 4 + rand() % 7;
enemy.y = rand() % 6;
enemy.last = 0;
enemy.side = 1;
enemy.level = 0;
world.enemies[j] = enemy;
world.enemies_count++;
for(int m = max(0, world.enemies[j].y - BombRange);
m < min(WorldSizeY, world.enemies[j].y + BombRange + 1);
m++) {
world.matrix[m][world.enemies[j].x] = 0;
}
for(int m = max(0, world.enemies[j].x - BombRange);
m < min(WorldSizeX, world.enemies[j].x + BombRange + 1);
m++) {
world.matrix[world.enemies[j].y][m] = 0;
}
}
world.matrix[world.endy][world.endx] = 1;
}
const NotificationSequence end = {
&message_vibro_on,
&message_note_ds4,
&message_delay_10,
&message_sound_off,
&message_delay_10,
&message_note_ds4,
&message_delay_10,
&message_sound_off,
&message_delay_10,
&message_note_ds4,
&message_delay_10,
&message_sound_off,
&message_delay_10,
&message_vibro_off,
NULL,
};
static const NotificationSequence bomb2 = {
&message_vibro_on,
&message_delay_25,
&message_vibro_off,
NULL,
};
static const NotificationSequence bomb_explore = {
&message_vibro_on,
&message_delay_50,
&message_vibro_off,
NULL,
};
static const NotificationSequence vibr1 = {
&message_vibro_on,
&message_delay_10,
&message_vibro_off,
&message_delay_10,
&message_vibro_on,
&message_delay_10,
&message_vibro_off,
&message_delay_10,
NULL,
};
void intToStr(int num, char* str) {
int i = 0, sign = 0;
if(num < 0) {
num = -num;
sign = 1;
}
do {
str[i++] = num % 10 + '0';
num /= 10;
} while(num > 0);
if(sign) {
str[i++] = '-';
}
str[i] = '\0';
// Reverse the string
int j, len = i;
char temp;
for(j = 0; j < len / 2; j++) {
temp = str[j];
str[j] = str[len - j - 1];
str[len - j - 1] = temp;
}
}
bool BFS() {
// Initialize visited array and queue
int visited[WorldSizeY][WorldSizeX] = {0};
Queue q = {.front = 0, .rear = 0};
// Mark the starting cell as visited and enqueue it
visited[world.player->y][world.player->x] = 1;
Cell startCell = {.row = world.player->y, .col = world.player->x};
enqueue(&q, startCell);
// Traverse the field
while(!is_empty(&q)) {
// Dequeue a cell from the queue
Cell currentCell = dequeue(&q);
// Check if the current cell is the destination cell
if(currentCell.row == world.endy && currentCell.col == world.endx) {
return true;
}
// Check the neighboring cells
for(int rowOffset = -1; rowOffset <= 1; rowOffset++) {
for(int colOffset = -1; colOffset <= 1; colOffset++) {
// Skip diagonals and the current cell
if(rowOffset == 0 && colOffset == 0) {
continue;
}
if(rowOffset != 0 && colOffset != 0) {
continue;
}
// Calculate the row and column of the neighboring cell
int neighborRow = currentCell.row + rowOffset;
int neighborCol = currentCell.col + colOffset;
// Skip out-of-bounds cells and already visited cells
if(neighborRow < 0 || neighborRow >= WorldSizeY || neighborCol < 0 ||
neighborCol >= WorldSizeX) {
continue;
}
if(visited[neighborRow][neighborCol]) {
continue;
}
// Mark the neighboring cell as visited and enqueue it
if(world.matrix[neighborRow][neighborCol] != 2) {
visited[neighborRow][neighborCol] = 1;
Cell neighborCell = {.row = neighborRow, .col = neighborCol};
enqueue(&q, neighborCell);
}
}
}
}
return false;
}
static void draw_callback(Canvas* canvas, void* ctx) {
furi_assert(ctx);
const BomberState* bomber_state = ctx;
furi_mutex_acquire(bomber_state->mutex, FuriWaitForever);
if(!BFS()) {
init();
}
canvas_clear(canvas);
canvas_draw_icon(canvas, world.endx * 10 + 4, world.endy * 10 + 2, &I_end);
if(world.running) {
for(size_t i = 0; i < WorldSizeY; i++) {
for(size_t j = 0; j < WorldSizeX; j++) {
switch(world.matrix[i][j]) {
case 0:
break;
case 1:
canvas_draw_icon(canvas, j * 10 + 4, i * 10 + 2, &I_box);
break;
case 2:
canvas_draw_icon(canvas, j * 10 + 4, i * 10 + 2, &I_unbreakbox);
break;
case 3:
canvas_draw_icon(canvas, j * 10 + 4, i * 10 + 2, &I_bomb0);
break;
case 4:
canvas_draw_icon(canvas, j * 10 + 4, i * 10 + 2, &I_bomb1);
break;
case 5:
canvas_draw_icon(canvas, j * 10 + 4, i * 10 + 2, &I_bomb2);
break;
case 6:
canvas_draw_icon(canvas, j * 10 + 4, i * 10 + 2, &I_explore);
world.matrix[i][j] = 0;
break;
}
}
}
if(world.player->side) {
canvas_draw_icon(
canvas, world.player->x * 10 + 4, world.player->y * 10 + 2, &I_playerright);
} else {
canvas_draw_icon(
canvas, world.player->x * 10 + 4, world.player->y * 10 + 2, &I_playerleft);
}
for(int i = 0; i < world.enemies_count; i++) {
if(world.enemies[i].level > 0) {
canvas_draw_icon(
canvas, world.enemies[i].x * 10 + 4, world.enemies[i].y * 10 + 2, &I_enemy1);
} else {
if(world.enemies[i].side) {
canvas_draw_icon(
canvas,
world.enemies[i].x * 10 + 4,
world.enemies[i].y * 10 + 2,
&I_enemyright);
} else {
canvas_draw_icon(
canvas,
world.enemies[i].x * 10 + 4,
world.enemies[i].y * 10 + 2,
&I_enemyleft);
}
}
}
} else {
canvas_set_font(canvas, FontPrimary);
if(world.player->x == world.endx && world.player->y == world.endy) {
if(world.level == 20) {
canvas_draw_str(canvas, 30, 35, "You win!");
} else {
canvas_draw_str(canvas, 30, 35, "Next level!");
char str[20];
intToStr(world.level, str);
canvas_draw_str(canvas, 90, 35, str);
}
} else {
canvas_draw_str(canvas, 30, 35, "You died :(");
}
}
furi_mutex_release(bomber_state->mutex);
}
static void input_callback(InputEvent* input_event, void* ctx) {
// Проверяем, что контекст не нулевой
furi_assert(ctx);
FuriMessageQueue* event_queue = ctx;
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
}
int32_t bomberduck_app(void* p) {
UNUSED(p);
// Текущее событие типа InputEvent
InputEvent event;
// Очередь событий на 8 элементов размера InputEvent
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
BomberState* bomber_state = malloc(sizeof(BomberState));
bomber_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal); // Alloc Mutex
if(!bomber_state->mutex) {
FURI_LOG_E("BomberDuck", "cannot create mutex\r\n");
furi_message_queue_free(event_queue);
free(bomber_state);
return 255;
}
DOLPHIN_DEED(DolphinDeedPluginGameStart);
// Создаем новый view port
ViewPort* view_port = view_port_alloc();
// Создаем callback отрисовки, без контекста
view_port_draw_callback_set(view_port, draw_callback, bomber_state);
// Создаем callback нажатий на клавиши, в качестве контекста передаем
// нашу очередь сообщений, чтоб запихивать в неё эти события
view_port_input_callback_set(view_port, input_callback, event_queue);
// Создаем GUI приложения
Gui* gui = furi_record_open(RECORD_GUI);
// Подключаем view port к GUI в полноэкранном режиме
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message_block(notification, &sequence_display_backlight_enforce_on);
init();
// Бесконечный цикл обработки очереди событий
while(1) {
if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
furi_mutex_acquire(bomber_state->mutex, FuriWaitForever);
// Если нажата кнопка "назад", то выходим из цикла, а следовательно и из приложения
if(event.type == InputTypePress) {
if(event.key == InputKeyOk) {
if(world.running) {
if(world.matrix[world.player->y][world.player->x] == 0 &&
world.bombs_count < 2) {
notification_message(notification, &bomb2);
world.matrix[world.player->y][world.player->x] = 3;
Bomb bomb = {world.player->x, world.player->y, furi_get_tick()};
world.bombs[world.bombs_count] = bomb;
world.bombs_count++;
}
} else {
init();
}
}
if(world.running) {
if(event.key == InputKeyUp) {
if(world.player->y > 0 &&
world.matrix[world.player->y - 1][world.player->x] == 0)
world.player->y--;
}
if(event.key == InputKeyDown) {
if(world.player->y < WorldSizeY - 1 &&
world.matrix[world.player->y + 1][world.player->x] == 0)
world.player->y++;
}
if(event.key == InputKeyLeft) {
world.player->side = 0;
if(world.player->x > 0 &&
world.matrix[world.player->y][world.player->x - 1] == 0)
world.player->x--;
}
if(event.key == InputKeyRight) {
world.player->side = 1;
if(world.player->x < WorldSizeX - 1 &&
world.matrix[world.player->y][world.player->x + 1] == 0)
world.player->x++;
}
}
} else if(event.type == InputTypeLong) {
if(event.key == InputKeyBack) {
break;
}
}
}
if(world.running) {
if(world.player->x == world.endx && world.player->y == world.endy) {
notification_message(notification, &end);
world.running = 0;
world.level += 1;
if(world.level % 5 == 0) {
DOLPHIN_DEED(DolphinDeedPluginGameWin);
}
}
for(int i = 0; i < world.bombs_count; i++) {
if(furi_get_tick() - world.bombs[i].planted >
(unsigned long)max((3000 - world.level * 150), 1000)) {
vibration = false;
world.matrix[world.bombs[i].y][world.bombs[i].x] = 6;
notification_message(notification, &bomb_explore);
for(int j = max(0, world.bombs[i].y - BombRange);
j < min(WorldSizeY, world.bombs[i].y + BombRange + 1);
j++) {
if(world.matrix[j][world.bombs[i].x] != 2) {
world.matrix[j][world.bombs[i].x] = 6;
if(j == world.player->y && world.bombs[i].x == world.player->x) {
notification_message(notification, &end);
world.running = 0;
}
for(int e = 0; e < world.enemies_count; e++) {
if(j == world.enemies[e].y &&
world.bombs[i].x == world.enemies[e].x) {
if(world.enemies[e].level > 0) {
world.enemies[e].level--;
} else {
for(int l = e; l < world.enemies_count - 1; l++) {
world.enemies[l] = world.enemies[l + 1];
}
world.enemies_count--;
}
}
}
}
}
for(int j = max(0, world.bombs[i].x - BombRange);
j < min(WorldSizeX, world.bombs[i].x + BombRange + 1);
j++) {
if(world.matrix[world.bombs[i].y][j] != 2) {
world.matrix[world.bombs[i].y][j] = 6;
if(world.bombs[i].y == world.player->y && j == world.player->x) {
notification_message(notification, &end);
world.running = 0;
}
for(int e = 0; e < world.enemies_count; e++) {
if(world.bombs[i].y == world.enemies[e].y &&
j == world.enemies[e].x) {
if(world.enemies[e].level > 0) {
world.enemies[e].level--;
} else {
for(int l = e; l < world.enemies_count - 1; l++) {
world.enemies[l] = world.enemies[l + 1];
}
world.enemies_count--;
}
}
}
}
}
for(int j = i; j < world.bombs_count - 1; j++) {
world.bombs[j] = world.bombs[j + 1];
}
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) {
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) {
world.matrix[world.bombs[i].y][world.bombs[i].x] = 4;
}
}
for(int e = 0; e < world.enemies_count; e++) {
if(world.player->y == world.enemies[e].y &&
world.player->x == world.enemies[e].x) {
notification_message(notification, &end);
world.running = 0;
}
}
for(int e = 0; e < world.enemies_count; e++) {
if(world.enemies[e].level > 0) {
if(furi_get_tick() - world.enemies[e].last >
(unsigned long)max((2000 - world.level * 100), 1000)) {
world.enemies[e].last = furi_get_tick();
int move = rand() % 4;
switch(move) {
case 0:
if(world.enemies[e].y > 0 &&
world.matrix[world.enemies[e].y - 1][world.enemies[e].x] != 2)
world.enemies[e].y--;
break;
case 1:
if(world.enemies[e].y < WorldSizeY - 1 &&
world.matrix[world.enemies[e].y + 1][world.enemies[e].x] != 2)
world.enemies[e].y++;
break;
case 2:
world.enemies[e].side = 0;
if(world.enemies[e].x > 0 &&
world.matrix[world.enemies[e].y][world.enemies[e].x - 1] != 2)
world.enemies[e].x--;
break;
case 3:
world.enemies[e].side = 1;
if(world.enemies[e].x < WorldSizeX - 1 &&
world.matrix[world.enemies[e].y][world.enemies[e].x + 1] != 2)
world.enemies[e].x++;
default:
break;
}
}
} else {
if(furi_get_tick() - world.enemies[e].last >
(unsigned long)max((1000 - world.level * 50), 500)) {
world.enemies[e].last = furi_get_tick();
int move = rand() % 4;
switch(move) {
case 0:
if(world.enemies[e].y > 0 &&
world.matrix[world.enemies[e].y - 1][world.enemies[e].x] == 0)
world.enemies[e].y--;
break;
case 1:
if(world.enemies[e].y < WorldSizeY - 1 &&
world.matrix[world.enemies[e].y + 1][world.enemies[e].x] == 0)
world.enemies[e].y++;
break;
case 2:
world.enemies[e].side = 0;
if(world.enemies[e].x > 0 &&
world.matrix[world.enemies[e].y][world.enemies[e].x - 1] == 0)
world.enemies[e].x--;
break;
case 3:
world.enemies[e].side = 1;
if(world.enemies[e].x < WorldSizeX - 1 &&
world.matrix[world.enemies[e].y][world.enemies[e].x + 1] == 0)
world.enemies[e].x++;
default:
break;
}
}
}
}
for(int e = 0; e < world.enemies_count; e++) {
for(int h = e + 1; h < world.enemies_count; h++) {
if(world.enemies[e].y == world.enemies[h].y &&
world.enemies[e].x == world.enemies[h].x) {
world.enemies[h].level++;
for(int l = e; l < world.enemies_count - 1; l++) {
world.enemies[l] = world.enemies[l + 1];
}
world.enemies_count--;
}
}
}
if(vibration) {
notification_message(notification, &vibr1);
}
}
view_port_update(view_port);
furi_mutex_release(bomber_state->mutex);
}
// Return to normal backlight settings
notification_message_block(notification, &sequence_display_backlight_enforce_auto);
furi_record_close(RECORD_NOTIFICATION);
// Специальная очистка памяти, занимаемой очередью
furi_message_queue_free(event_queue);
// Чистим созданные объекты, связанные с интерфейсом
gui_remove_view_port(gui, view_port);
view_port_free(view_port);
furi_mutex_free(bomber_state->mutex);
furi_record_close(RECORD_GUI);
free(bomber_state);
return 0;
}

View File

@@ -14,6 +14,7 @@ enum HidDebugSubmenuIndex {
HidSubmenuIndexTikTok,
HidSubmenuIndexYTShorts,
HidSubmenuIndexMouse,
HidSubmenuIndexMouseClicker,
HidSubmenuIndexMouseJiggler,
};
@@ -44,6 +45,9 @@ static void hid_submenu_callback(void* context, uint32_t index) {
} else if(index == HidSubmenuIndexYTShorts) {
app->view_id = BtHidViewYTShorts;
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewYTShorts);
} else if(index == HidSubmenuIndexMouseClicker) {
app->view_id = HidViewMouseClicker;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseClicker);
} else if(index == HidSubmenuIndexMouseJiggler) {
app->view_id = HidViewMouseJiggler;
view_dispatcher_switch_to_view(app->view_dispatcher, HidViewMouseJiggler);
@@ -67,6 +71,7 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con
hid_numpad_set_connected_status(hid->hid_numpad, connected);
hid_media_set_connected_status(hid->hid_media, connected);
hid_mouse_set_connected_status(hid->hid_mouse, connected);
hid_mouse_clicker_set_connected_status(hid->hid_mouse_clicker, connected);
hid_mouse_jiggler_set_connected_status(hid->hid_mouse_jiggler, connected);
hid_tiktok_set_connected_status(hid->hid_tiktok, connected);
hid_ytshorts_set_connected_status(hid->hid_ytshorts, connected);
@@ -143,6 +148,12 @@ Hid* hid_alloc(HidTransport transport) {
hid_submenu_callback,
app);
}
submenu_add_item(
app->device_type_submenu,
"Mouse Clicker",
HidSubmenuIndexMouseClicker,
hid_submenu_callback,
app);
submenu_add_item(
app->device_type_submenu,
"Mouse Jiggler",
@@ -222,6 +233,14 @@ Hid* hid_app_alloc_view(void* context) {
view_dispatcher_add_view(
app->view_dispatcher, HidViewMouse, hid_mouse_get_view(app->hid_mouse));
// Mouse clicker view
app->hid_mouse_clicker = hid_mouse_clicker_alloc(app);
view_set_previous_callback(
hid_mouse_clicker_get_view(app->hid_mouse_clicker), hid_exit_confirm_view);
view_dispatcher_add_view(
app->view_dispatcher,
HidViewMouseClicker,
hid_mouse_clicker_get_view(app->hid_mouse_clicker));
// Mouse jiggler view
app->hid_mouse_jiggler = hid_mouse_jiggler_alloc(app);
view_set_previous_callback(
@@ -259,6 +278,8 @@ void hid_free(Hid* app) {
hid_media_free(app->hid_media);
view_dispatcher_remove_view(app->view_dispatcher, HidViewMouse);
hid_mouse_free(app->hid_mouse);
view_dispatcher_remove_view(app->view_dispatcher, HidViewMouseClicker);
hid_mouse_clicker_free(app->hid_mouse_clicker);
view_dispatcher_remove_view(app->view_dispatcher, HidViewMouseJiggler);
hid_mouse_jiggler_free(app->hid_mouse_jiggler);
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewTikTok);

View File

@@ -25,6 +25,7 @@
#include "views/hid_mouse_jiggler.h"
#include "views/hid_tiktok.h"
#include "views/hid_ytshorts.h"
#include "views/hid_mouse_clicker.h"
#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"
@@ -48,6 +49,7 @@ struct Hid {
HidNumpad* hid_numpad;
HidMedia* hid_media;
HidMouse* hid_mouse;
HidMouseClicker* hid_mouse_clicker;
HidMouseJiggler* hid_mouse_jiggler;
HidTikTok* hid_tiktok;
HidYTShorts* hid_ytshorts;

View File

@@ -6,6 +6,7 @@ typedef enum {
HidViewNumpad,
HidViewMedia,
HidViewMouse,
HidViewMouseClicker,
HidViewMouseJiggler,
BtHidViewTikTok,
BtHidViewYTShorts,

View File

@@ -0,0 +1,214 @@
#include "hid_mouse_clicker.h"
#include <gui/elements.h>
#include "../hid.h"
#include "hid_icons.h"
#define TAG "HidMouseClicker"
#define DEFAULT_CLICK_RATE 1
#define MAXIMUM_CLICK_RATE 60
struct HidMouseClicker {
View* view;
Hid* hid;
FuriTimer* timer;
};
typedef struct {
bool connected;
bool running;
int rate;
HidTransport transport;
} HidMouseClickerModel;
static void hid_mouse_clicker_start_or_restart_timer(void* context) {
furi_assert(context);
HidMouseClicker* hid_mouse_clicker = context;
if(furi_timer_is_running(hid_mouse_clicker->timer)) {
furi_timer_stop(hid_mouse_clicker->timer);
}
with_view_model(
hid_mouse_clicker->view,
HidMouseClickerModel * model,
{
furi_timer_start(
hid_mouse_clicker->timer, furi_kernel_get_tick_frequency() / model->rate);
},
true);
}
static void hid_mouse_clicker_draw_callback(Canvas* canvas, void* context) {
furi_assert(context);
HidMouseClickerModel* model = context;
// Header
if(model->transport == HidTransportBle) {
if(model->connected) {
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
} else {
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
}
}
canvas_set_font(canvas, FontPrimary);
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse Clicker");
// Ok
canvas_draw_icon(canvas, 63, 25, &I_Space_65x18);
if(model->running) {
canvas_set_font(canvas, FontPrimary);
FuriString* rate_label = furi_string_alloc();
furi_string_printf(rate_label, "%d clicks/s\n\nUp / Down", model->rate);
elements_multiline_text(canvas, AlignLeft, 35, furi_string_get_cstr(rate_label));
canvas_set_font(canvas, FontSecondary);
furi_string_free(rate_label);
elements_slightly_rounded_box(canvas, 66, 27, 60, 13);
canvas_set_color(canvas, ColorWhite);
} else {
canvas_set_font(canvas, FontPrimary);
elements_multiline_text(canvas, AlignLeft, 35, "Press Start\nto start\nclicking");
canvas_set_font(canvas, FontSecondary);
}
canvas_draw_icon(canvas, 74, 29, &I_Ok_btn_9x9);
if(model->running) {
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Stop");
} else {
elements_multiline_text_aligned(canvas, 91, 36, AlignLeft, AlignBottom, "Start");
}
canvas_set_color(canvas, ColorBlack);
// Back
canvas_draw_icon(canvas, 74, 49, &I_Pin_back_arrow_10x8);
elements_multiline_text_aligned(canvas, 91, 57, AlignLeft, AlignBottom, "Quit");
}
static void hid_mouse_clicker_timer_callback(void* context) {
furi_assert(context);
HidMouseClicker* hid_mouse_clicker = context;
with_view_model(
hid_mouse_clicker->view,
HidMouseClickerModel * model,
{
if(model->running) {
hid_hal_mouse_press(hid_mouse_clicker->hid, HID_MOUSE_BTN_LEFT);
hid_hal_mouse_release(hid_mouse_clicker->hid, HID_MOUSE_BTN_LEFT);
}
},
false);
}
static void hid_mouse_clicker_enter_callback(void* context) {
hid_mouse_clicker_start_or_restart_timer(context);
}
static void hid_mouse_clicker_exit_callback(void* context) {
furi_assert(context);
HidMouseClicker* hid_mouse_clicker = context;
furi_timer_stop(hid_mouse_clicker->timer);
}
static bool hid_mouse_clicker_input_callback(InputEvent* event, void* context) {
furi_assert(context);
HidMouseClicker* hid_mouse_clicker = context;
bool consumed = false;
bool rate_changed = false;
if(event->type != InputTypeRelease) {
return false;
}
with_view_model(
hid_mouse_clicker->view,
HidMouseClickerModel * model,
{
switch(event->key) {
case InputKeyOk:
model->running = !model->running;
consumed = true;
break;
case InputKeyUp:
if(model->rate < MAXIMUM_CLICK_RATE) {
model->rate++;
}
rate_changed = true;
consumed = true;
break;
case InputKeyDown:
if(model->rate > 1) {
model->rate--;
}
rate_changed = true;
consumed = true;
break;
default:
consumed = true;
break;
}
},
true);
if(rate_changed) {
hid_mouse_clicker_start_or_restart_timer(context);
}
return consumed;
}
HidMouseClicker* hid_mouse_clicker_alloc(Hid* hid) {
HidMouseClicker* hid_mouse_clicker = malloc(sizeof(HidMouseClicker));
hid_mouse_clicker->view = view_alloc();
view_set_context(hid_mouse_clicker->view, hid_mouse_clicker);
view_allocate_model(
hid_mouse_clicker->view, ViewModelTypeLocking, sizeof(HidMouseClickerModel));
view_set_draw_callback(hid_mouse_clicker->view, hid_mouse_clicker_draw_callback);
view_set_input_callback(hid_mouse_clicker->view, hid_mouse_clicker_input_callback);
view_set_enter_callback(hid_mouse_clicker->view, hid_mouse_clicker_enter_callback);
view_set_exit_callback(hid_mouse_clicker->view, hid_mouse_clicker_exit_callback);
hid_mouse_clicker->hid = hid;
hid_mouse_clicker->timer = furi_timer_alloc(
hid_mouse_clicker_timer_callback, FuriTimerTypePeriodic, hid_mouse_clicker);
with_view_model(
hid_mouse_clicker->view,
HidMouseClickerModel * model,
{
model->transport = hid->transport;
model->rate = DEFAULT_CLICK_RATE;
},
true);
return hid_mouse_clicker;
}
void hid_mouse_clicker_free(HidMouseClicker* hid_mouse_clicker) {
furi_assert(hid_mouse_clicker);
furi_timer_stop(hid_mouse_clicker->timer);
furi_timer_free(hid_mouse_clicker->timer);
view_free(hid_mouse_clicker->view);
free(hid_mouse_clicker);
}
View* hid_mouse_clicker_get_view(HidMouseClicker* hid_mouse_clicker) {
furi_assert(hid_mouse_clicker);
return hid_mouse_clicker->view;
}
void hid_mouse_clicker_set_connected_status(HidMouseClicker* hid_mouse_clicker, bool connected) {
furi_assert(hid_mouse_clicker);
with_view_model(
hid_mouse_clicker->view,
HidMouseClickerModel * model,
{ model->connected = connected; },
true);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <gui/view.h>
typedef struct Hid Hid;
typedef struct HidMouseClicker HidMouseClicker;
HidMouseClicker* hid_mouse_clicker_alloc(Hid* bt_hid);
void hid_mouse_clicker_free(HidMouseClicker* hid_mouse_clicker);
View* hid_mouse_clicker_get_view(HidMouseClicker* hid_mouse_clicker);
void hid_mouse_clicker_set_connected_status(HidMouseClicker* hid_mouse_clicker, bool connected);

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");
}
static void hid_ytshorts_reset_cursor(HidYTShorts* hid_ytshorts) {
// Set cursor to the phone's left up corner
// Delays to guarantee one packet per connection interval

View File

@@ -3166,6 +3166,11 @@ int32_t swd_probe_app_main(void* p) {
furi_message_queue_free(app->event_queue);
furi_mutex_free(app->gui_mutex);
furi_mutex_free(app->swd_mutex);
// Reset GPIO pins to default state
for(int io = 0; io < 8; io++) {
furi_hal_gpio_init(gpios[io], GpioModeAnalog, GpioPullNo, GpioSpeedLow);
}
free(app);
furi_record_close(RECORD_GUI);

View File

@@ -30,7 +30,7 @@ static uint32_t get_keypress_delay(TokenAutomationFeature features) {
}
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_release_fn,
TokenAutomationFeature features) {
@@ -47,8 +47,6 @@ void totp_type_code_worker_execute_automation(
TokenAutomationFeature features) {
furi_delay_ms(500);
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) {
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;
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);
furi_delay_ms(get_keystroke_delay(features));
i++;
@@ -74,7 +76,4 @@ void totp_type_code_worker_execute_automation(
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_CAPS_LOCK, key_press_fn, key_release_fn, features);
}

View File

@@ -242,5 +242,6 @@ bool desktop_view_locked_is_locked_hint_visible(DesktopViewLocked* locked_view)
DesktopViewLockedModel* model = view_get_model(locked_view->view);
const DesktopViewLockedState view_state = model->view_state;
view_commit_model(locked_view->view, false);
return view_state == DesktopViewLockedStateLockedHintShown;
return view_state == DesktopViewLockedStateLockedHintShown ||
view_state == DesktopViewLockedStateLocked;
}

View File

@@ -1,7 +1,7 @@
Filetype: IR library file
Version: 1
# Last Updated 07th Mar, 2023
# Last Checked 25th Apr, 2023
# Last Updated 2, May, 2023
# Last Checked 2, May, 2023
#
name: POWER
type: parsed
@@ -1899,3 +1899,39 @@ type: parsed
protocol: SIRC20
address: 10 01 00 00
command: 33 00 00 00
#
name: POWER
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 195 1833 300 766 280 760 275 790 276 737 309 731 304 1801 301 1804 309 731 304 1801 270 795 282 758 277 762 273 1832 270 769 246 45851 326 1780 302 739 307 785 282 732 303 736 310 1795 307 732 303 763 303 1775 307 733 334 1798 273 1832 270 1810 251 814 273 1780 281 43762 302 1804 309 758 277 737 330 762 284 730 305 734 301 1803 310 1796 306 733 302 1829 273 767 279 734 301 791 275 1804 278 762 253 45870 307 1798 304 763 272 767 279 787 279 760 275 1829 284 730 305 734 301 1804 309 757 278 1827 275 1804 278 1828 274 765 270 1835 278 43740 303 1776 306 787 279 760 275 765 281 759 307 758 277 1775 307 1799 303 736 299 1832 281 759 276 763 304 736 299 1832 281 733 302 45820 306 1800 302 764 282 758 277 788 278 762 284 1821 281 732 303 736 310 1796 307 733 302 1829 273 1806 276 1830 272 767 268 1837 245 43772 302 1778 304 789 277 762 284 756 279 786 249 765 301 1777 336 1770 301 764 282 1824 278 761 274 765 301 738 308 1824 278 761 274
#
name: MUTE
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 254 1721 360 681 354 738 308 706 329 711 355 1774 307 1772 361 1744 327 687 359 1772 299 742 335 705 330 736 279 1825 298 742 283 44773 384 1721 360 707 308 707 359 733 302 711 335 705 361 704 331 708 338 1766 336 704 331 1773 329 1776 306 1773 360 681 323 1782 331 44726 411 1722 328 686 360 733 302 711 335 705 361 1742 329 1803 330 1749 332 708 327 1777 335 705 330 710 325 741 274 1830 303 737 278 44778 359 1747 355 712 303 711 355 711 335 705 330 709 337 703 363 703 332 1770 332 709 337 1767 335 1771 300 1752 360 733 302 1776 326 44731 355 1751 330 711 355 737 309 705 330 710 336 1793 309 1771 331 1774 307 706 360 1771 300 740 326 714 332 735 280 1798 325 741 274
#
name: POWER
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 9219 4484 662 469 661 469 661 1627 660 471 658 474 656 499 631 499 631 499 631 1657 630 1657 631 500 630 1657 631 1657 631 1657 630 1657 631 1657 631 500 630 500 630 500 630 1657 630 500 631 500 630 500 631 500 630 1657 630 1658 630 1657 631 500 630 1657 631 1658 630 1658 630 1658 630 40107 9106 2202 631
#
name: VOL+
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 9218 4484 636 495 660 469 661 1627 660 471 658 472 658 474 656 475 655 474 656 1632 655 1632 656 474 657 1632 656 1631 657 1632 656 1631 656 1632 656 474 656 1632 655 475 656 474 657 474 656 474 656 474 656 474 656 1632 655 474 656 1632 656 1632 656 1632 656 1632 656 1632 656 1632 656 40103 9107 2177 655
#
name: VOL-
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 9245 4429 689 467 662 468 661 1626 660 471 658 473 657 474 656 474 656 474 656 1631 657 1631 657 474 656 1631 656 1632 656 1631 657 1631 657 1631 656 1632 656 1631 657 474 656 474 656 474 657 474 656 474 656 474 657 474 656 474 656 1631 656 1632 656 1632 656 1632 656 1632 656 1631 656 40082 9109 2175 656
#
name: MUTE
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 9219 4485 636 495 660 469 661 1626 661 471 658 473 657 474 656 499 631 500 630 1657 630 1657 631 500 630 1657 630 1657 631 1657 631 1657 630 1657 631 1657 631 500 630 500 630 1657 631 500 630 500 630 500 630 500 631 500 630 1657 631 1657 631 500 630 1657 631 1658 630 1657 631 1658 630 39868 9106 2178 655

Binary file not shown.

Before

Width:  |  Height:  |  Size: 933 B

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -892,25 +892,11 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
MfClassicSectorTrailer* sector_trailer =
(MfClassicSectorTrailer*)emulator->data.block[sector_trailer_block].value;
if(cmd == MF_CLASSIC_AUTH_KEY_A_CMD) {
if(mf_classic_is_key_found(
&emulator->data, mf_classic_get_sector_by_block(block), MfClassicKeyA)) {
key = nfc_util_bytes2num(sector_trailer->key_a, 6);
access_key = MfClassicKeyA;
} else {
FURI_LOG_D(TAG, "Key not known");
command_processed = true;
break;
}
key = nfc_util_bytes2num(sector_trailer->key_a, 6);
access_key = MfClassicKeyA;
} else {
if(mf_classic_is_key_found(
&emulator->data, mf_classic_get_sector_by_block(block), MfClassicKeyB)) {
key = nfc_util_bytes2num(sector_trailer->key_b, 6);
access_key = MfClassicKeyB;
} else {
FURI_LOG_D(TAG, "Key not known");
command_processed = true;
break;
}
key = nfc_util_bytes2num(sector_trailer->key_b, 6);
access_key = MfClassicKeyB;
}
uint32_t nonce = prng_successor(DWT->CYCCNT, 32) ^ 0xAA;