Skip to contentSkip to conversation

PS2 Input Core Support

DISCUSSION Udo A. Steinberg 3 participants 12 messages Jul 17, 2002 Input drivers

lore
Share & tools
lore
#0 lore raw

Hi Vojtech,

I'm running 2.5.26 with an ordinary PS/2 keyboard and a 5 button PS/2 mouse. When using the old psaux driver the mouse works fine.
With input core support, however, the scroll wheel doesn't work properly. In my XF86Config I'm using IMPS/2 protocol and ZAxisMapping 4 5. Scrolling up causes the window to scroll down. Scrolling down doesn't do anything. When changing the protocol to ExplorerPS2 things are not much better. You can't drag windows over the screen.

The following is the relevant kernel information.
Do you have any tips?

mice: PS/2 mouse device common for all mice
input.c: calling /sbin/hotplug input [HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add PRODUC input.c: hotplug returned -2
input: AT Set 2 keyboard on isa0060/serio0
serio: i8042 KBD port at 0x60,0x64 irq 1
serio: i8042 AUX port at 0x60,0x64 irq 12
input.c: calling /sbin/hotplug input [HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add PRODUC input.c: hotplug returned -2
input: ImExPS/2 Microsoft IntelliMouse Explorer on isa0060/serio1

Regards,
Udo.

#1 lore raw
Quoted 11 lines · Udo A. Steinberg

Hi Vojtech,

I'm running 2.5.26 with an ordinary PS/2 keyboard and a 5 button PS/2 mouse. When using the old psaux driver the mouse works fine.
With input core support, however, the scroll wheel doesn't work properly. In my XF86Config I'm using IMPS/2 protocol and ZAxisMapping 4 5. Scrolling up causes the window to scroll down. Scrolling down doesn't do anything. When changing the protocol to ExplorerPS2 things are not much better. You can't drag windows over the screen.

Quoted 2 lines

The following is the relevant kernel information.
Do you have any tips?

It's a bug. This patch should fix it:

drivers/input/mouse/psmouse.c +1 -1
diff -Nru a/drivers/input/mouse/psmouse.c b/drivers/input/mouse/psmouse.c
@@ -142,7 +142,7 @@
  */
 
 	if (psmouse->type == PSMOUSE_IMEX) {
-		input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 7) - (int) (packet[2] & 8));
+		input_report_rel(dev, REL_WHEEL, (int) (packet[2] & 8) - (int) (packet[3] & 7));
 		input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
 		input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
 	}
Quoted 12 lines

mice: PS/2 mouse device common for all mice
input.c: calling /sbin/hotplug input [HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add PRODUC input.c: hotplug returned -2
input: AT Set 2 keyboard on isa0060/serio0
serio: i8042 KBD port at 0x60,0x64 irq 1
serio: i8042 AUX port at 0x60,0x64 irq 12
input.c: calling /sbin/hotplug input [HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ACTION=add PRODUC input.c: hotplug returned -2
input: ImExPS/2 Microsoft IntelliMouse Explorer on isa0060/serio1

Regards,
Udo.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#2 lore raw
Quoted 2 lines · Vojtech Pavlik

It's a bug. This patch should fix it:

Hello,

With this patch I can now properly scroll down. But scrolling the mouse wheel up doesn't do any scrolling up in X.

-Udo.

#3 lore raw
Quoted 8 lines · Udo A. Steinberg
Quoted 2 lines · Vojtech Pavlik

It's a bug. This patch should fix it:

Hello,

With this patch I can now properly scroll down. But scrolling the mouse wheel up doesn't do any scrolling up in X.

This is interesting. Can you try the attached test utility? You need to enable CONFIG_INPUT_EVDEV, as well, and use it on /dev/input/evdev0 or 1, depening what's your mouse.

I'm wondering whether the scroll events show up or not.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs

/*
* $Id: evtest.c,v 1.18 2002/07/17 08:50:55 vojtech Exp $ *
* Copyright (c) 1999-2000 Vojtech Pavlik
*
* Event device test program
*/

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
* Should you need to contact me, the author, you can do so either by
* e-mail - mail your message to <[email protected]>, or by paper mail:
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */

#include <linux/input.h>

#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

char *events[EV_MAX + 1] = { "Reset", "Key", "Relative", "Absolute", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "LED", "Sound", NULL, "Repeat", "ForceFeedback", NULL, "ForceFeedbackStatus"};
char *keys[KEY_MAX + 1] = { "Reserved", "Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Minus", "Equal", "Backspace", "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LeftBrace", "RightBrace", "Enter", "LeftControl", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Semicolon", "Apostrophe", "Grave", "LeftShift", "BackSlash", "Z", "X", "C", "V", "B", "N", "M", "Comma", "Dot", "Slash", "RightShift", "KPAsterisk", "LeftAlt", "Space", "CapsLock", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NumLock", "ScrollLock", "KP7", "KP8", "KP9", "KPMinus", "KP4", "KP5", "KP6", "KPPlus", "KP1", "KP2", "KP3", "KP0", "KPDot", "103rd", "F13", "102nd", "F11", "F12", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "KPEnter", "RightCtrl", "KPSlash", "SysRq", "RightAlt", "LineFeed", "Home", "Up", "PageUp", "Left", "Right", "End", "Down", "PageDown", "Insert", "Delete", "Macro", "Mute", "VolumeDown", "VolumeUp", "Power", "KPEqual", "KPPlusMinus", "Pause", "F21", "F22", "F23", "F24", "KPComma", "LeftMeta", "RightMeta", "Compose", "Stop", "Again", "Props", "Undo", "Front", "Copy", "Open", "Paste", "Find", "Cut", "Help", "Menu", "Calc", "Setup", "Sleep", "WakeUp", "File", "SendFile", "DeleteFile", "X-fer", "Prog1", "Prog2", "WWW", "MSDOS", "Coffee", "Direction", "CycleWindows", "Mail", "Bookmarks", "Computer", "Back", "Forward", "CloseCD", "EjectCD", "EjectCloseCD", "NextSong", "PlayPause", "PreviousSong", "StopCD", "Record", "Rewind", "Phone", "ISOKey", "Config", "HomePage", "Refresh", "Exit", "Move", "Edit", "ScrollUp", "ScrollDown", "KPLeftParenthesis", "KPRightParenthesis",
"International1", "International2", "International3", "International4", "International5",
"International6", "International7", "International8", "International9",
"Language1", "Language2", "Language3", "Language4", "Language5", "Language6", "Language7", "Language8", "Language9", NULL,
"PlayCD", "PauseCD", "Prog3", "Prog4", "Suspend", "Close",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"Btn0", "Btn1", "Btn2", "Btn3", "Btn4", "Btn5", "Btn6", "Btn7", "Btn8", "Btn9",
NULL, NULL, NULL, NULL, NULL, NULL,
"LeftBtn", "RightBtn", "MiddleBtn", "SideBtn", "ExtraBtn", "ForwardBtn", "BackBtn",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"Trigger", "ThumbBtn", "ThumbBtn2", "TopBtn", "TopBtn2", "PinkieBtn",
"BaseBtn", "BaseBtn2", "BaseBtn3", "BaseBtn4", "BaseBtn5", "BaseBtn6",
NULL, NULL, NULL, "BtnDead",
"BtnA", "BtnB", "BtnC", "BtnX", "BtnY", "BtnZ", "BtnTL", "BtnTR", "BtnTL2", "BtnTR2", "BtnSelect", "BtnStart", "BtnMode", "BtnThumbL", "BtnThumbR", NULL,
"ToolPen", "ToolRubber", "ToolBrush", "ToolPencil", "ToolAirbrush", "ToolFinger", "ToolMouse", "ToolLens", NULL, NULL, "Touch", "Stylus", "Stylus2", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "Ok", "Select", "Goto", "Clear", "Power2", "Option", "Info", "Time", "Vendor",
"Archive", "Program", "Channel", "Favorites", "EPG", "PVR", "MHP", "Language",
"Title", "Subtitle", "Angle", "Zoom", "Mode", "Keyboard", "Screen", "PC", "TV",
"TV2", "VCR", "VCR2", "Sat", "Sat2", "CD", "Tape", "Radio", "Tuner", "Player",
"Text", "DVD", "Aux", "MP3", "Audio", "Video", "Directory", "List", "Memo",
"Calendar", "Red", "Green", "Yellow", "Blue", "ChannelUp", "ChannelDown",
"First", "Last", "AB", "Next", "Restart", "Slow", "Shuffle", "Break",
"Previous", "Digits", "Teen", "Twen" };

char *absval[5] = { "Value", "Min ", "Max ", "Fuzz ", "Flat " };
char *relatives[REL_MAX + 1] = { "X", "Y", "Z", NULL, NULL, NULL, "HWheel", "Dial", "Wheel" }; char *absolutes[ABS_MAX + 1] = { "X", "Y", "Z", "Rx", "Ry", "Rz", "Throttle", "Rudder", "Wheel", "Gas", "Brake", NULL, NULL, NULL, NULL, NULL,
"Hat0X", "Hat0Y", "Hat1X", "Hat1Y", "Hat2X", "Hat2Y", "Hat3X", "Hat 3Y", "Pressure", "Distance", "XTilt", "YTilt"}; char *leds[LED_MAX + 1] = { "NumLock", "CapsLock", "ScrollLock", "Compose", "Kana", "Sleep", "Suspend", "Mute" }; char *repeats[REP_MAX + 1] = { "Delay", "Period" };
char *sounds[SND_MAX + 1] = { "Bell", "Click" };

char **names[EV_MAX + 1] = { events, keys, relatives, absolutes, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, leds, sounds, NULL, repeats, NULL, NULL, NULL };

#define BITS_PER_LONG (sizeof(long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
#define BIT(x) (1UL<<OFF(x))
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)

int main (int argc, char **argv)

{
	int fd, rd, i, j, k;
	struct input_event ev[64];
	int version;
	unsigned short id[4];
	unsigned long bit[EV_MAX][NBITS(KEY_MAX)];
	char name[256] = "Unknown";
	int abs[5];

	if (argc < 2) {
		printf("Usage: evtest /dev/input/eventX\n");
		printf("Where X = input device number\n");
		exit(1);
	}

	if ((fd = open(argv[argc - 1], O_RDONLY)) < 0) {
		perror("evtest");
		exit(1);
	}

	if (ioctl(fd, EVIOCGVERSION, &version)) {
		perror("evtest: can't get version");
		exit(1);
	}

	printf("Input driver version is %d.%d.%d\n",
		version >> 16, (version >> 8) & 0xff, version & 0xff);

	ioctl(fd, EVIOCGID, id);
	printf("Input device ID: bus 0x%x vendor 0x%x product 0x%x version 0x%x\n",
		id[ID_BUS], id[ID_VENDOR], id[ID_PRODUCT], id[ID_VERSION]);

	ioctl(fd, EVIOCGNAME(sizeof(name)), name);
	printf("Input device name: \"%s\"\n", name);

	memset(bit, 0, sizeof(bit));
	ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]);
	printf("Supported events:\n");

	for (i = 0; i < EV_MAX; i++)
		if (test_bit(i, bit[0])) {
			printf("  Event type %d (%s)\n", i, events[i] ? events[i] : "?");
			ioctl(fd, EVIOCGBIT(i, KEY_MAX), bit[i]);
			for (j = 0; j < KEY_MAX; j++) 
				if (test_bit(j, bit[i])) {
					printf("    Event code %d (%s)\n", j, names[i] ? (names[i][j] ? names[i][j] : "?") : "?");
					if (i == EV_ABS) {
						ioctl(fd, EVIOCGABS(j), abs);
						for (k = 0; k < 5; k++)
							if ((k < 3) || abs[k])
								printf("      %s %6d\n", absval[k], abs[k]);
					}
				}
		}
		

	printf("Testing ... (interrupt to exit)\n");

	while (1) {
		rd = read(fd, ev, sizeof(struct input_event) * 64);

		if (rd < (int) sizeof(struct input_event)) {
			printf("yyy\n");
			perror("\nevtest: error reading");
			exit (1);
		}

		for (i = 0; i < rd / sizeof(struct input_event); i++)
			printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n",
				ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type,
				events[ev[i].type] ? events[ev[i].type] : "?",
				ev[i].code,
				names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?",
				ev[i].value);

	}
}
#4 lore raw
Quoted 6 lines · Vojtech Pavlik

This is interesting. Can you try the attached test utility? You need to enable CONFIG_INPUT_EVDEV, as well, and use it on /dev/input/evdev0 or 1, depening what's your mouse.

I'm wondering whether the scroll events show up or not.

Hello,

They show up in the output. First 4 events are scroll-down, last 4 events are scroll-up.

Regards,
-Udo.

./evtest /dev/input/event2
Input driver version is 1.0.0
Input device ID: bus 0x11 vendor 0x6 product 0x2 version 0x100 Input device name: "ImExPS/2 Microsoft IntelliMouse Explorer" Supported events:
Event type 1 (Key)
Event code 272 (LeftBtn)
Event code 273 (RightBtn)
Event code 274 (MiddleBtn)
Event code 275 (SideBtn)
Event code 276 (ExtraBtn)
Event type 2 (Relative)
Event code 0 (X)
Event code 1 (Y)
Event code 8 (Wheel)
Testing ... (interrupt to exit)
Event: time 1026908021.053509, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908021.607555, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908022.017017, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908022.412833, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908023.241679, type 2 (Relative), code 8 (Wheel), value -7
Event: time 1026908023.711842, type 2 (Relative), code 8 (Wheel), value -7
Event: time 1026908024.149266, type 2 (Relative), code 8 (Wheel), value -7
Event: time 1026908024.529600, type 2 (Relative), code 8 (Wheel), value -7

#5 lore raw
Quoted 6 lines · Udo A. Steinberg
Quoted 5 lines · Vojtech Pavlik

This is interesting. Can you try the attached test utility? You need to enable CONFIG_INPUT_EVDEV, as well, and use it on /dev/input/evdev0 or 1, depening what's your mouse.

Quoted 6 lines
Quoted 1 line

I'm wondering whether the scroll events show up or not.

Hello,

They show up in the output. First 4 events are scroll-down, last 4 events are scroll-up.

Ok, another patch. :)

drivers/input/mouse/psmouse.c +1 -1
diff -Nru a/drivers/input/mouse/psmouse.c b/drivers/input/mouse/psmouse.c
@@ -142,7 +142,7 @@
  */
 
 	if (psmouse->type == PSMOUSE_IMEX) {
-		input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[2] & 7));
+		input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 7) - (int) (packet[3] & 8));
 		input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
 		input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
 	}
Quoted 28 lines

Regards,
-Udo.

./evtest /dev/input/event2
Input driver version is 1.0.0
Input device ID: bus 0x11 vendor 0x6 product 0x2 version 0x100 Input device name: "ImExPS/2 Microsoft IntelliMouse Explorer" Supported events:
Event type 1 (Key)
Event code 272 (LeftBtn)
Event code 273 (RightBtn)
Event code 274 (MiddleBtn)
Event code 275 (SideBtn)
Event code 276 (ExtraBtn)
Event type 2 (Relative)
Event code 0 (X)
Event code 1 (Y)
Event code 8 (Wheel)
Testing ... (interrupt to exit)
Event: time 1026908021.053509, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908021.607555, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908022.017017, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908022.412833, type 2 (Relative), code 8 (Wheel), value -1
Event: time 1026908023.241679, type 2 (Relative), code 8 (Wheel), value -7
Event: time 1026908023.711842, type 2 (Relative), code 8 (Wheel), value -7
Event: time 1026908024.149266, type 2 (Relative), code 8 (Wheel), value -7
Event: time 1026908024.529600, type 2 (Relative), code 8 (Wheel), value -7

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#6 lore raw
Quoted 2 lines · Vojtech Pavlik

Ok, another patch. :)

Very close :)
Directions of scrolling are reversed. The following works ok:

drivers/input/mouse/psmouse.c Wed Jul 17 12:19:13 2002 +1 -1
diff -Nru a/drivers/input/mouse/psmouse.c b/drivers/input/mouse/psmouse.c
@@ -142,7 +142,7 @@
  */
 
        if (psmouse->type == PSMOUSE_IMEX) {
-               input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[2] & 7));
+               input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7));
                input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
                input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
        }

Regards,
-Udo.

#7 lore raw
Quoted 11 lines · Udo A. Steinberg
Quoted 2 lines · Vojtech Pavlik

Ok, another patch. :)

Very close :)
Directions of scrolling are reversed. The following works ok:

diff -Nru a/drivers/input/mouse/psmouse.c b/drivers/input/mouse/psmouse.c

drivers/input/mouse/psmouse.c Wed Jul 17 12:19:13 2002 line 148

Quoted 8 lines
drivers/input/mouse/psmouse.c Wed Jul 17 12:19:13 2002 +1 -1
@@ -142,7 +142,7 @@
  */
 
        if (psmouse->type == PSMOUSE_IMEX) {
-               input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[2] & 7));
+               input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7));
                input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
                input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
        }

Can you check with evtest again? Up should be showing as -1, down as 1. If it doesn't, then there is another direction bug elsewhere.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#8 lore raw
Quoted 2 lines · Vojtech Pavlik

Can you check with evtest again? Up should be showing as -1, down as 1.

With my patch up is 1 and down is -1 and things scroll the right way.

Quoted 1 line

If it doesn't, then there is another direction bug elsewhere.

Possibly.

-Udo.

#9 lore raw
Quoted 5 lines · Udo A. Steinberg
Quoted 2 lines · Vojtech Pavlik

Can you check with evtest again? Up should be showing as -1, down as 1.

With my patch up is 1 and down is -1 and things scroll the right way.

What protocol are you using in X?
Does this happen with both ExplorerPS/2 and ImPS/2?

Quoted 3 lines
Quoted 1 line

If it doesn't, then there is another direction bug elsewhere.

Possibly.

mousedev.c

Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#10 lore raw
Quoted 1 line · Vojtech Pavlik

What protocol are you using in X?

ImPS/2

Quoted 1 line

Does this happen with both ExplorerPS/2 and ImPS/2?

Both ImPS/2 and ExplorerPS/2 behave the same way when configured with 5 buttons and ZAxisMapping 4 5.

When using ExplorerPS/2 with 7 buttons and ZAxisMapping 6 7, then scrolling doesn't work at all, however evtest displays all button and scroll events correctly (with scroll directions reversed).

-Udo.

#11 lore raw
In reply to Udo A. Steinberg
Quoted 7 lines · Udo A. Steinberg

I'm running 2.5.26 with an ordinary PS/2 keyboard and a 5 button PS/2 mouse. When using the old psaux driver the mouse works fine.
With input core support, however, the scroll wheel doesn't work properly. In my XF86Config I'm using IMPS/2 protocol and ZAxisMapping 4 5. Scrolling up causes the window to scroll down. Scrolling down doesn't do anything. When changing the protocol to ExplorerPS2 things are not much better. You can't drag windows over the screen.

I think this is no kernel problem. You have 7 buttons (5 + 2 wheel).

Try this: http://www.deadman.org/X/xbuttons.html or google for intellimouse and linux.

Regards,
Oliver.