linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "François-Xavier Carton" <fx.carton91@gmail.com>
To: linux-input@vger.kernel.org
Cc: "François-Xavier Carton" <fx.carton91@gmail.com>
Subject: [PATCH 3/3] HID: gamecube-adapter: make axis limits parameters
Date: Wed,  6 May 2020 02:48:01 +0200	[thread overview]
Message-ID: <20200506004801.9478-3-fx.carton91@gmail.com> (raw)
In-Reply-To: <20200506004801.9478-1-fx.carton91@gmail.com>

The axes do not cover the full 0-255 range, with different limit values
for each axis. The limits are made module parameters so they can be
configured.

Signed-off-by: François-Xavier Carton <fx.carton91@gmail.com>
---
 drivers/hid/hid-gamecube-adapter.c | 36 +++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-gamecube-adapter.c b/drivers/hid/hid-gamecube-adapter.c
index b4022ff5b4b4..6a2fb908de3c 100644
--- a/drivers/hid/hid-gamecube-adapter.c
+++ b/drivers/hid/hid-gamecube-adapter.c
@@ -19,6 +19,30 @@
 #include <linux/usb.h>
 #include "usbhid/usbhid.h"
 
+static unsigned int left_stick_min = 0;
+module_param(left_stick_min, uint, 0644);
+MODULE_PARM_DESC(left_stick_min, "Minimum value for left stick.");
+
+static unsigned int left_stick_max = 255;
+module_param(left_stick_max, uint, 0644);
+MODULE_PARM_DESC(left_stick_max, "Maximum value for left stick.");
+
+static unsigned int right_stick_min = 0;
+module_param(right_stick_min, uint, 0644);
+MODULE_PARM_DESC(right_stick_min, "Minimum value for right stick (C stick).");
+
+static unsigned int right_stick_max = 255;
+module_param(right_stick_max, uint, 0644);
+MODULE_PARM_DESC(right_stick_max, "Maximum value for right stick (C stick).");
+
+static unsigned int shoulder_min = 0;
+module_param(shoulder_min, uint, 0644);
+MODULE_PARM_DESC(shoulder_min, "Minimum value for shoulders.");
+
+static unsigned int shoulder_max = 255;
+module_param(shoulder_max, uint, 0644);
+MODULE_PARM_DESC(shoulder_max, "Maximum value for shoulders.");
+
 enum gamecube_output {
 	GC_CMD_INIT = 0x13,
 	GC_CMD_RUMBLE = 0x11
@@ -136,10 +160,6 @@ static const unsigned int gamecube_buttons[] = {
 	BTN_DPAD_LEFT, BTN_DPAD_RIGHT, BTN_DPAD_DOWN, BTN_DPAD_UP
 };
 
-static const unsigned int gamecube_axes[] = {
-	ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_Z, ABS_RZ
-};
-
 static const char* gamecube_ctrl_name(enum gamecube_ctrl_flags flags)
 {
 	switch (flags & GC_TYPES) {
@@ -179,8 +199,12 @@ static int gamecube_ctrl_create(struct gamecube_ctrl *ctrl)
 
 	for (i = 0; i < ARRAY_SIZE(gamecube_buttons); i++)
 		input_set_capability(input, EV_KEY, gamecube_buttons[i]);
-	for (i = 0; i < ARRAY_SIZE(gamecube_axes); i++)
-		input_set_abs_params(input, gamecube_axes[i], 0, 255, 0, 0);
+	input_set_abs_params(input, ABS_X, left_stick_min, left_stick_max, 0, 0);
+	input_set_abs_params(input, ABS_Y, left_stick_min, left_stick_max, 0, 0);
+	input_set_abs_params(input, ABS_RX, right_stick_min, right_stick_max, 0, 0);
+	input_set_abs_params(input, ABS_RY, right_stick_min, right_stick_max, 0, 0);
+	input_set_abs_params(input, ABS_Z, shoulder_min, shoulder_max, 0, 0);
+	input_set_abs_params(input, ABS_RZ, shoulder_min, shoulder_max, 0, 0);
 #ifdef CONFIG_HID_GAMECUBE_ADAPTER_FF
 	input_set_capability(input, EV_FF, FF_RUMBLE);
 	if (input_ff_create_memless(input, NULL, gamecube_rumble_play))
-- 
2.26.2


  parent reply	other threads:[~2020-05-06  0:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  0:47 [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter François-Xavier Carton
2020-05-06  0:48 ` [PATCH 2/3] HID: gamecube-adapter: add rumble support François-Xavier Carton
2020-05-06  0:48 ` François-Xavier Carton [this message]
2020-05-09 23:50 ` [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter François-Xavier Carton
2020-05-10 12:45 ` Bastien Nocera
2020-05-11 14:09   ` Ethan Lee
2020-05-11 23:23     ` François-Xavier Carton
2020-05-12  0:22       ` Ethan Lee
2020-05-12  2:27         ` François-Xavier Carton

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=20200506004801.9478-3-fx.carton91@gmail.com \
    --to=fx.carton91@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).