linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* xpad - Rename buttons to avoid conflict with mouse input
@ 2008-04-15 10:13 Michael Gruber
  2008-04-16 16:49 ` Anssi Hannula
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Gruber @ 2008-04-15 10:13 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input

From: Michael Gruber <lists.mg@googlemail.com>

BTN_LEFT, BTN_RIGHT and BTN_BACK are listed as mouse buttons according to
input.h. Rename them to make sure they do not interfere with mouse input.

Signed-off-by: Michael Gruber <lists.mg@googlemail.com>

---

When I set up the driver to use MAP_DPAD_TO_BUTTONS the controller starts
acting as mouse. Touching the d-pad issues left and right mouse click events
and the back button acts like one of my other mouse buttons.

 drivers/input/joystick/xpad.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

--- a/drivers/input/joystick/xpad.c	2008-04-15 10:41:42.000000000 +0200
+++ b/drivers/input/joystick/xpad.c	2008-04-15 10:49:41.000000000 +0200
@@ -150,7 +150,7 @@ static const struct xpad_device {
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
-	BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR,	/* start/back/sticks */
+	BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR,	/* start/back/sticks */
 	-1						/* terminating entry */
 };

@@ -162,9 +162,9 @@ static const signed short xpad_btn[] = {

 /* only used if MAP_DPAD_TO_BUTTONS */
 static const signed short xpad_btn_pad[] = {
-	BTN_LEFT, BTN_RIGHT,		/* d-pad left, right */
-	BTN_0, BTN_1,			/* d-pad up, down (XXX names??) */
-	-1				/* terminating entry */
+	BTN_0, BTN_1,		/* d-pad up, down */
+	BTN_2, BTN_3,		/* d-pad left, right */
+	-1			/* terminating entry */
 };

 static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
@@ -279,15 +279,15 @@ static void xpad_process_packet(struct u
 		input_report_abs(dev, ABS_HAT0Y,
 				 !!(data[2] & 0x02) - !!(data[2] & 0x01));
 	} else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
-		input_report_key(dev, BTN_LEFT,  data[2] & 0x04);
-		input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
 		input_report_key(dev, BTN_0,     data[2] & 0x01); /* up */
 		input_report_key(dev, BTN_1,     data[2] & 0x02); /* down */
+		input_report_key(dev, BTN_2,     data[2] & 0x04); /* left */
+		input_report_key(dev, BTN_3,     data[2] & 0x08); /* right */
 	}

 	/* start/back buttons and stick press left/right */
 	input_report_key(dev, BTN_START,  data[2] & 0x10);
-	input_report_key(dev, BTN_BACK,   data[2] & 0x20);
+	input_report_key(dev, BTN_SELECT, data[2] & 0x20);
 	input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
 	input_report_key(dev, BTN_THUMBR, data[2] & 0x80);

@@ -327,15 +327,15 @@ static void xpad360_process_packet(struc
 				 !!(data[2] & 0x02) - !!(data[2] & 0x01));
 	} else if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) {
 		/* dpad as buttons (right, left, down, up) */
-		input_report_key(dev, BTN_LEFT, data[2] & 0x04);
-		input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
 		input_report_key(dev, BTN_0, data[2] & 0x01);	/* up */
 		input_report_key(dev, BTN_1, data[2] & 0x02);	/* down */
+		input_report_key(dev, BTN_2, data[2] & 0x04);	/* left */
+		input_report_key(dev, BTN_3, data[2] & 0x08);	/* right */
 	}

 	/* start/back buttons */
 	input_report_key(dev, BTN_START,  data[2] & 0x10);
-	input_report_key(dev, BTN_BACK,   data[2] & 0x20);
+	input_report_key(dev, BTN_SELECT, data[2] & 0x20);

 	/* stick press left/right */
 	input_report_key(dev, BTN_THUMBL, data[2] & 0x40);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: xpad - Rename buttons to avoid conflict with mouse input
  2008-04-15 10:13 xpad - Rename buttons to avoid conflict with mouse input Michael Gruber
@ 2008-04-16 16:49 ` Anssi Hannula
  2008-04-16 18:34   ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Anssi Hannula @ 2008-04-16 16:49 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: Michael Gruber, linux-input

Michael Gruber wrote:
> From: Michael Gruber <lists.mg@googlemail.com>
> 
> BTN_LEFT, BTN_RIGHT and BTN_BACK are listed as mouse buttons according to
> input.h. Rename them to make sure they do not interfere with mouse input.
> 
> Signed-off-by: Michael Gruber <lists.mg@googlemail.com>
> 
> ---
> 
> When I set up the driver to use MAP_DPAD_TO_BUTTONS the controller starts
> acting as mouse. Touching the d-pad issues left and right mouse click events
> and the back button acts like one of my other mouse buttons.

Patch seems correct to me.

Acked-by: Anssi Hannula <anssi.hannula@gmail.com>

>  drivers/input/joystick/xpad.c |   20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> --- a/drivers/input/joystick/xpad.c	2008-04-15 10:41:42.000000000 +0200
> +++ b/drivers/input/joystick/xpad.c	2008-04-15 10:49:41.000000000 +0200
> @@ -150,7 +150,7 @@ static const struct xpad_device {
>  /* buttons shared with xbox and xbox360 */
>  static const signed short xpad_common_btn[] = {
>  	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
> -	BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR,	/* start/back/sticks */
> +	BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR,	/* start/back/sticks */
>  	-1						/* terminating entry */
>  };
> 
> @@ -162,9 +162,9 @@ static const signed short xpad_btn[] = {
> 
>  /* only used if MAP_DPAD_TO_BUTTONS */
>  static const signed short xpad_btn_pad[] = {
> -	BTN_LEFT, BTN_RIGHT,		/* d-pad left, right */
> -	BTN_0, BTN_1,			/* d-pad up, down (XXX names??) */
> -	-1				/* terminating entry */
> +	BTN_0, BTN_1,		/* d-pad up, down */
> +	BTN_2, BTN_3,		/* d-pad left, right */
> +	-1			/* terminating entry */
>  };
> 
>  static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
> @@ -279,15 +279,15 @@ static void xpad_process_packet(struct u
>  		input_report_abs(dev, ABS_HAT0Y,
>  				 !!(data[2] & 0x02) - !!(data[2] & 0x01));
>  	} else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
> -		input_report_key(dev, BTN_LEFT,  data[2] & 0x04);
> -		input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
>  		input_report_key(dev, BTN_0,     data[2] & 0x01); /* up */
>  		input_report_key(dev, BTN_1,     data[2] & 0x02); /* down */
> +		input_report_key(dev, BTN_2,     data[2] & 0x04); /* left */
> +		input_report_key(dev, BTN_3,     data[2] & 0x08); /* right */
>  	}
> 
>  	/* start/back buttons and stick press left/right */
>  	input_report_key(dev, BTN_START,  data[2] & 0x10);
> -	input_report_key(dev, BTN_BACK,   data[2] & 0x20);
> +	input_report_key(dev, BTN_SELECT, data[2] & 0x20);
>  	input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
>  	input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
> 
> @@ -327,15 +327,15 @@ static void xpad360_process_packet(struc
>  				 !!(data[2] & 0x02) - !!(data[2] & 0x01));
>  	} else if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) {
>  		/* dpad as buttons (right, left, down, up) */
> -		input_report_key(dev, BTN_LEFT, data[2] & 0x04);
> -		input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
>  		input_report_key(dev, BTN_0, data[2] & 0x01);	/* up */
>  		input_report_key(dev, BTN_1, data[2] & 0x02);	/* down */
> +		input_report_key(dev, BTN_2, data[2] & 0x04);	/* left */
> +		input_report_key(dev, BTN_3, data[2] & 0x08);	/* right */
>  	}
> 
>  	/* start/back buttons */
>  	input_report_key(dev, BTN_START,  data[2] & 0x10);
> -	input_report_key(dev, BTN_BACK,   data[2] & 0x20);
> +	input_report_key(dev, BTN_SELECT, data[2] & 0x20);
> 
>  	/* stick press left/right */
>  	input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Anssi Hannula

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: xpad - Rename buttons to avoid conflict with mouse input
  2008-04-16 16:49 ` Anssi Hannula
@ 2008-04-16 18:34   ` Dmitry Torokhov
  2008-04-16 18:56     ` Anssi Hannula
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2008-04-16 18:34 UTC (permalink / raw)
  To: Anssi Hannula; +Cc: Michael Gruber, linux-input

On Wed, Apr 16, 2008 at 07:49:33PM +0300, Anssi Hannula wrote:
> Michael Gruber wrote:
> > From: Michael Gruber <lists.mg@googlemail.com>
> > 
> > BTN_LEFT, BTN_RIGHT and BTN_BACK are listed as mouse buttons according to
> > input.h. Rename them to make sure they do not interfere with mouse input.
> > 
> > Signed-off-by: Michael Gruber <lists.mg@googlemail.com>
> > 
> > ---
> > 
> > When I set up the driver to use MAP_DPAD_TO_BUTTONS the controller starts
> > acting as mouse. Touching the d-pad issues left and right mouse click events
> > and the back button acts like one of my other mouse buttons.
> 
> Patch seems correct to me.
> 
> Acked-by: Anssi Hannula <anssi.hannula@gmail.com>
> 

The original author of d-pad mode did that so the pad withh work
with stepmania. If left/right/0/1 are the defaults used there
we might break existing setups... Do you know of other applications
using dance pads?


-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: xpad - Rename buttons to avoid conflict with mouse input
  2008-04-16 18:34   ` Dmitry Torokhov
@ 2008-04-16 18:56     ` Anssi Hannula
  0 siblings, 0 replies; 4+ messages in thread
From: Anssi Hannula @ 2008-04-16 18:56 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Michael Gruber, linux-input

Dmitry Torokhov wrote:
> On Wed, Apr 16, 2008 at 07:49:33PM +0300, Anssi Hannula wrote:
>> Michael Gruber wrote:
>>> From: Michael Gruber <lists.mg@googlemail.com>
>>>
>>> BTN_LEFT, BTN_RIGHT and BTN_BACK are listed as mouse buttons according to
>>> input.h. Rename them to make sure they do not interfere with mouse input.
>>>
>>> Signed-off-by: Michael Gruber <lists.mg@googlemail.com>
>>>
>>> ---
>>>
>>> When I set up the driver to use MAP_DPAD_TO_BUTTONS the controller starts
>>> acting as mouse. Touching the d-pad issues left and right mouse click events
>>> and the back button acts like one of my other mouse buttons.
>> Patch seems correct to me.
>>
>> Acked-by: Anssi Hannula <anssi.hannula@gmail.com>
>>
> 
> The original author of d-pad mode did that so the pad withh work
> with stepmania. If left/right/0/1 are the defaults used there
> we might break existing setups...

With a quick test there seem to be no default mappings for game
controllers, but they are manually defined.

IMO having to redefine keys after a major kernel upgrade is ok, and
certainly a lesser trouble than having dancepad directionals act as
mouse buttons.

> Do you know of other applications
> using dance pads?

Nope.

-- 
Anssi Hannula

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-16 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 10:13 xpad - Rename buttons to avoid conflict with mouse input Michael Gruber
2008-04-16 16:49 ` Anssi Hannula
2008-04-16 18:34   ` Dmitry Torokhov
2008-04-16 18:56     ` Anssi Hannula

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).