mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-16 20:09:44 -07:00
autofire upd
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build application
|
||||
steps:
|
||||
- name: Cache toolchain
|
||||
uses: actions/cache@v3
|
||||
id: toolchain-cache
|
||||
with:
|
||||
path: ./firmware
|
||||
key: firmware
|
||||
- name: Checkout firmware
|
||||
if: steps.toolchain-cache.outputs.cache-hit != 'true'
|
||||
run: git clone https://github.com/flipperdevices/flipperzero-firmware.git --recursive --depth 1 firmware
|
||||
- name: Install toolchain
|
||||
if: steps.toolchain-cache.outputs.cache-hit != 'true'
|
||||
run: cd firmware && ./fbt
|
||||
- name: Checkout application
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: firmware/applications_user/usb_hid_autofire
|
||||
- name: Build application
|
||||
run: cd firmware && ./fbt fap_usb_hid_autofire
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.1 KiB |
@@ -20,9 +20,13 @@ typedef struct {
|
||||
} UsbMouseEvent;
|
||||
|
||||
bool btn_left_autofire = false;
|
||||
uint32_t autofire_delay = 10;
|
||||
|
||||
static void usb_hid_autofire_render_callback(Canvas* canvas, void* ctx) {
|
||||
UNUSED(ctx);
|
||||
char autofire_delay_str[12];
|
||||
itoa(autofire_delay, autofire_delay_str, 10);
|
||||
|
||||
canvas_clear(canvas);
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
@@ -33,6 +37,8 @@ static void usb_hid_autofire_render_callback(Canvas* canvas, void* ctx) {
|
||||
canvas_draw_str(canvas, 96, 10, VERSION);
|
||||
canvas_draw_str(canvas, 0, 22, "Press [ok] for auto left clicking");
|
||||
canvas_draw_str(canvas, 0, 34, btn_left_autofire ? "<active>" : "<inactive>");
|
||||
canvas_draw_str(canvas, 0, 46, "delay [ms]:");
|
||||
canvas_draw_str(canvas, 50, 46, autofire_delay_str);
|
||||
canvas_draw_str(canvas, 0, 63, "Press [back] to exit");
|
||||
}
|
||||
|
||||
@@ -45,10 +51,6 @@ static void usb_hid_autofire_input_callback(InputEvent* input_event, void* ctx)
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
//void wait(int ticks) {
|
||||
// for (int i = 0; i < ticks; i++) {}
|
||||
//}
|
||||
|
||||
int32_t usb_hid_autofire_app(void* p) {
|
||||
UNUSED(p);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(UsbMouseEvent));
|
||||
@@ -78,17 +80,34 @@ int32_t usb_hid_autofire_app(void* p) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(event.input.key == InputKeyOk && event.input.type == InputTypeRelease) {
|
||||
btn_left_autofire = !btn_left_autofire;
|
||||
if(event.input.type != InputTypeRelease) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(event.input.key) {
|
||||
case InputKeyOk:
|
||||
btn_left_autofire = !btn_left_autofire;
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
if(autofire_delay > 0) {
|
||||
autofire_delay -= 10;
|
||||
}
|
||||
break;
|
||||
case InputKeyRight:
|
||||
autofire_delay += 10;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(btn_left_autofire) {
|
||||
furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT);
|
||||
// wait(100);
|
||||
// TODO: Don't wait, but use the timer directly to just don't send the release event (see furi_hal_cortex_delay_us)
|
||||
furi_delay_us(autofire_delay * 500);
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT);
|
||||
// wait(100);
|
||||
furi_delay_us(autofire_delay * 500);
|
||||
}
|
||||
|
||||
view_port_update(view_port);
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define VERSION "0.2"
|
||||
#define VERSION "0.3"
|
||||
|
||||
Reference in New Issue
Block a user