* [PATCH] Input: amimouse - Fix the buttons
@ 2026-11-24 10:06 Daniel Palmer
2026-11-24 10:48 ` Geert Uytterhoeven
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Palmer @ 2026-11-24 10:06 UTC (permalink / raw)
To: dmitry.torokhov, linux-input; +Cc: linux-m68k, linux-kernel, 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".
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")
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
drivers/input/mouse/amimouse.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c
index d203c2a6c438..caf35ddf3d06 100644
--- a/drivers/input/mouse/amimouse.c
+++ b/drivers/input/mouse/amimouse.c
@@ -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);
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: amimouse - Fix the buttons
2026-11-24 10:06 [PATCH] Input: amimouse - Fix the buttons Daniel Palmer
@ 2026-11-24 10:48 ` Geert Uytterhoeven
2026-11-24 10:55 ` Philippe De Muyter
2026-11-24 18:19 ` Dmitry Torokhov
2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2026-11-24 10:48 UTC (permalink / raw)
To: Daniel Palmer; +Cc: dmitry.torokhov, linux-input, linux-m68k, linux-kernel
Hi Daniel,
On Tue, 24 Nov 2026 at 11:06, Daniel Palmer <daniel@0x0f.com> wrote:
> 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")
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Thanks for your patch!
> --- a/drivers/input/mouse/amimouse.c
> +++ b/drivers/input/mouse/amimouse.c
> @@ -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);
Nice catch!
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
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 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: amimouse - Fix the buttons
2026-11-24 10:06 [PATCH] Input: amimouse - Fix the buttons Daniel Palmer
2026-11-24 10:48 ` Geert Uytterhoeven
@ 2026-11-24 10:55 ` Philippe De Muyter
2026-11-24 18:19 ` Dmitry Torokhov
2 siblings, 0 replies; 4+ messages in thread
From: Philippe De Muyter @ 2026-11-24 10:55 UTC (permalink / raw)
To: Daniel Palmer; +Cc: dmitry.torokhov, linux-input, linux-m68k, linux-kernel
Hello Daniel,
On Tue, Nov 24, 2026 at 07:06:04PM +0900, Daniel Palmer wrote:
> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: amimouse - Fix the buttons
2026-11-24 10:06 [PATCH] Input: amimouse - Fix the buttons Daniel Palmer
2026-11-24 10:48 ` Geert Uytterhoeven
2026-11-24 10:55 ` Philippe De Muyter
@ 2026-11-24 18:19 ` Dmitry Torokhov
2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2026-11-24 18:19 UTC (permalink / raw)
To: Daniel Palmer; +Cc: linux-input, linux-m68k, linux-kernel
On Tue, Nov 24, 2026 at 07:06:04PM +0900, Daniel Palmer wrote:
> 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")
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-24 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 10:06 [PATCH] Input: amimouse - Fix the buttons Daniel Palmer
2026-11-24 10:48 ` Geert Uytterhoeven
2026-11-24 10:55 ` Philippe De Muyter
2026-11-24 18:19 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox