diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2010-06-20 21:32:31 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-06-24 04:49:58 -0400 |
commit | c04266889b591165bdea396b20313bebb83c0fd6 (patch) | |
tree | 5b240074d9126960722952408f9ed8ed4f562ede /drivers/hid | |
parent | 0b778e76c1e7ccf49f8980b594e72f984095fd26 (diff) |
HID: magicmouse: enable horizontal scrolling
Mimicks OS X behavior.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-magicmouse.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index fe0c760d7e6e..0b89c1cf9ec4 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c | |||
@@ -95,6 +95,7 @@ struct magicmouse_sc { | |||
95 | struct { | 95 | struct { |
96 | short x; | 96 | short x; |
97 | short y; | 97 | short y; |
98 | short scroll_x; | ||
98 | short scroll_y; | 99 | short scroll_y; |
99 | u8 size; | 100 | u8 size; |
100 | } touches[16]; | 101 | } touches[16]; |
@@ -181,11 +182,13 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
181 | */ | 182 | */ |
182 | if (emulate_scroll_wheel) { | 183 | if (emulate_scroll_wheel) { |
183 | unsigned long now = jiffies; | 184 | unsigned long now = jiffies; |
184 | int step = msc->touches[id].scroll_y - y; | 185 | int step_x = msc->touches[id].scroll_x - x; |
186 | int step_y = msc->touches[id].scroll_y - y; | ||
185 | 187 | ||
186 | /* Calculate and apply the scroll motion. */ | 188 | /* Calculate and apply the scroll motion. */ |
187 | switch (tdata[7] & TOUCH_STATE_MASK) { | 189 | switch (tdata[7] & TOUCH_STATE_MASK) { |
188 | case TOUCH_STATE_START: | 190 | case TOUCH_STATE_START: |
191 | msc->touches[id].scroll_x = x; | ||
189 | msc->touches[id].scroll_y = y; | 192 | msc->touches[id].scroll_y = y; |
190 | 193 | ||
191 | /* Reset acceleration after half a second. */ | 194 | /* Reset acceleration after half a second. */ |
@@ -198,12 +201,20 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
198 | 201 | ||
199 | break; | 202 | break; |
200 | case TOUCH_STATE_DRAG: | 203 | case TOUCH_STATE_DRAG: |
201 | step /= (64 - (int)scroll_speed) * msc->scroll_accel; | 204 | step_x /= (64 - (int)scroll_speed) * msc->scroll_accel; |
202 | if (step != 0) { | 205 | if (step_x != 0) { |
203 | msc->touches[id].scroll_y -= step * | 206 | msc->touches[id].scroll_x -= step_x * |
204 | (64 - scroll_speed) * msc->scroll_accel; | 207 | (64 - scroll_speed) * msc->scroll_accel; |
205 | msc->scroll_jiffies = now; | 208 | msc->scroll_jiffies = now; |
206 | input_report_rel(input, REL_WHEEL, step); | 209 | input_report_rel(input, REL_HWHEEL, -step_x); |
210 | } | ||
211 | |||
212 | step_y /= (64 - (int)scroll_speed) * msc->scroll_accel; | ||
213 | if (step_y != 0) { | ||
214 | msc->touches[id].scroll_y -= step_y * | ||
215 | (64 - scroll_speed) * msc->scroll_accel; | ||
216 | msc->scroll_jiffies = now; | ||
217 | input_report_rel(input, REL_WHEEL, step_y); | ||
207 | } | 218 | } |
208 | break; | 219 | break; |
209 | } | 220 | } |
@@ -318,8 +329,10 @@ static void magicmouse_setup_input(struct input_dev *input, struct hid_device *h | |||
318 | __set_bit(EV_REL, input->evbit); | 329 | __set_bit(EV_REL, input->evbit); |
319 | __set_bit(REL_X, input->relbit); | 330 | __set_bit(REL_X, input->relbit); |
320 | __set_bit(REL_Y, input->relbit); | 331 | __set_bit(REL_Y, input->relbit); |
321 | if (emulate_scroll_wheel) | 332 | if (emulate_scroll_wheel) { |
322 | __set_bit(REL_WHEEL, input->relbit); | 333 | __set_bit(REL_WHEEL, input->relbit); |
334 | __set_bit(REL_HWHEEL, input->relbit); | ||
335 | } | ||
323 | 336 | ||
324 | if (report_touches) { | 337 | if (report_touches) { |
325 | __set_bit(EV_ABS, input->evbit); | 338 | __set_bit(EV_ABS, input->evbit); |