public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: torvalds@osdl.org, vojtech@ucw.cz, linux-kernel@vger.kernel.org
Subject: [PATCH 9/44] Support for scroll wheel on Office keyboards
Date: Tue, 16 Mar 2004 15:19:36 +0100	[thread overview]
Message-ID: <10794467761141@twilight.ucw.cz> (raw)
In-Reply-To: <1079446776784@twilight.ucw.cz>

You can pull this changeset from:
	bk://kernel.bkbits.net/vojtech/input

===================================================================

ChangeSet@1.1474.188.9, 2004-01-26 13:56:47+01:00, vojtech@suse.cz
  input: Add support for scroll wheel on MS Office and similar keyboards.


 atkbd.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 58 insertions(+), 7 deletions(-)

===================================================================

diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c	Tue Mar 16 13:19:47 2004
+++ b/drivers/input/keyboard/atkbd.c	Tue Mar 16 13:19:47 2004
@@ -33,18 +33,18 @@
 MODULE_PARM(atkbd_set, "1i");
 MODULE_PARM(atkbd_reset, "1i");
 MODULE_PARM(atkbd_softrepeat, "1i");
+MODULE_PARM(atkbd_scroll, "1i");
 MODULE_LICENSE("GPL");
 
 static int atkbd_set = 2;
 module_param_named(set, atkbd_set, int, 0);
 MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3, 4)");
+
 #if defined(__i386__) || defined(__x86_64__) || defined(__hppa__)
 static int atkbd_reset;
 #else
 static int atkbd_reset = 1;
 #endif
-static int atkbd_softrepeat;
-
 module_param_named(reset, atkbd_reset, bool, 0);
 MODULE_PARM_DESC(reset, "Reset keyboard during initialization");
 
@@ -52,6 +52,10 @@
 module_param_named(softrepeat, atkbd_softrepeat, bool, 0);
 MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat");
 
+static int atkbd_scroll;
+module_parm_named(scroll, atkbd_scroll, bool, 0);
+MODULE_PARM_DESC_(scroll, "Enable scroll-wheel on office keyboards");
+
 /*
  * Scancode to keycode tables. These are just the default setting, and
  * are loadable via an userland utility.
@@ -127,11 +131,11 @@
 #define ATKBD_CMD_EX_SETLEDS	0x20eb
 #define ATKBD_CMD_OK_GETID	0x02e8
 
+
 #define ATKBD_RET_ACK		0xfa
 #define ATKBD_RET_NAK		0xfe
 #define ATKBD_RET_BAT		0xaa
 #define ATKBD_RET_EMUL0		0xe0
-#define ATKBD_RET_EMULX		0x80
 #define ATKBD_RET_EMUL1		0xe1
 #define ATKBD_RET_RELEASE	0xf0
 #define ATKBD_RET_HANGUEL	0xf1
@@ -141,6 +145,22 @@
 #define ATKBD_KEY_UNKNOWN	  0
 #define ATKBD_KEY_NULL		255
 
+#define ATKBD_SCR_1		254
+#define ATKBD_SCR_2		253
+#define ATKBD_SCR_4		252
+#define ATKBD_SCR_8		251
+#define ATKBD_SCR_CLICK		250
+
+#define ATKBD_SPECIAL		250
+
+static unsigned char atkbd_scroll_keys[5][2] = {
+	{ ATKBD_SCR_1,     0x45 },
+	{ ATKBD_SCR_2,     0x29 },
+	{ ATKBD_SCR_4,     0x36 },
+	{ ATKBD_SCR_8,     0x27 },
+	{ ATKBD_SCR_CLICK, 0x60 },
+};
+
 /*
  * The atkbd control structure
  */
@@ -189,6 +209,7 @@
 {
 	struct atkbd *atkbd = serio->private;
 	unsigned int code = data;
+	int scroll = 0, click = -1;
 	int value;
 
 #ifdef ATKBD_DEBUG
@@ -284,6 +305,21 @@
 			else
 				printk(KERN_WARNING "atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n",						code & 0x80 ? "e0" : "", code & 0x7f);
 			break;
+		case ATKBD_SCR_1:
+			scroll = 1 - atkbd->release * 2;
+			break;
+		case ATKBD_SCR_2:
+			scroll = 2 - atkbd->release * 4;
+			break;
+		case ATKBD_SCR_4:
+			scroll = 4 - atkbd->release * 8;
+			break;
+		case ATKBD_SCR_8:
+			scroll = 8 - atkbd->release * 16;
+			break;
+		case ATKBD_SCR_CLICK:
+			click = !atkbd->release;
+			break;
 		default:
 			value = atkbd->release ? 0 :
 				(1 + (!atkbd_softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key)));
@@ -305,6 +341,13 @@
 			atkbd_report_key(&atkbd->dev, regs, atkbd->keycode[code], value);
 	}
 
+	if (scroll || click != -1) {
+		input_regs(&atkbd->dev, regs);
+		input_report_key(&atkbd->dev, BTN_MIDDLE, click);
+		input_report_rel(&atkbd->dev, REL_WHEEL, scroll);
+		input_sync(&atkbd->dev);
+	}
+
 	atkbd->release = 0;
 out:
 	return IRQ_HANDLED;
@@ -705,15 +748,23 @@
 
 	sprintf(atkbd->phys, "%s/input0", serio->phys);
 
+	if (atkbd_scroll) {
+		for (i = 0; i < 5; i++)
+			atkbd_set2_keycode[atkbd_scroll_keys[i][1]] = atkbd_scroll_keys[i][0];
+		atkbd->dev.evbit[0] |= BIT(EV_REL);
+		atkbd->dev.relbit[0] = BIT(REL_WHEEL);
+		set_bit(BTN_MIDDLE, atkbd->dev.keybit);
+	}
+
 	if (atkbd->translated) {
 		for (i = 0; i < 128; i++) {
 			atkbd->keycode[i] = atkbd_set2_keycode[atkbd_unxlate_table[i]];
 			atkbd->keycode[i | 0x80] = atkbd_set2_keycode[atkbd_unxlate_table[i] | 0x80];
 		}
-	} else if (atkbd->set == 2) {
-		memcpy(atkbd->keycode, atkbd_set2_keycode, sizeof(atkbd->keycode));
-	} else {
+	} else if (atkbd->set == 3) {
 		memcpy(atkbd->keycode, atkbd_set3_keycode, sizeof(atkbd->keycode));
+	} else {
+		memcpy(atkbd->keycode, atkbd_set2_keycode, sizeof(atkbd->keycode));
 	}
 
 	atkbd->dev.name = atkbd->name;
@@ -724,7 +775,7 @@
 	atkbd->dev.id.version = atkbd->id;
 
 	for (i = 0; i < 512; i++)
-		if (atkbd->keycode[i] && atkbd->keycode[i] < 255)
+		if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL)
 			set_bit(atkbd->keycode[i], atkbd->dev.keybit);
 
 	input_register_device(&atkbd->dev);


  reply	other threads:[~2004-03-16 14:42 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-16 14:17 [44 patches] Input update Vojtech Pavlik
2004-03-16 14:19 ` [PATCH 1/44] Fix hid-core for devices with #usages < #values Vojtech Pavlik
2004-03-16 14:19   ` [PATCH 2/44] Add ioctl to hiddev to set multiple usages at once Vojtech Pavlik
2004-03-16 14:19     ` [PATCH 3/44] HID quirk (badpad) for Saitek Rumblepad Vojtech Pavlik
2004-03-16 14:19       ` [PATCH 4/44] HID quirk for another A4Tech dual-wheel mouse Vojtech Pavlik
2004-03-16 14:19         ` [PATCH 5/44] .ko module names for acm.txt Vojtech Pavlik
2004-03-16 14:19           ` [PATCH 6/44] Fix sunkbd.c to work with serport Vojtech Pavlik
2004-03-16 14:19             ` [PATCH 7/44] request_region() instead of check_region() in ns558.c Vojtech Pavlik
2004-03-16 14:19               ` [PATCH 8/44] Don't reinitialize scancode map after sleep in atkbd.c Vojtech Pavlik
2004-03-16 14:19                 ` Vojtech Pavlik [this message]
2004-03-16 14:19                   ` [PATCH 10/44] Make enabling IBM RapidAccess special features its own option Vojtech Pavlik
2004-03-16 14:19                     ` [PATCH 11/44] Convert HP/PARISC Lasi/Dino PS/2 driver to a serio driver Vojtech Pavlik
2004-03-16 14:19                       ` [PATCH 12/44] Credit to Panagiotis Issaris for Graphire 3 support Vojtech Pavlik
2004-03-16 14:19                         ` [PATCH 13/44] Remove the obsolete busmouse.c helper driver Vojtech Pavlik
2004-03-16 14:19                           ` [PATCH 14/44] Fix a warning in i8042.c Vojtech Pavlik
2004-03-16 14:19                             ` [PATCH 15/44] Add serio entries for LK keyboards Vojtech Pavlik
2004-03-16 14:19                               ` [PATCH 16/44] Whitespace in atkbd.c Vojtech Pavlik
2004-03-16 14:19                                 ` [PATCH 17/44] Automatically decide how strictly to check the protocol in synaptics Vojtech Pavlik
2004-03-16 14:19                                   ` [PATCH 18/44] Whitespace fixes in psmouse.c Vojtech Pavlik
2004-03-16 14:19                                     ` [PATCH 19/44] Don't fail when mouse reset doesn't work Vojtech Pavlik
2004-03-16 14:19                                       ` [PATCH 20/44] Add module_parm_array() helper Vojtech Pavlik
2004-03-16 14:19                                         ` [PATCH 21/44] Convert joystick drivers to new module parameters Vojtech Pavlik
2004-03-16 14:19                                           ` [PATCH 22/44] Create __obsolete_setup() macro to warn users about obsolete kernel params Vojtech Pavlik
2004-03-16 14:19                                             ` [PATCH 23/44] Use __obsolete_setup() in input drivers to warn " Vojtech Pavlik
2004-03-16 14:19                                               ` [PATCH 24/44] Workaround i8042 chips with broken MUX mode Vojtech Pavlik
2004-03-16 14:19                                                 ` [PATCH 25/44] Only reprobe on PS/2 HW when the HW sends 0xaa Vojtech Pavlik
2004-03-16 14:19                                                   ` [PATCH 26/44] Always assume i8042 is in XLATE mode Vojtech Pavlik
2004-03-16 14:19                                                     ` [PATCH 27/44] Add DEC LK201/LK401 keyboard support Vojtech Pavlik
2004-03-17 19:08                                                       ` Maciej W. Rozycki
2004-03-16 18:46                   ` [PATCH 9/44] Support for scroll wheel on Office keyboards Aubin LaBrosse
2004-03-19 14:00                     ` Vojtech Pavlik
2004-03-27 19:55                   ` Andries Brouwer
2004-03-30 13:09                     ` Pavel Machek
2004-03-30 17:05                       ` Paul Wagland
2004-03-30 18:55                       ` Vojtech Pavlik
2004-03-30 18:53                     ` Vojtech Pavlik
2004-05-29 14:36                     ` Vojtech Pavlik

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=10794467761141@twilight.ucw.cz \
    --to=vojtech@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vojtech@ucw.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