@@ -68,6 +68,10 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie
68
68
#define TOUCH_STATE_START 0x30
69
69
#define TOUCH_STATE_DRAG 0x40
70
70
71
+ /* Number of high-resolution events for each low-resolution detent. */
72
+ #define SCROLL_HR_STEPS 10
73
+ #define SCROLL_HR_MULT (120 / SCROLL_HR_STEPS)
74
+ #define SCROLL_HR_THRESHOLD 90 /* units */
71
75
#define SCROLL_ACCEL_DEFAULT 7
72
76
73
77
/* Touch surface information. Dimension is in hundredths of a mm, min and max
@@ -126,7 +130,11 @@ struct magicmouse_sc {
126
130
short y ;
127
131
short scroll_x ;
128
132
short scroll_y ;
133
+ short scroll_x_hr ;
134
+ short scroll_y_hr ;
129
135
u8 size ;
136
+ bool scroll_x_active ;
137
+ bool scroll_y_active ;
130
138
} touches [16 ];
131
139
int tracking_ids [16 ];
132
140
@@ -248,12 +256,20 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
248
256
unsigned long now = jiffies ;
249
257
int step_x = msc -> touches [id ].scroll_x - x ;
250
258
int step_y = msc -> touches [id ].scroll_y - y ;
259
+ int step_hr = ((64 - (int )scroll_speed ) * msc -> scroll_accel ) /
260
+ SCROLL_HR_STEPS ;
261
+ int step_x_hr = msc -> touches [id ].scroll_x_hr - x ;
262
+ int step_y_hr = msc -> touches [id ].scroll_y_hr - y ;
251
263
252
264
/* Calculate and apply the scroll motion. */
253
265
switch (state ) {
254
266
case TOUCH_STATE_START :
255
267
msc -> touches [id ].scroll_x = x ;
256
268
msc -> touches [id ].scroll_y = y ;
269
+ msc -> touches [id ].scroll_x_hr = x ;
270
+ msc -> touches [id ].scroll_y_hr = y ;
271
+ msc -> touches [id ].scroll_x_active = false;
272
+ msc -> touches [id ].scroll_y_active = false;
257
273
258
274
/* Reset acceleration after half a second. */
259
275
if (scroll_acceleration && time_before (now ,
@@ -280,6 +296,40 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
280
296
msc -> scroll_jiffies = now ;
281
297
input_report_rel (input , REL_WHEEL , step_y );
282
298
}
299
+
300
+ if (!msc -> touches [id ].scroll_x_active &&
301
+ abs (step_x_hr ) > SCROLL_HR_THRESHOLD ) {
302
+ msc -> touches [id ].scroll_x_active = true;
303
+ msc -> touches [id ].scroll_x_hr = x ;
304
+ step_x_hr = 0 ;
305
+ }
306
+
307
+ step_x_hr /= step_hr ;
308
+ if (step_x_hr != 0 &&
309
+ msc -> touches [id ].scroll_x_active ) {
310
+ msc -> touches [id ].scroll_x_hr -= step_x_hr *
311
+ step_hr ;
312
+ input_report_rel (input ,
313
+ REL_HWHEEL_HI_RES ,
314
+ - step_x_hr * SCROLL_HR_MULT );
315
+ }
316
+
317
+ if (!msc -> touches [id ].scroll_y_active &&
318
+ abs (step_y_hr ) > SCROLL_HR_THRESHOLD ) {
319
+ msc -> touches [id ].scroll_y_active = true;
320
+ msc -> touches [id ].scroll_y_hr = y ;
321
+ step_y_hr = 0 ;
322
+ }
323
+
324
+ step_y_hr /= step_hr ;
325
+ if (step_y_hr != 0 &&
326
+ msc -> touches [id ].scroll_y_active ) {
327
+ msc -> touches [id ].scroll_y_hr -= step_y_hr *
328
+ step_hr ;
329
+ input_report_rel (input ,
330
+ REL_WHEEL_HI_RES ,
331
+ step_y_hr * SCROLL_HR_MULT );
332
+ }
283
333
break ;
284
334
}
285
335
}
@@ -481,6 +531,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
481
531
if (emulate_scroll_wheel ) {
482
532
__set_bit (REL_WHEEL , input -> relbit );
483
533
__set_bit (REL_HWHEEL , input -> relbit );
534
+ __set_bit (REL_WHEEL_HI_RES , input -> relbit );
535
+ __set_bit (REL_HWHEEL_HI_RES , input -> relbit );
484
536
}
485
537
} else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
486
538
/* setting the device name to ensure the same driver settings
0 commit comments