linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aristeu Rozanski <arozansk@redhat.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@atrey.karlin.mff.cuni.cz
Subject: [RFC] psmouse: add support for 4th button using the 4th bit
Date: Mon, 2 Apr 2007 16:48:10 -0400	[thread overview]
Message-ID: <20070402204810.GC14838@redhat.com> (raw)

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;
 }
 

             reply	other threads:[~2007-04-02 20:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-02 20:48 Aristeu Rozanski [this message]
2007-04-03 14:39 ` [RFC] psmouse: add support for 4th button using the 4th bit 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070402204810.GC14838@redhat.com \
    --to=arozansk@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).