Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 204388
b: refs/heads/master
c: c042668
h: refs/heads/master
v: v3
  • Loading branch information
Chase Douglas authored and Jiri Kosina committed Jun 24, 2010
1 parent 4d4b9c5 commit 79c5b52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0b778e76c1e7ccf49f8980b594e72f984095fd26
refs/heads/master: c04266889b591165bdea396b20313bebb83c0fd6
25 changes: 19 additions & 6 deletions trunk/drivers/hid/hid-magicmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct magicmouse_sc {
struct {
short x;
short y;
short scroll_x;
short scroll_y;
u8 size;
} touches[16];
Expand Down Expand Up @@ -181,11 +182,13 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
*/
if (emulate_scroll_wheel) {
unsigned long now = jiffies;
int step = msc->touches[id].scroll_y - y;
int step_x = msc->touches[id].scroll_x - x;
int step_y = msc->touches[id].scroll_y - y;

/* Calculate and apply the scroll motion. */
switch (tdata[7] & TOUCH_STATE_MASK) {
case TOUCH_STATE_START:
msc->touches[id].scroll_x = x;
msc->touches[id].scroll_y = y;

/* Reset acceleration after half a second. */
Expand All @@ -198,12 +201,20 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda

break;
case TOUCH_STATE_DRAG:
step /= (64 - (int)scroll_speed) * msc->scroll_accel;
if (step != 0) {
msc->touches[id].scroll_y -= step *
step_x /= (64 - (int)scroll_speed) * msc->scroll_accel;
if (step_x != 0) {
msc->touches[id].scroll_x -= step_x *
(64 - scroll_speed) * msc->scroll_accel;
msc->scroll_jiffies = now;
input_report_rel(input, REL_WHEEL, step);
input_report_rel(input, REL_HWHEEL, -step_x);
}

step_y /= (64 - (int)scroll_speed) * msc->scroll_accel;
if (step_y != 0) {
msc->touches[id].scroll_y -= step_y *
(64 - scroll_speed) * msc->scroll_accel;
msc->scroll_jiffies = now;
input_report_rel(input, REL_WHEEL, step_y);
}
break;
}
Expand Down Expand Up @@ -318,8 +329,10 @@ static void magicmouse_setup_input(struct input_dev *input, struct hid_device *h
__set_bit(EV_REL, input->evbit);
__set_bit(REL_X, input->relbit);
__set_bit(REL_Y, input->relbit);
if (emulate_scroll_wheel)
if (emulate_scroll_wheel) {
__set_bit(REL_WHEEL, input->relbit);
__set_bit(REL_HWHEEL, input->relbit);
}

if (report_touches) {
__set_bit(EV_ABS, input->evbit);
Expand Down

0 comments on commit 79c5b52

Please sign in to comment.