@@ -44,9 +44,7 @@ struct BtMouse {
44
44
#define BT_MOUSE_FLAG_KILL_THREAD (1UL << 1)
45
45
#define BT_MOUSE_FLAG_ALL (BT_MOUSE_FLAG_INPUT_EVENT | BT_MOUSE_FLAG_KILL_THREAD)
46
46
47
- #define MOUSE_MOVE_SHORT 5
48
- #define MOUSE_MOVE_LONG 20
49
- #define MOUSE_SCROLL 20
47
+ #define MOUSE_SCROLL 2
50
48
51
49
static void bt_mouse_notify_event (BtMouse * bt_mouse ) {
52
50
FuriThreadId thread_id = furi_thread_get_id (bt_mouse -> thread );
@@ -68,7 +66,7 @@ static void bt_mouse_button_state(BtMouse* bt_mouse, int8_t button, bool state)
68
66
event .button = button ;
69
67
event .state = state ;
70
68
71
- if (bt_mouse -> connected ) {
69
+ if (bt_mouse -> connected ) {
72
70
furi_mutex_acquire (bt_mouse -> mutex , FuriWaitForever );
73
71
bt_mouse -> queue [bt_mouse -> qtail ++ ] = event ;
74
72
bt_mouse -> qtail %= BTN_EVT_QUEUE_SIZE ;
@@ -102,11 +100,11 @@ static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) {
102
100
bt_mouse_button_state (bt_mouse , HID_MOUSE_BTN_WHEEL , false);
103
101
}
104
102
} else if (event -> key == InputKeyRight ) {
105
- if (event -> type == InputTypePress ) {
103
+ if (event -> type == InputTypePress || event -> type == InputTypeRepeat ) {
106
104
bt_mouse -> wheel = MOUSE_SCROLL ;
107
105
}
108
106
} else if (event -> key == InputKeyLeft ) {
109
- if (event -> type == InputTypePress ) {
107
+ if (event -> type == InputTypePress || event -> type == InputTypeRepeat ) {
110
108
bt_mouse -> wheel = - MOUSE_SCROLL ;
111
109
}
112
110
}
@@ -147,11 +145,11 @@ void bt_mouse_connection_status_changed_callback(BtStatus status, void* context)
147
145
// bt_mouse->view, void * model, { model->connected = connected; }, true);
148
146
}
149
147
150
- bool bt_mouse_move (int8_t dx , int8_t dy , void * context ) {
148
+ bool bt_mouse_move (int8_t dx , int8_t dy , void * context ) {
151
149
furi_assert (context );
152
150
BtMouse * bt_mouse = context ;
153
151
154
- if (bt_mouse -> connected ) {
152
+ if (bt_mouse -> connected ) {
155
153
furi_mutex_acquire (bt_mouse -> mutex , FuriWaitForever );
156
154
bt_mouse -> dx += dx ;
157
155
bt_mouse -> dy += dy ;
@@ -203,10 +201,9 @@ void bt_mouse_exit_callback(void* context) {
203
201
}
204
202
205
203
static int8_t clamp (int t ) {
206
- if (t < -128 ) {
204
+ if (t < -128 ) {
207
205
return -128 ;
208
- }
209
- else if (t > 127 ) {
206
+ } else if (t > 127 ) {
210
207
return 127 ;
211
208
}
212
209
return t ;
@@ -217,7 +214,8 @@ static int32_t bt_mouse_thread_callback(void* context) {
217
214
BtMouse * bt_mouse = (BtMouse * )context ;
218
215
219
216
while (1 ) {
220
- uint32_t flags = furi_thread_flags_wait (BT_MOUSE_FLAG_ALL , FuriFlagWaitAny , FuriWaitForever );
217
+ uint32_t flags =
218
+ furi_thread_flags_wait (BT_MOUSE_FLAG_ALL , FuriFlagWaitAny , FuriWaitForever );
221
219
if (flags & BT_MOUSE_FLAG_KILL_THREAD ) {
222
220
break ;
223
221
}
@@ -226,7 +224,7 @@ static int32_t bt_mouse_thread_callback(void* context) {
226
224
227
225
ButtonEvent event ;
228
226
bool send_buttons = false;
229
- if (bt_mouse -> qhead != bt_mouse -> qtail ) {
227
+ if (bt_mouse -> qhead != bt_mouse -> qtail ) {
230
228
event = bt_mouse -> queue [bt_mouse -> qhead ++ ];
231
229
bt_mouse -> qhead %= BTN_EVT_QUEUE_SIZE ;
232
230
send_buttons = true;
@@ -241,19 +239,19 @@ static int32_t bt_mouse_thread_callback(void* context) {
241
239
242
240
furi_mutex_release (bt_mouse -> mutex );
243
241
244
- if (bt_mouse -> connected && send_buttons ) {
245
- if (event .state ) {
242
+ if (bt_mouse -> connected && send_buttons ) {
243
+ if (event .state ) {
246
244
furi_hal_bt_hid_mouse_press (event .button );
247
245
} else {
248
246
furi_hal_bt_hid_mouse_release (event .button );
249
247
}
250
248
}
251
249
252
- if (bt_mouse -> connected && (dx != 0 || dy != 0 )) {
250
+ if (bt_mouse -> connected && (dx != 0 || dy != 0 )) {
253
251
furi_hal_bt_hid_mouse_move (dx , dy );
254
252
}
255
253
256
- if (bt_mouse -> connected && wheel != 0 ) {
254
+ if (bt_mouse -> connected && wheel != 0 ) {
257
255
furi_hal_bt_hid_mouse_scroll (wheel );
258
256
}
259
257
}
0 commit comments