Skip to contentSkip to conversation

Input: amimouse - Fix the buttons

PATCH Applied Daniel Palmer 4 participants 4 messages Nov 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: amimouse - Fix the buttons

On the Amiga the left button is connected to CIAAPRA bit 6 (/FIR0) and the middle and right ones are POTINP (called potgor in the code) bits 8 (DATLX) and 10 (DATLY), all of these are active low according to the "Amiga Hardware Reference Manual (3rd edition)":

In chapter 8, "Interface Hardware": under "Mouse Buttons" a 0 in CIAAPRA bit 6 means "switch closed", and under "Digital I/O on the Controller Port" reading POTINP "will produce a 0 if the button is pressed, a 1 if it is not".

Invert the bits from the registers so the state of the buttons is correct.

Tested with Quake on a real Amiga 4000.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/input/mouse/amimouse.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/input/mouse/amimouse.c +4 -3
index d203c2a6c438..caf35ddf3d06 100644
@@ -58,9 +58,10 @@ static irqreturn_t amimouse_interrupt(int irq, void *data)
 	input_report_rel(dev, REL_X, dx);
 	input_report_rel(dev, REL_Y, dy);
 
-	input_report_key(dev, BTN_LEFT,   ciaa.pra & 0x40);
-	input_report_key(dev, BTN_MIDDLE, potgor & 0x0100);
-	input_report_key(dev, BTN_RIGHT,  potgor & 0x0400);
+	/* the buttons are active low */
+	input_report_key(dev, BTN_LEFT,   !(ciaa.pra & 0x40));
+	input_report_key(dev, BTN_MIDDLE, !(potgor & 0x0100));
+	input_report_key(dev, BTN_RIGHT,  !(potgor & 0x0400));
 
 	input_sync(dev);
 
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Daniel,

Quoted 10 lines · Daniel Palmer

On the Amiga the left button is connected to CIAAPRA bit 6 (/FIR0) and the middle and right ones are POTINP (called potgor in the code) bits 8 (DATLX) and 10 (DATLY), all of these are active low according to the "Amiga Hardware Reference Manual (3rd edition)":

In chapter 8, "Interface Hardware": under "Mouse Buttons" a 0 in CIAAPRA bit 6 means "switch closed", and under "Digital I/O on the Controller Port" reading POTINP "will produce a 0 if the button is pressed, a 1 if it is not".

Quoted 7 lines

Invert the bits from the registers so the state of the buttons is correct.

Tested with Quake on a real Amiga 4000.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

Thanks for your patch!

Quoted 5 lines
drivers/input/mouse/amimouse.c +0 -0
@@ -58,9 +58,10 @@ static irqreturn_t amimouse_interrupt(int irq, void *data)
        input_report_rel(dev, REL_X, dx);
        input_report_rel(dev, REL_Y, dy);

drivers/input/mouse/amimouse.c static irqreturn_t amimouse_interrupt(int irq, void *data) · line 66

Quoted 10 lines
drivers/input/mouse/amimouse.c +4 -3
 
-       input_report_key(dev, BTN_LEFT,   ciaa.pra & 0x40);
-       input_report_key(dev, BTN_MIDDLE, potgor & 0x0100);
-       input_report_key(dev, BTN_RIGHT,  potgor & 0x0400);
+       /* the buttons are active low */
+       input_report_key(dev, BTN_LEFT,   !(ciaa.pra & 0x40));
+       input_report_key(dev, BTN_MIDDLE, !(potgor & 0x0100));
+       input_report_key(dev, BTN_RIGHT,  !(potgor & 0x0400));
 
        input_sync(dev);

Nice catch!

That bug was introduced in in full-history-linux commit 7c40d075b02b3ddd ("Add keyboard, mouse and touchscreen drivers. Add tsdev, power and evbug event handlers.") when converting drivers/char/amigamouse.c.

How come we never noticed before? I did use the mouse after that, cfr.
https://lists.x.org/archives/xorg-devel/2013-March/035831.html

Comparing drivers/input/mouse/inport.c to the old drivers/char/atixlmouse.c, I am wondering if the same bug is present there, too?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw
In reply to Daniel Palmer

Hello Daniel,

Quoted 4 lines · Daniel Palmer

On the Amiga the left button is connected to CIAAPRA bit 6 (/FIR0) and the middle and right ones are POTINP (called potgor in the code) bits 8 (DATLX) and 10 (DATLY), all of these are active low according to the "Amiga Hardware Reference Manual (3rd edition)":

Try to put the word 'mouse' in the prevous sentence. I had to read the description twice to understand what you're talking about.

Best

Philippe (not a amiga user)

maintainer Applied
#3 lore raw
In reply to Daniel Palmer
Quoted 10 lines · Daniel Palmer

On the Amiga the left button is connected to CIAAPRA bit 6 (/FIR0) and the middle and right ones are POTINP (called potgor in the code) bits 8 (DATLX) and 10 (DATLY), all of these are active low according to the "Amiga Hardware Reference Manual (3rd edition)":

In chapter 8, "Interface Hardware": under "Mouse Buttons" a 0 in CIAAPRA bit 6 means "switch closed", and under "Digital I/O on the Controller Port" reading POTINP "will produce a 0 if the button is pressed, a 1 if it is not".

Quoted 7 lines

Invert the bits from the registers so the state of the buttons is correct.

Tested with Quake on a real Amiga 4000.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

Applied, thank you.

Signature · 1 line
Dmitry