diff options
author | Anssi Hannula <anssi.hannula@gmail.com> | 2008-03-31 19:51:11 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2008-04-22 05:34:57 -0400 |
commit | c17f9c901c4e62cbf857b831bcc3070380449b88 (patch) | |
tree | 360860210f1f81086ec10c83370c3526a601544c /drivers | |
parent | 1d1bdd20008416a744c0c844e231e7ba69c11699 (diff) |
HID: force feedback driver for Logitech Rumblepad 2
Add force feedback support for Logitech Rumblepad 2.
Tested-By: Edgar Simo <bobbens@gmail.com>
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/usbhid/Kconfig | 8 | ||||
-rw-r--r-- | drivers/hid/usbhid/Makefile | 3 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-ff.c | 3 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-lg2ff.c | 114 |
4 files changed, 128 insertions, 0 deletions
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig index 7160fa65d79b..a5f0fb0fdaf4 100644 --- a/drivers/hid/usbhid/Kconfig +++ b/drivers/hid/usbhid/Kconfig | |||
@@ -71,6 +71,14 @@ config LOGITECH_FF | |||
71 | Note: if you say N here, this device will still be supported, but without | 71 | Note: if you say N here, this device will still be supported, but without |
72 | force feedback. | 72 | force feedback. |
73 | 73 | ||
74 | config LOGIRUMBLEPAD2_FF | ||
75 | bool "Logitech Rumblepad 2 support" | ||
76 | depends on HID_FF | ||
77 | select INPUT_FF_MEMLESS if USB_HID | ||
78 | help | ||
79 | Say Y here if you want to enable force feedback support for Logitech | ||
80 | Rumblepad 2 devices. | ||
81 | |||
74 | config PANTHERLORD_FF | 82 | config PANTHERLORD_FF |
75 | bool "PantherLord/GreenAsia based device support" | 83 | bool "PantherLord/GreenAsia based device support" |
76 | depends on HID_FF | 84 | depends on HID_FF |
diff --git a/drivers/hid/usbhid/Makefile b/drivers/hid/usbhid/Makefile index 8e6ab5b164a2..00a7b7090192 100644 --- a/drivers/hid/usbhid/Makefile +++ b/drivers/hid/usbhid/Makefile | |||
@@ -16,6 +16,9 @@ endif | |||
16 | ifeq ($(CONFIG_LOGITECH_FF),y) | 16 | ifeq ($(CONFIG_LOGITECH_FF),y) |
17 | usbhid-objs += hid-lgff.o | 17 | usbhid-objs += hid-lgff.o |
18 | endif | 18 | endif |
19 | ifeq ($(CONFIG_LOGIRUMBLEPAD2_FF),y) | ||
20 | usbhid-objs += hid-lg2ff.o | ||
21 | endif | ||
19 | ifeq ($(CONFIG_PANTHERLORD_FF),y) | 22 | ifeq ($(CONFIG_PANTHERLORD_FF),y) |
20 | usbhid-objs += hid-plff.o | 23 | usbhid-objs += hid-plff.o |
21 | endif | 24 | endif |
diff --git a/drivers/hid/usbhid/hid-ff.c b/drivers/hid/usbhid/hid-ff.c index 4c210e16b1b4..1d0dac52f166 100644 --- a/drivers/hid/usbhid/hid-ff.c +++ b/drivers/hid/usbhid/hid-ff.c | |||
@@ -59,6 +59,9 @@ static struct hid_ff_initializer inits[] = { | |||
59 | { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */ | 59 | { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */ |
60 | { 0x46d, 0xca03, hid_lgff_init }, /* Logitech MOMO force wheel */ | 60 | { 0x46d, 0xca03, hid_lgff_init }, /* Logitech MOMO force wheel */ |
61 | #endif | 61 | #endif |
62 | #ifdef CONFIG_LOGIRUMBLEPAD2_FF | ||
63 | { 0x46d, 0xc218, hid_lg2ff_init }, /* Logitech Rumblepad 2 */ | ||
64 | #endif | ||
62 | #ifdef CONFIG_PANTHERLORD_FF | 65 | #ifdef CONFIG_PANTHERLORD_FF |
63 | { 0x810, 0x0001, hid_plff_init }, /* "Twin USB Joystick" */ | 66 | { 0x810, 0x0001, hid_plff_init }, /* "Twin USB Joystick" */ |
64 | { 0xe8f, 0x0003, hid_plff_init }, /* "GreenAsia Inc. USB Joystick " */ | 67 | { 0xe8f, 0x0003, hid_plff_init }, /* "GreenAsia Inc. USB Joystick " */ |
diff --git a/drivers/hid/usbhid/hid-lg2ff.c b/drivers/hid/usbhid/hid-lg2ff.c new file mode 100644 index 000000000000..d469bd0061c9 --- /dev/null +++ b/drivers/hid/usbhid/hid-lg2ff.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Force feedback support for Logitech Rumblepad 2 | ||
3 | * | ||
4 | * Copyright (c) 2008 Anssi Hannula <anssi.hannula@gmail.com> | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | |||
24 | #include <linux/input.h> | ||
25 | #include <linux/usb.h> | ||
26 | #include <linux/hid.h> | ||
27 | #include "usbhid.h" | ||
28 | |||
29 | struct lg2ff_device { | ||
30 | struct hid_report *report; | ||
31 | }; | ||
32 | |||
33 | static int play_effect(struct input_dev *dev, void *data, | ||
34 | struct ff_effect *effect) | ||
35 | { | ||
36 | struct hid_device *hid = input_get_drvdata(dev); | ||
37 | struct lg2ff_device *lg2ff = data; | ||
38 | int weak, strong; | ||
39 | |||
40 | strong = effect->u.rumble.strong_magnitude; | ||
41 | weak = effect->u.rumble.weak_magnitude; | ||
42 | |||
43 | if (weak || strong) { | ||
44 | weak = weak * 0xff / 0xffff; | ||
45 | strong = strong * 0xff / 0xffff; | ||
46 | |||
47 | lg2ff->report->field[0]->value[0] = 0x51; | ||
48 | lg2ff->report->field[0]->value[2] = weak; | ||
49 | lg2ff->report->field[0]->value[4] = strong; | ||
50 | } else { | ||
51 | lg2ff->report->field[0]->value[0] = 0xf3; | ||
52 | lg2ff->report->field[0]->value[2] = 0x00; | ||
53 | lg2ff->report->field[0]->value[4] = 0x00; | ||
54 | } | ||
55 | |||
56 | usbhid_submit_report(hid, lg2ff->report, USB_DIR_OUT); | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int hid_lg2ff_init(struct hid_device *hid) | ||
61 | { | ||
62 | struct lg2ff_device *lg2ff; | ||
63 | struct hid_report *report; | ||
64 | struct hid_input *hidinput = list_entry(hid->inputs.next, | ||
65 | struct hid_input, list); | ||
66 | struct list_head *report_list = | ||
67 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
68 | struct input_dev *dev = hidinput->input; | ||
69 | int error; | ||
70 | |||
71 | if (list_empty(report_list)) { | ||
72 | printk(KERN_ERR "hid-lg2ff: no output report found\n"); | ||
73 | return -ENODEV; | ||
74 | } | ||
75 | |||
76 | report = list_entry(report_list->next, struct hid_report, list); | ||
77 | |||
78 | if (report->maxfield < 1) { | ||
79 | printk(KERN_ERR "hid-lg2ff: output report is empty\n"); | ||
80 | return -ENODEV; | ||
81 | } | ||
82 | if (report->field[0]->report_count < 7) { | ||
83 | printk(KERN_ERR "hid-lg2ff: not enough values in the field\n"); | ||
84 | return -ENODEV; | ||
85 | } | ||
86 | |||
87 | lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); | ||
88 | if (!lg2ff) | ||
89 | return -ENOMEM; | ||
90 | |||
91 | set_bit(FF_RUMBLE, dev->ffbit); | ||
92 | |||
93 | error = input_ff_create_memless(dev, lg2ff, play_effect); | ||
94 | if (error) { | ||
95 | kfree(lg2ff); | ||
96 | return error; | ||
97 | } | ||
98 | |||
99 | lg2ff->report = report; | ||
100 | report->field[0]->value[0] = 0xf3; | ||
101 | report->field[0]->value[1] = 0x00; | ||
102 | report->field[0]->value[2] = 0x00; | ||
103 | report->field[0]->value[3] = 0x00; | ||
104 | report->field[0]->value[4] = 0x00; | ||
105 | report->field[0]->value[5] = 0x00; | ||
106 | report->field[0]->value[6] = 0x00; | ||
107 | |||
108 | usbhid_submit_report(hid, report, USB_DIR_OUT); | ||
109 | |||
110 | printk(KERN_INFO "Force feedback for Logitech Rumblepad 2 by " | ||
111 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
112 | |||
113 | return 0; | ||
114 | } | ||