Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions air_mouse/.catalog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.3
- Vertical layout, faster refresh rate
## 1.2
- Migration to new BLE profile
## 1.1
Expand Down
7 changes: 4 additions & 3 deletions air_mouse/.catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ The Air Mouse app turns Flipper Zero with the module into a computer mouse. Cont

## Controls

- Left-click: press the OK button.
- Right-click: press the UP button.
- Scrolling: press and hold the LEFT button and tilt your Flipper Zero.
- Left-click: press the Left button.
- Middle-click: press the OK button.
- Right-click: press the Right button.
- Scrolling: press and hold the UP button and tilt your Flipper Zero.
Binary file modified air_mouse/.catalog/screenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions air_mouse/air_mouse_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static const ImuHidApi hid_api_ble = {
.mouse_key_press = ble_hid_mouse_key_press,
.mouse_key_release = ble_hid_mouse_key_release,
.mouse_scroll = ble_hid_mouse_scroll,
.report_rate_max = 30,
.report_rate_max = 200,
};

static void ble_hid_remove_pairing(void) {
Expand Down Expand Up @@ -206,7 +206,6 @@ static AirMouseApp* air_mouse_alloc(void) {

app->gui = furi_record_open(RECORD_GUI);
app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(app->view_dispatcher);
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

app->air_mouse_view = air_mouse_view_alloc(air_mouse_hid_deinit, app);
Expand Down
2 changes: 1 addition & 1 deletion air_mouse/application.fam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
App(
appid="vgm_air_mouse",
name="Air Mouse",
fap_version="1.2",
fap_version="1.3",
fap_description="Turn Flipper Zero with the Video Game Module into an air mouse",
apptype=FlipperAppType.EXTERNAL,
entry_point="air_mouse_app",
Expand Down
Binary file added air_mouse/assets/Wheel_mouse_icon_9x9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 25 additions & 12 deletions air_mouse/imu_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#define ACCEL_GYRO_RATE DataRate1kHz

#define FILTER_SAMPLE_FREQ 1000.f
#define FILTER_BETA 0.08f
#define FILTER_BETA 0.08f

#define SCROLL_RATE_DIV 50
#define SCROLL_RATE_DIV 50
#define SCROLL_SENSITIVITY_K 0.25f
#define MOUSE_SENSITIVITY_K 30.f
#define EXP_RATE 1.1f
#define MOUSE_SENSITIVITY_K 30.f
#define EXP_RATE 1.1f

#define IMU_CALI_AVG 64

Expand All @@ -22,15 +22,18 @@ typedef enum {
ImuMouseNewData = (1 << 1),
ImuMouseRightPress = (1 << 2),
ImuMouseRightRelease = (1 << 3),
ImuMouseLeftPress = (1 << 4),
ImuMouseLeftRelease = (1 << 5),
ImuMouseScrollOn = (1 << 6),
ImuMouseScrollOff = (1 << 7),
ImuMouseWheelPress = (1 << 4),
ImuMouseWheelRelease = (1 << 5),
ImuMouseLeftPress = (1 << 6),
ImuMouseLeftRelease = (1 << 7),
ImuMouseScrollOn = (1 << 8),
ImuMouseScrollOff = (1 << 9),
} ImuThreadFlags;

#define FLAGS_ALL \
(ImuMouseStop | ImuMouseNewData | ImuMouseRightPress | ImuMouseRightRelease | \
ImuMouseLeftPress | ImuMouseLeftRelease | ImuMouseScrollOn | ImuMouseScrollOff)
#define FLAGS_ALL \
(ImuMouseStop | ImuMouseNewData | ImuMouseRightPress | ImuMouseRightRelease | \
ImuMouseWheelPress | ImuMouseWheelRelease | ImuMouseLeftPress | ImuMouseLeftRelease | \
ImuMouseScrollOn | ImuMouseScrollOff)

typedef struct {
float q0;
Expand Down Expand Up @@ -179,6 +182,12 @@ static int32_t imu_thread(void* context) {
if(events & ImuMouseRightRelease) {
imu->hid->mouse_key_release(imu->hid_inst, HID_MOUSE_BTN_RIGHT);
}
if(events & ImuMouseWheelPress) {
imu->hid->mouse_key_press(imu->hid_inst, HID_MOUSE_BTN_WHEEL);
}
if(events & ImuMouseWheelRelease) {
imu->hid->mouse_key_release(imu->hid_inst, HID_MOUSE_BTN_WHEEL);
}
if(events & ImuMouseLeftPress) {
imu->hid->mouse_key_press(imu->hid_inst, HID_MOUSE_BTN_LEFT);
}
Expand Down Expand Up @@ -237,7 +246,7 @@ static int32_t imu_thread(void* context) {
float mouse_y = CLAMP(diff_y, 127.f, -127.f);

imu->hid->mouse_move(
imu->hid_inst, mouse_exp_rate(mouse_x), mouse_exp_rate(mouse_y));
imu->hid_inst, mouse_exp_rate(mouse_x), -mouse_exp_rate(mouse_y));

diff_x -= (float)(int8_t)mouse_x;
diff_y -= (float)(int8_t)mouse_y;
Expand All @@ -259,8 +268,12 @@ void imu_mouse_key_press(ImuThread* imu, ImuMouseKey key, bool state) {
uint32_t flag = 0;
if(key == ImuMouseKeyRight) {
flag = (state) ? (ImuMouseRightPress) : (ImuMouseRightRelease);
} else if(key == ImuMouseKeyWheel) {
flag = (state) ? (ImuMouseWheelPress) : (ImuMouseWheelRelease);
} else if(key == ImuMouseKeyLeft) {
flag = (state) ? (ImuMouseLeftPress) : (ImuMouseLeftRelease);
} else {
furi_crash();
}

furi_thread_flags_set(furi_thread_get_id(imu->thread), flag);
Expand Down
1 change: 1 addition & 0 deletions air_mouse/imu_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ typedef struct {

typedef enum {
ImuMouseKeyRight,
ImuMouseKeyWheel,
ImuMouseKeyLeft,
} ImuMouseKey;

Expand Down
2 changes: 1 addition & 1 deletion air_mouse/sensors/ICM42688P.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ bool icm42688_fifo_read(ICM42688P* icm42688p, ICM42688PFifoPacket* data);

#ifdef __cplusplus
}
#endif
#endif
Loading