linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] psmouse: add support for 4th button using the 4th bit
@ 2007-04-02 20:48 Aristeu Rozanski
  2007-04-03 14:39 ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Aristeu Rozanski @ 2007-04-02 20:48 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input

Some mice like the Cortron Trackball use the fourth bit of the first byte
(yes, that one that the protocol tells to be always 1, oh well) to represent
the fourth button. This patch adds an option to use the fourth bit to
represent the fourth button.

Please comment on this and please keep me on Cc list, I'm not subscribed to
linux-input.

---
 drivers/input/mouse/psmouse-base.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

--- linus-2.6.orig/drivers/input/mouse/psmouse-base.c
+++ linus-2.6/drivers/input/mouse/psmouse-base.c
@@ -64,6 +64,13 @@ static unsigned int psmouse_resync_time;
 module_param_named(resync_time, psmouse_resync_time, uint, 0644);
 MODULE_PARM_DESC(resync_time, "How long can mouse stay idle before forcing resync (in seconds, 0 = never).");
 
+static unsigned int psmouse_4th_bit_as_button;
+module_param_named(4th_bit_as_button, psmouse_4th_bit_as_button, uint, 0);
+MODULE_PARM_DESC(4th_bit_as_button, "Interpret the 4th bit of the first byte "
+		 "as 4th button. Some mice like Cortron Trackballs use the "
+		 "4th bit (which should be always set) of the first byte as "
+		 "4th button");
+
 PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO,
 			NULL,
 			psmouse_attr_show_protocol, psmouse_attr_set_protocol);
@@ -176,6 +183,14 @@ static psmouse_ret_t psmouse_process_byt
 		packet[1] |= (packet[0] & 0x40) << 1;
 	}
 
+ /*
+ * Use the 4th bit of the first package as button
+ */
+	if (psmouse_4th_bit_as_button) {
+		input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1);
+		packet[0] |= 0x08;
+	}
+
 /*
  * Generic PS/2 Mouse
  */
@@ -643,6 +658,9 @@ static int psmouse_extensions(struct psm
 		psmouse_reset(psmouse);
 	}
 
+	if (psmouse_4th_bit_as_button)
+		set_bit(BTN_SIDE, psmouse->dev->keybit);
+
 	return PSMOUSE_PS2;
 }
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-05-09 15:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-02 20:48 [RFC] psmouse: add support for 4th button using the 4th bit Aristeu Rozanski
2007-04-03 14:39 ` Dmitry Torokhov
2007-04-03 14:42   ` Aristeu Rozanski
2007-04-03 15:05     ` Dmitry Torokhov
2007-04-03 15:23       ` Aristeu Rozanski
2007-05-08 18:53       ` Aristeu Rozanski
2007-05-09 14:36         ` Dmitry Torokhov
2007-05-09 14:53           ` [PATCH] " Aristeu Rozanski
2007-05-09 15:39             ` Dmitry Torokhov
2007-05-09 15:49               ` Aristeu Rozanski

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).