* [PATCH 2.6.28] mousedev: Allow devices to be excluded from /dev/input/mice
@ 2009-01-30 12:04 Richard Atterer
2009-01-31 4:29 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Richard Atterer @ 2009-01-30 12:04 UTC (permalink / raw)
To: linux-kernel; +Cc: vojtech, linux-input, dtor, rubini, jkosina
From: Richard Atterer <atterer@debian.org>
Allow devices to be excluded from /dev/input/mice
This patch adds an "ignoreid=0x1234:0x5678" parameter to the mousedev
module. If a mouse matches the given device ID(s), its movement and button
presses will not be relayed via /dev/input/mice.
Why is this needed? In my case, I'm using some mice as sensors (robotic
application, more or less), so their movement should not influence the
mouse pointer at all. I could simply specify only my main mouse in
xorg.conf rather than /dev/input/mice. However, /dev/input/mice is the only
way to allow hot-plugging of mice with X.
This feature could also be used to disable non-working/buggy touchpads in
laptops.
As soon as the "ignoreid" parameter is used, the code also prints out
information on devices that it does *not* ignore, to help users find out
the device IDs they may want to blacklist.
mousedev is usually compiled into the kernel rather than as a module, so I
would have liked to make the sysfs permissions for the parameter 0644
rather than 0444. However, I believe there may be a bug in the code for
array-of-charp parameters which prevents this from working:
After setting up the array via an "echo" to the sysfs file, only the number
of array entries is set correctly, the strings themselves are usually empty
or point to garbage. I don't think my own code is at fault here!? :-/
Richard
Signed-off-by: Richard Atterer <atterer@debian.org>
---
mousedev.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
--- a/drivers/input/mousedev.c 2008-12-25 00:26:37.000000000 +0100
+++ b/drivers/input/mousedev.c 2009-01-26 22:36:06.417673499 +0100
@@ -49,6 +49,18 @@ static unsigned tap_time = 200;
module_param(tap_time, uint, 0644);
MODULE_PARM_DESC(tap_time, "Tap time for touchpads in absolute mode (msecs)");
+static char* ignoreid[8];
+static int ignoreid_count;
+/* Would like to make this 0644, but overwriting via sysfs seems buggy: */
+module_param_array(ignoreid, charp, &ignoreid_count, 0444);
+MODULE_PARM_DESC(ignoreid, "Specify input IDs of mouse devices which"
+ " should not be included in /dev/input/mice, as a"
+ " comma-separated list of \"idVendor:idProduct\" pairs,"
+ " e.g. ignoreid=idVendor0:idProduct0,idVendor1:idProduct1"
+ " where both idVendor and idProduct are hex with a 0x"
+ " prefix. Changes after module load time only work for"
+ " devices that are not yet plugged in.");
+
struct mousedev_hw_data {
int dx, dy, dz;
int x, y;
@@ -962,6 +974,22 @@ static void mixdev_remove_device(struct
put_device(&mousedev->dev);
}
+static int mixdev_ignore(struct input_dev *dev) {
+ u16 idVendor, idProduct;
+ int i;
+ for (i = 0; i < ignoreid_count; ++i) {
+ int m = sscanf(ignoreid[i], "0x%hx:0x%hx", &idVendor, &idProduct);
+ if (m != 2) {
+ printk(KERN_WARNING "mousedev: Could not parse"
+ " ignoreid param #%d \"%s\"\n", i, ignoreid[i]);
+ continue;
+ }
+ if (dev->id.vendor == idVendor && dev->id.product == idProduct)
+ return 1;
+ }
+ return 0;
+}
+
static int mousedev_connect(struct input_handler *handler,
struct input_dev *dev,
const struct input_device_id *id)
@@ -970,6 +998,18 @@ static int mousedev_connect(struct input
int minor;
int error;
+ if (ignoreid_count) {
+ if (mixdev_ignore(dev)) {
+ printk(KERN_INFO "mousedev: Ignoring device"
+ " 0x%04x:0x%04x for /dev/input/mice\n",
+ dev->id.vendor, dev->id.product);
+ return 0;
+ }
+ printk(KERN_INFO "mousedev: Including device"
+ " 0x%04x:0x%04x in /dev/input/mice\n",
+ dev->id.vendor, dev->id.product);
+ }
+
for (minor = 0; minor < MOUSEDEV_MINORS; minor++)
if (!mousedev_table[minor])
break;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.28] mousedev: Allow devices to be excluded from /dev/input/mice
2009-01-30 12:04 [PATCH 2.6.28] mousedev: Allow devices to be excluded from /dev/input/mice Richard Atterer
@ 2009-01-31 4:29 ` Dmitry Torokhov
2009-01-31 19:17 ` Richard Atterer
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2009-01-31 4:29 UTC (permalink / raw)
To: Richard Atterer; +Cc: linux-kernel, vojtech, linux-input, rubini, jkosina
Hi Richard,
On Friday 30 January 2009 04:04:56 Richard Atterer wrote:
> From: Richard Atterer <atterer@debian.org>
>
> Allow devices to be excluded from /dev/input/mice
>
> This patch adds an "ignoreid=0x1234:0x5678" parameter to the mousedev
> module. If a mouse matches the given device ID(s), its movement and button
> presses will not be relayed via /dev/input/mice.
>
Thank you for the patch, however I don't think that it is the right solution.
> Why is this needed? In my case, I'm using some mice as sensors (robotic
> application, more or less), so their movement should not influence the
> mouse pointer at all.
I think this is the case where EVIOCGRAB use is warranted then.
> I could simply specify only my main mouse in
> xorg.conf rather than /dev/input/mice. However, /dev/input/mice is the only
> way to allow hot-plugging of mice with X.
>
The newer X does support input hotplug pretty well actually.
> This feature could also be used to disable non-working/buggy touchpads in
> laptops.
>
You can already do that by unbinding serio and usb devices from their
respective drivers, no need to modify mousedev.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.28] mousedev: Allow devices to be excluded from /dev/input/mice
2009-01-31 4:29 ` Dmitry Torokhov
@ 2009-01-31 19:17 ` Richard Atterer
0 siblings, 0 replies; 3+ messages in thread
From: Richard Atterer @ 2009-01-31 19:17 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel, linux-input
Hi Dmitry,
On Fri, Jan 30, 2009 at 08:29:59PM -0800, Dmitry Torokhov wrote:
> On Friday 30 January 2009 04:04:56 Richard Atterer wrote:
> > In my case, I'm using some mice as sensors (robotic application, more
> > or less), so their movement should not influence the mouse pointer at
> > all.
>
> I think this is the case where EVIOCGRAB use is warranted then.
Many thanks for the suggestion - that's exactly what I need! :-)
Richard
--
__ _
|_) /| Richard Atterer | GnuPG key: 888354F7
| \/¯| http://atterer.net | 08A9 7B7D 3D13 3EF2 3D25 D157 79E6 F6DC 8883 54F7
¯ '` ¯
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-01-31 19:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-30 12:04 [PATCH 2.6.28] mousedev: Allow devices to be excluded from /dev/input/mice Richard Atterer
2009-01-31 4:29 ` Dmitry Torokhov
2009-01-31 19:17 ` Richard Atterer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).