mirror of
https://github.com/UberGuidoZ/Flipper.git
synced 2026-09-18 18:41:31 +00:00
Added xMasterX API v11.x source
This commit is contained in:
@@ -0,0 +1,310 @@
|
||||
#include "bt_mouse.h"
|
||||
#include "../tracking/main_loop.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal_bt.h>
|
||||
#include <furi_hal_bt_hid.h>
|
||||
#include <furi_hal_usb_hid.h>
|
||||
#include <bt/bt_service/bt.h>
|
||||
#include <gui/elements.h>
|
||||
#include <notification/notification.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
typedef struct ButtonEvent {
|
||||
int8_t button;
|
||||
bool state;
|
||||
} ButtonEvent;
|
||||
|
||||
#define BTN_EVT_QUEUE_SIZE 32
|
||||
|
||||
struct BtMouse {
|
||||
View* view;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
Bt* bt;
|
||||
NotificationApp* notifications;
|
||||
FuriMutex* mutex;
|
||||
FuriThread* thread;
|
||||
bool connected;
|
||||
|
||||
// Current mouse state
|
||||
uint8_t btn;
|
||||
int dx;
|
||||
int dy;
|
||||
int wheel;
|
||||
|
||||
// Circular buffer;
|
||||
// (qhead == qtail) means either empty or overflow.
|
||||
// We'll ignore overflow and treat it as empty.
|
||||
int qhead;
|
||||
int qtail;
|
||||
ButtonEvent queue[BTN_EVT_QUEUE_SIZE];
|
||||
};
|
||||
|
||||
#define BT_MOUSE_FLAG_INPUT_EVENT (1UL << 0)
|
||||
#define BT_MOUSE_FLAG_KILL_THREAD (1UL << 1)
|
||||
#define BT_MOUSE_FLAG_ALL (BT_MOUSE_FLAG_INPUT_EVENT | BT_MOUSE_FLAG_KILL_THREAD)
|
||||
|
||||
#define MOUSE_SCROLL 2
|
||||
|
||||
static void bt_mouse_notify_event(BtMouse* bt_mouse) {
|
||||
FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
|
||||
furi_assert(thread_id);
|
||||
furi_thread_flags_set(thread_id, BT_MOUSE_FLAG_INPUT_EVENT);
|
||||
}
|
||||
|
||||
static void bt_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||
UNUSED(context);
|
||||
canvas_clear(canvas);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 0, 10, "Bluetooth Mouse mode");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
|
||||
}
|
||||
|
||||
static void bt_mouse_button_state(BtMouse* bt_mouse, int8_t button, bool state) {
|
||||
ButtonEvent event;
|
||||
event.button = button;
|
||||
event.state = state;
|
||||
|
||||
if(bt_mouse->connected) {
|
||||
furi_mutex_acquire(bt_mouse->mutex, FuriWaitForever);
|
||||
bt_mouse->queue[bt_mouse->qtail++] = event;
|
||||
bt_mouse->qtail %= BTN_EVT_QUEUE_SIZE;
|
||||
furi_mutex_release(bt_mouse->mutex);
|
||||
bt_mouse_notify_event(bt_mouse);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) {
|
||||
with_view_model(
|
||||
bt_mouse->view,
|
||||
void* model,
|
||||
{
|
||||
UNUSED(model);
|
||||
if(event->key == InputKeyUp) {
|
||||
if(event->type == InputTypePress) {
|
||||
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, true);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, false);
|
||||
}
|
||||
} else if(event->key == InputKeyDown) {
|
||||
if(event->type == InputTypePress) {
|
||||
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_RIGHT, true);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_RIGHT, false);
|
||||
}
|
||||
} else if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, true);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, false);
|
||||
}
|
||||
} else if(event->key == InputKeyRight) {
|
||||
if(event->type == InputTypePress || event->type == InputTypeRepeat) {
|
||||
bt_mouse->wheel = MOUSE_SCROLL;
|
||||
}
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
if(event->type == InputTypePress || event->type == InputTypeRepeat) {
|
||||
bt_mouse->wheel = -MOUSE_SCROLL;
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool bt_mouse_input_callback(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == InputTypeLong && event->key == InputKeyBack) {
|
||||
furi_hal_bt_hid_mouse_release_all();
|
||||
} else {
|
||||
bt_mouse_process(bt_mouse, event);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void bt_mouse_connection_status_changed_callback(BtStatus status, void* context) {
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = context;
|
||||
|
||||
bt_mouse->connected = (status == BtStatusConnected);
|
||||
if(bt_mouse->connected) {
|
||||
notification_internal_message(bt_mouse->notifications, &sequence_set_blue_255);
|
||||
tracking_begin();
|
||||
view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
|
||||
} else {
|
||||
tracking_end();
|
||||
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
|
||||
}
|
||||
|
||||
//with_view_model(
|
||||
// bt_mouse->view, void * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
bool bt_mouse_move(int8_t dx, int8_t dy, void* context) {
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = context;
|
||||
|
||||
if(bt_mouse->connected) {
|
||||
furi_mutex_acquire(bt_mouse->mutex, FuriWaitForever);
|
||||
bt_mouse->dx += dx;
|
||||
bt_mouse->dy += dy;
|
||||
furi_mutex_release(bt_mouse->mutex);
|
||||
bt_mouse_notify_event(bt_mouse);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void bt_mouse_enter_callback(void* context) {
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = context;
|
||||
|
||||
bt_mouse->bt = furi_record_open(RECORD_BT);
|
||||
bt_mouse->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
bt_set_status_changed_callback(
|
||||
bt_mouse->bt, bt_mouse_connection_status_changed_callback, bt_mouse);
|
||||
furi_assert(bt_set_profile(bt_mouse->bt, BtProfileHidKeyboard));
|
||||
furi_hal_bt_start_advertising();
|
||||
}
|
||||
|
||||
bool bt_mouse_custom_callback(uint32_t event, void* context) {
|
||||
UNUSED(event);
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = context;
|
||||
|
||||
tracking_step(bt_mouse_move, context);
|
||||
furi_delay_ms(3); // Magic! Removing this will break the buttons
|
||||
|
||||
view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void bt_mouse_exit_callback(void* context) {
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = context;
|
||||
|
||||
tracking_end();
|
||||
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);
|
||||
|
||||
furi_hal_bt_stop_advertising();
|
||||
bt_set_profile(bt_mouse->bt, BtProfileSerial);
|
||||
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
bt_mouse->notifications = NULL;
|
||||
furi_record_close(RECORD_BT);
|
||||
bt_mouse->bt = NULL;
|
||||
}
|
||||
|
||||
static int8_t clamp(int t) {
|
||||
if(t < -128) {
|
||||
return -128;
|
||||
} else if(t > 127) {
|
||||
return 127;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static int32_t bt_mouse_thread_callback(void* context) {
|
||||
furi_assert(context);
|
||||
BtMouse* bt_mouse = (BtMouse*)context;
|
||||
|
||||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(BT_MOUSE_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags & BT_MOUSE_FLAG_KILL_THREAD) {
|
||||
break;
|
||||
}
|
||||
if(flags & BT_MOUSE_FLAG_INPUT_EVENT) {
|
||||
furi_mutex_acquire(bt_mouse->mutex, FuriWaitForever);
|
||||
|
||||
ButtonEvent event;
|
||||
bool send_buttons = false;
|
||||
if(bt_mouse->qhead != bt_mouse->qtail) {
|
||||
event = bt_mouse->queue[bt_mouse->qhead++];
|
||||
bt_mouse->qhead %= BTN_EVT_QUEUE_SIZE;
|
||||
send_buttons = true;
|
||||
}
|
||||
|
||||
int8_t dx = clamp(bt_mouse->dx);
|
||||
bt_mouse->dx -= dx;
|
||||
int8_t dy = clamp(bt_mouse->dy);
|
||||
bt_mouse->dy -= dy;
|
||||
int8_t wheel = clamp(bt_mouse->wheel);
|
||||
bt_mouse->wheel -= wheel;
|
||||
|
||||
furi_mutex_release(bt_mouse->mutex);
|
||||
|
||||
if(bt_mouse->connected && send_buttons) {
|
||||
if(event.state) {
|
||||
furi_hal_bt_hid_mouse_press(event.button);
|
||||
} else {
|
||||
furi_hal_bt_hid_mouse_release(event.button);
|
||||
}
|
||||
}
|
||||
|
||||
if(bt_mouse->connected && (dx != 0 || dy != 0)) {
|
||||
furi_hal_bt_hid_mouse_move(dx, dy);
|
||||
}
|
||||
|
||||
if(bt_mouse->connected && wheel != 0) {
|
||||
furi_hal_bt_hid_mouse_scroll(wheel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_mouse_thread_start(BtMouse* bt_mouse) {
|
||||
furi_assert(bt_mouse);
|
||||
bt_mouse->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
bt_mouse->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(bt_mouse->thread, "BtSender");
|
||||
furi_thread_set_stack_size(bt_mouse->thread, 1024);
|
||||
furi_thread_set_context(bt_mouse->thread, bt_mouse);
|
||||
furi_thread_set_callback(bt_mouse->thread, bt_mouse_thread_callback);
|
||||
furi_thread_start(bt_mouse->thread);
|
||||
}
|
||||
|
||||
void bt_mouse_thread_stop(BtMouse* bt_mouse) {
|
||||
furi_assert(bt_mouse);
|
||||
FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
|
||||
furi_assert(thread_id);
|
||||
furi_thread_flags_set(thread_id, BT_MOUSE_FLAG_KILL_THREAD);
|
||||
furi_thread_join(bt_mouse->thread);
|
||||
furi_thread_free(bt_mouse->thread);
|
||||
furi_mutex_free(bt_mouse->mutex);
|
||||
}
|
||||
|
||||
BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) {
|
||||
BtMouse* bt_mouse = malloc(sizeof(BtMouse));
|
||||
memset(bt_mouse, 0, sizeof(BtMouse));
|
||||
|
||||
bt_mouse->view = view_alloc();
|
||||
bt_mouse->view_dispatcher = view_dispatcher;
|
||||
view_set_context(bt_mouse->view, bt_mouse);
|
||||
view_set_draw_callback(bt_mouse->view, bt_mouse_draw_callback);
|
||||
view_set_input_callback(bt_mouse->view, bt_mouse_input_callback);
|
||||
view_set_enter_callback(bt_mouse->view, bt_mouse_enter_callback);
|
||||
view_set_custom_callback(bt_mouse->view, bt_mouse_custom_callback);
|
||||
view_set_exit_callback(bt_mouse->view, bt_mouse_exit_callback);
|
||||
bt_mouse_thread_start(bt_mouse);
|
||||
return bt_mouse;
|
||||
}
|
||||
|
||||
void bt_mouse_free(BtMouse* bt_mouse) {
|
||||
furi_assert(bt_mouse);
|
||||
bt_mouse_thread_stop(bt_mouse);
|
||||
view_free(bt_mouse->view);
|
||||
free(bt_mouse);
|
||||
}
|
||||
|
||||
View* bt_mouse_get_view(BtMouse* bt_mouse) {
|
||||
furi_assert(bt_mouse);
|
||||
return bt_mouse->view;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
typedef struct BtMouse BtMouse;
|
||||
|
||||
BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher);
|
||||
|
||||
void bt_mouse_free(BtMouse* bt_mouse);
|
||||
|
||||
View* bt_mouse_get_view(BtMouse* bt_mouse);
|
||||
|
||||
void bt_mouse_set_connected_status(BtMouse* bt_mouse, bool connected);
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "calibration.h"
|
||||
#include "../tracking/main_loop.h"
|
||||
#include "../air_mouse.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
struct Calibration {
|
||||
View* view;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
};
|
||||
|
||||
static void calibration_draw_callback(Canvas* canvas, void* context) {
|
||||
UNUSED(context);
|
||||
canvas_clear(canvas);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 0, 10, "Calibrating...");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 0, 63, "Please wait");
|
||||
}
|
||||
|
||||
void calibration_enter_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Calibration* calibration = context;
|
||||
calibration_begin();
|
||||
view_dispatcher_send_custom_event(calibration->view_dispatcher, 0);
|
||||
}
|
||||
|
||||
bool calibration_custom_callback(uint32_t event, void* context) {
|
||||
UNUSED(event);
|
||||
furi_assert(context);
|
||||
Calibration* calibration = context;
|
||||
|
||||
if(calibration_step()) {
|
||||
view_dispatcher_switch_to_view(calibration->view_dispatcher, AirMouseViewSubmenu);
|
||||
} else {
|
||||
view_dispatcher_send_custom_event(calibration->view_dispatcher, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void calibration_exit_callback(void* context) {
|
||||
furi_assert(context);
|
||||
calibration_end();
|
||||
}
|
||||
|
||||
Calibration* calibration_alloc(ViewDispatcher* view_dispatcher) {
|
||||
Calibration* calibration = malloc(sizeof(Calibration));
|
||||
calibration->view = view_alloc();
|
||||
calibration->view_dispatcher = view_dispatcher;
|
||||
view_set_context(calibration->view, calibration);
|
||||
view_set_draw_callback(calibration->view, calibration_draw_callback);
|
||||
view_set_enter_callback(calibration->view, calibration_enter_callback);
|
||||
view_set_custom_callback(calibration->view, calibration_custom_callback);
|
||||
view_set_exit_callback(calibration->view, calibration_exit_callback);
|
||||
return calibration;
|
||||
}
|
||||
|
||||
void calibration_free(Calibration* calibration) {
|
||||
furi_assert(calibration);
|
||||
view_free(calibration->view);
|
||||
free(calibration);
|
||||
}
|
||||
|
||||
View* calibration_get_view(Calibration* calibration) {
|
||||
furi_assert(calibration);
|
||||
return calibration->view;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
typedef struct Calibration Calibration;
|
||||
|
||||
Calibration* calibration_alloc(ViewDispatcher* view_dispatcher);
|
||||
|
||||
void calibration_free(Calibration* calibration);
|
||||
|
||||
View* calibration_get_view(Calibration* calibration);
|
||||
@@ -0,0 +1,139 @@
|
||||
#include "usb_mouse.h"
|
||||
#include "../tracking/main_loop.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal_usb.h>
|
||||
#include <furi_hal_usb_hid.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
struct UsbMouse {
|
||||
View* view;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
FuriHalUsbInterface* usb_mode_prev;
|
||||
};
|
||||
|
||||
static void usb_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||
UNUSED(context);
|
||||
canvas_clear(canvas);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 0, 10, "USB Mouse mode");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
|
||||
}
|
||||
|
||||
#define MOUSE_SCROLL 2
|
||||
|
||||
static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
|
||||
with_view_model(
|
||||
usb_mouse->view,
|
||||
void* model,
|
||||
{
|
||||
UNUSED(model);
|
||||
if(event->key == InputKeyUp) {
|
||||
if(event->type == InputTypePress) {
|
||||
furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT);
|
||||
}
|
||||
} else if(event->key == InputKeyDown) {
|
||||
if(event->type == InputTypePress) {
|
||||
furi_hal_hid_mouse_press(HID_MOUSE_BTN_RIGHT);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_RIGHT);
|
||||
}
|
||||
} else if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
furi_hal_hid_mouse_press(HID_MOUSE_BTN_WHEEL);
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_WHEEL);
|
||||
}
|
||||
} else if(event->key == InputKeyRight) {
|
||||
if(event->type == InputTypePress || event->type == InputTypeRepeat) {
|
||||
furi_hal_hid_mouse_scroll(MOUSE_SCROLL);
|
||||
}
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
if(event->type == InputTypePress || event->type == InputTypeRepeat) {
|
||||
furi_hal_hid_mouse_scroll(-MOUSE_SCROLL);
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool usb_mouse_input_callback(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
UsbMouse* usb_mouse = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == InputTypeLong && event->key == InputKeyBack) {
|
||||
// furi_hal_hid_mouse_release_all();
|
||||
} else {
|
||||
usb_mouse_process(usb_mouse, event);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void usb_mouse_enter_callback(void* context) {
|
||||
furi_assert(context);
|
||||
UsbMouse* usb_mouse = context;
|
||||
|
||||
usb_mouse->usb_mode_prev = furi_hal_usb_get_config();
|
||||
furi_hal_usb_unlock();
|
||||
furi_check(furi_hal_usb_set_config(&usb_hid, NULL) == true);
|
||||
|
||||
tracking_begin();
|
||||
|
||||
view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0);
|
||||
}
|
||||
|
||||
bool usb_mouse_move(int8_t dx, int8_t dy, void* context) {
|
||||
UNUSED(context);
|
||||
return furi_hal_hid_mouse_move(dx, dy);
|
||||
}
|
||||
|
||||
bool usb_mouse_custom_callback(uint32_t event, void* context) {
|
||||
UNUSED(event);
|
||||
furi_assert(context);
|
||||
UsbMouse* usb_mouse = context;
|
||||
|
||||
tracking_step(usb_mouse_move, context);
|
||||
furi_delay_ms(3); // Magic! Removing this will break the buttons
|
||||
|
||||
view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void usb_mouse_exit_callback(void* context) {
|
||||
furi_assert(context);
|
||||
UsbMouse* usb_mouse = context;
|
||||
|
||||
tracking_end();
|
||||
|
||||
furi_hal_usb_set_config(usb_mouse->usb_mode_prev, NULL);
|
||||
}
|
||||
|
||||
UsbMouse* usb_mouse_alloc(ViewDispatcher* view_dispatcher) {
|
||||
UsbMouse* usb_mouse = malloc(sizeof(UsbMouse));
|
||||
usb_mouse->view = view_alloc();
|
||||
usb_mouse->view_dispatcher = view_dispatcher;
|
||||
view_set_context(usb_mouse->view, usb_mouse);
|
||||
view_set_draw_callback(usb_mouse->view, usb_mouse_draw_callback);
|
||||
view_set_input_callback(usb_mouse->view, usb_mouse_input_callback);
|
||||
view_set_enter_callback(usb_mouse->view, usb_mouse_enter_callback);
|
||||
view_set_custom_callback(usb_mouse->view, usb_mouse_custom_callback);
|
||||
view_set_exit_callback(usb_mouse->view, usb_mouse_exit_callback);
|
||||
return usb_mouse;
|
||||
}
|
||||
|
||||
void usb_mouse_free(UsbMouse* usb_mouse) {
|
||||
furi_assert(usb_mouse);
|
||||
view_free(usb_mouse->view);
|
||||
free(usb_mouse);
|
||||
}
|
||||
|
||||
View* usb_mouse_get_view(UsbMouse* usb_mouse) {
|
||||
furi_assert(usb_mouse);
|
||||
return usb_mouse->view;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
typedef struct UsbMouse UsbMouse;
|
||||
|
||||
UsbMouse* usb_mouse_alloc(ViewDispatcher* view_dispatcher);
|
||||
|
||||
void usb_mouse_free(UsbMouse* usb_mouse);
|
||||
|
||||
View* usb_mouse_get_view(UsbMouse* usb_mouse);
|
||||
Reference in New Issue
Block a user