Thread (11 messages) 11 messages, 5 authors, 2020-06-19

Re: [PATCH v3] HID: Wiimote: Treat the d-pad as an analogue stick

From: David Rheinsberg <hidden>
Date: 2020-06-01 07:27:43

Hi

On Sat, 30 May 2020 at 17:04, Daniel Morse [off-list ref] wrote:
The controllers from the Super Nintendo Classic Edition (AKA the SNES
Mini) appear as a Classic Controller Pro when connected to a Wii
Remote. All the buttons work as the same, with the d-pad being mapped
the same as the d-pad on the Classic Controller Pro. This differs from
the behaviour of most controllers with d-pads and no analogue sticks,
where the d-pad maps to ABS_HAT1X for left and right, and ABS_HAT1Y
for up and down. This patch adds an option to the hid-wiimote module
to make the Super Nintendo Classic Controller behave this way.

The patch has been tested with a Super Nintendo Classic Controller
plugged into a Wii Remote in both with the option both enabled and
disabled. When enabled the d-pad acts as the analogue control, and
when disabled it acts as it did before the patch was applied. This
patch has not been tested with e Wii Classic Controller (either the
original or the pro version) as I do not have one of these
controllers.

Although I have not tested it with these controllers, I think it is
likely this patch will also work with the NES Classic Edition
Controllers.

Changes from V1 to V2
* 3 if statements to control the behaviour, one to make the d-pad
register as button presses when the behaviour is disabled, and 2 to
make it act as an analog stick when enabled (once for each of the
motion plus states)
* the values for lx and ly are calculated and then passed to
input_report_abs() in one place, rather then calling
input_report_abs() from different places depending on how the values
are determined.
* using an array to map from button presses to analog value.
* reduced the values used to indicate the position of the analog stick

Changes from V3 to V3
* Moved the definition of dpad_as_analog in hid-wiimote.h
* Renamed the dpad_as_analog vaiable to wiimote_dpad_as_analog
* changed digital_to_analog from an __s8 to static const s8
* Removed the unnecessary braces when getting values from digital_to_analog

Note: I have also attached a patch file to this final version in
addition to the code in the body because gmail web client keeps
turning the tabs into spaces.

Signed-off-by: Daniel G. Morse <redacted>
Reviewed-by: David Rheinsberg <redacted>

From 8909feec10fda919d1ec46c95418d63ac52ee41f Mon Sep 17 00:00:00 2001
From: Speedfox <redacted>
Date: Tue, 26 May 2020 02:55:50 +0100
Subject: [PATCH] Added option to make d-pad analog

Updates from code review
---
You can put comments below these 3 dashes^^. There seems to be some
email-header in the commit message above, and the changes between
versions can also be put outside of the commit message. Some
subsystems keep it in the commit-message, though. Maybe Jiri can strip
that when applying? The `Signed-off-by`-etc lines are usually last in
the commit-message. I don't mind either way.

Anyway, thanks for the patch, looks all good!
David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help