All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
@ 2021-02-25  4:10 Chris Ye
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Ye @ 2021-02-25  4:10 UTC (permalink / raw)
  To: Łukasz Patron ,
	Benjamin Valentin, Chris Ye, Lee Jones, Olivier Crête ,
	Sanjay Govind, Andrzej Pietrasiewicz
  Cc: linux-input, linux-kernel, trivial, kernel-team

Add "Share" button input capability and input event mapping for
Microsoft Xbox One controller.
Fixed Microsoft Xbox One controller share button not working under USB
connection.

Signed-off-by: Chris Ye <lzye@google.com>
---
 drivers/input/joystick/xpad.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 9f0d07dcbf06..08c3e93ccb2f 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
 	-1
 };
 
+static const signed short xpad_xboxone_btn[] = {
+	/* buttons for xbox one controller */
+	BTN_TL, BTN_TR,		/* Button LB/RB */
+	BTN_MODE,		/* The big X button */
+	KEY_RECORD,		/* The share button */
+	-1
+};
+
 static const signed short xpad_abs[] = {
 	ABS_X, ABS_Y,		/* left stick */
 	ABS_RX, ABS_RY,		/* right stick */
@@ -862,6 +870,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 	/* menu/view buttons */
 	input_report_key(dev, BTN_START,  data[4] & 0x04);
 	input_report_key(dev, BTN_SELECT, data[4] & 0x08);
+	input_report_key(dev, KEY_RECORD, data[22] & 0x01);
 
 	/* buttons A,B,X,Y */
 	input_report_key(dev, BTN_A,	data[4] & 0x10);
@@ -1668,10 +1677,13 @@ static int xpad_init_input(struct usb_xpad *xpad)
 		input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
 
 	/* set up model-specific ones */
-	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
-	    xpad->xtype == XTYPE_XBOXONE) {
+	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
 		for (i = 0; xpad360_btn[i] >= 0; i++)
 			input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
+	}  else if (xpad->xtype == XTYPE_XBOXONE) {
+		for (i = 0; xpad_xboxone_btn[i] >= 0; i++)
+			input_set_capability(input_dev, EV_KEY,
+						xpad_xboxone_btn[i]);
 	} else {
 		for (i = 0; xpad_btn[i] >= 0; i++)
 			input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
-- 
2.30.0.617.g56c4b15f3c-goog


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

* Re: [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
  2021-02-25  6:26     ` Dmitry Torokhov
@ 2021-02-28  1:34       ` Cameron Gutman
  0 siblings, 0 replies; 8+ messages in thread
From: Cameron Gutman @ 2021-02-28  1:34 UTC (permalink / raw)
  To: Dmitry Torokhov, Chris Ye
  Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team

On 2/25/21 12:26 AM, Dmitry Torokhov wrote:
> On Wed, Feb 24, 2021 at 08:44:37PM -0800, Chris Ye wrote:
>> Hi Dmitry,
>> The latest Xbox One X series has this button, I can add a new
>> XTYPE_XBOXONE_X and only apply the change to the new type.
> 
> Sounds good to me. Cameron, what do you think?
> 

I'm not sure if some wires got crossed, but I see v2 uses MAP_SHARE_BUTTON
rather than a new XTYPE. I'm fine with either.

>> The controller supports bluetooth and the HID usage for this button is
>> consumer 0xB2:
>> 0x05, 0x0C,        //   Usage Page (Consumer)
>> 0x0A, 0xB2, 0x00,  //   Usage (Record)
> 
> I see, thank you.
> 

Regards,
Cameron

>>
>> Thanks!
>> Chris
>>
>> On Wed, Feb 24, 2021 at 8:33 PM Dmitry Torokhov
>> <dmitry.torokhov@gmail.com> wrote:
>>>
>>> Hi Chris,
>>>
>>> On Thu, Feb 25, 2021 at 04:00:32AM +0000, Chris Ye wrote:
>>>> Add "Share" button input capability and input event mapping for
>>>> Microsoft Xbox One controller.
>>>> Fixed Microsoft Xbox One controller share button not working under USB
>>>> connection.
>>>>
>>>> Signed-off-by: Chris Ye <lzye@google.com>
>>>> ---
>>>>  drivers/input/joystick/xpad.c | 16 ++++++++++++++--
>>>>  1 file changed, 14 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
>>>> index 9f0d07dcbf06..08c3e93ccb2f 100644
>>>> --- a/drivers/input/joystick/xpad.c
>>>> +++ b/drivers/input/joystick/xpad.c
>>>> @@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
>>>>       -1
>>>>  };
>>>>
>>>> +static const signed short xpad_xboxone_btn[] = {
>>>> +     /* buttons for xbox one controller */
>>>> +     BTN_TL, BTN_TR,         /* Button LB/RB */
>>>> +     BTN_MODE,               /* The big X button */
>>>> +     KEY_RECORD,             /* The share button */
>>>
>>> If I understand this correctly, not all Xbox One controllers have this
>>> new key. Is it possible to determine if it is present and only set
>>> capability for controllers that actually have it?
>>>
>>> Also, I am unsure if KEY_RECORD is the best keycode for this. It might,
>>> but does your controller supports bluetooth? What HID usage code does it
>>> send for this key?
>>>
>>> Thanks.
>>>
>>> --
>>> Dmitry
> 


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

* Re: [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
  2021-02-25  4:44     ` Chris Ye
  (?)
@ 2021-02-25  6:26     ` Dmitry Torokhov
  2021-02-28  1:34       ` Cameron Gutman
  -1 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2021-02-25  6:26 UTC (permalink / raw)
  To: Chris Ye, Cameron Gutman
  Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team

On Wed, Feb 24, 2021 at 08:44:37PM -0800, Chris Ye wrote:
> Hi Dmitry,
> The latest Xbox One X series has this button, I can add a new
> XTYPE_XBOXONE_X and only apply the change to the new type.

Sounds good to me. Cameron, what do you think?

> The controller supports bluetooth and the HID usage for this button is
> consumer 0xB2:
> 0x05, 0x0C,        //   Usage Page (Consumer)
> 0x0A, 0xB2, 0x00,  //   Usage (Record)

I see, thank you.

> 
> Thanks!
> Chris
> 
> On Wed, Feb 24, 2021 at 8:33 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > Hi Chris,
> >
> > On Thu, Feb 25, 2021 at 04:00:32AM +0000, Chris Ye wrote:
> > > Add "Share" button input capability and input event mapping for
> > > Microsoft Xbox One controller.
> > > Fixed Microsoft Xbox One controller share button not working under USB
> > > connection.
> > >
> > > Signed-off-by: Chris Ye <lzye@google.com>
> > > ---
> > >  drivers/input/joystick/xpad.c | 16 ++++++++++++++--
> > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> > > index 9f0d07dcbf06..08c3e93ccb2f 100644
> > > --- a/drivers/input/joystick/xpad.c
> > > +++ b/drivers/input/joystick/xpad.c
> > > @@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
> > >       -1
> > >  };
> > >
> > > +static const signed short xpad_xboxone_btn[] = {
> > > +     /* buttons for xbox one controller */
> > > +     BTN_TL, BTN_TR,         /* Button LB/RB */
> > > +     BTN_MODE,               /* The big X button */
> > > +     KEY_RECORD,             /* The share button */
> >
> > If I understand this correctly, not all Xbox One controllers have this
> > new key. Is it possible to determine if it is present and only set
> > capability for controllers that actually have it?
> >
> > Also, I am unsure if KEY_RECORD is the best keycode for this. It might,
> > but does your controller supports bluetooth? What HID usage code does it
> > send for this key?
> >
> > Thanks.
> >
> > --
> > Dmitry

-- 
Dmitry

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

* Re: [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
  2021-02-25  4:32 ` Dmitry Torokhov
@ 2021-02-25  4:44     ` Chris Ye
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Ye @ 2021-02-25  4:44 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team

Hi Dmitry,
The latest Xbox One X series has this button, I can add a new
XTYPE_XBOXONE_X and only apply the change to the new type.
The controller supports bluetooth and the HID usage for this button is
consumer 0xB2:
0x05, 0x0C,        //   Usage Page (Consumer)
0x0A, 0xB2, 0x00,  //   Usage (Record)

Thanks!
Chris

On Wed, Feb 24, 2021 at 8:33 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> Hi Chris,
>
> On Thu, Feb 25, 2021 at 04:00:32AM +0000, Chris Ye wrote:
> > Add "Share" button input capability and input event mapping for
> > Microsoft Xbox One controller.
> > Fixed Microsoft Xbox One controller share button not working under USB
> > connection.
> >
> > Signed-off-by: Chris Ye <lzye@google.com>
> > ---
> >  drivers/input/joystick/xpad.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> > index 9f0d07dcbf06..08c3e93ccb2f 100644
> > --- a/drivers/input/joystick/xpad.c
> > +++ b/drivers/input/joystick/xpad.c
> > @@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
> >       -1
> >  };
> >
> > +static const signed short xpad_xboxone_btn[] = {
> > +     /* buttons for xbox one controller */
> > +     BTN_TL, BTN_TR,         /* Button LB/RB */
> > +     BTN_MODE,               /* The big X button */
> > +     KEY_RECORD,             /* The share button */
>
> If I understand this correctly, not all Xbox One controllers have this
> new key. Is it possible to determine if it is present and only set
> capability for controllers that actually have it?
>
> Also, I am unsure if KEY_RECORD is the best keycode for this. It might,
> but does your controller supports bluetooth? What HID usage code does it
> send for this key?
>
> Thanks.
>
> --
> Dmitry

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

* Re: [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
@ 2021-02-25  4:44     ` Chris Ye
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Ye @ 2021-02-25  4:44 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team

Hi Dmitry,
The latest Xbox One X series has this button, I can add a new
XTYPE_XBOXONE_X and only apply the change to the new type.
The controller supports bluetooth and the HID usage for this button is
consumer 0xB2:
0x05, 0x0C,        //   Usage Page (Consumer)
0x0A, 0xB2, 0x00,  //   Usage (Record)

Thanks!
Chris

On Wed, Feb 24, 2021 at 8:33 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> Hi Chris,
>
> On Thu, Feb 25, 2021 at 04:00:32AM +0000, Chris Ye wrote:
> > Add "Share" button input capability and input event mapping for
> > Microsoft Xbox One controller.
> > Fixed Microsoft Xbox One controller share button not working under USB
> > connection.
> >
> > Signed-off-by: Chris Ye <lzye@google.com>
> > ---
> >  drivers/input/joystick/xpad.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> > index 9f0d07dcbf06..08c3e93ccb2f 100644
> > --- a/drivers/input/joystick/xpad.c
> > +++ b/drivers/input/joystick/xpad.c
> > @@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
> >       -1
> >  };
> >
> > +static const signed short xpad_xboxone_btn[] = {
> > +     /* buttons for xbox one controller */
> > +     BTN_TL, BTN_TR,         /* Button LB/RB */
> > +     BTN_MODE,               /* The big X button */
> > +     KEY_RECORD,             /* The share button */
>
> If I understand this correctly, not all Xbox One controllers have this
> new key. Is it possible to determine if it is present and only set
> capability for controllers that actually have it?
>
> Also, I am unsure if KEY_RECORD is the best keycode for this. It might,
> but does your controller supports bluetooth? What HID usage code does it
> send for this key?
>
> Thanks.
>
> --
> Dmitry


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

* Re: [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
  2021-02-25  4:00 ` Chris Ye
  (?)
@ 2021-02-25  4:32 ` Dmitry Torokhov
  2021-02-25  4:44     ` Chris Ye
  -1 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2021-02-25  4:32 UTC (permalink / raw)
  To: Chris Ye; +Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team

Hi Chris,

On Thu, Feb 25, 2021 at 04:00:32AM +0000, Chris Ye wrote:
> Add "Share" button input capability and input event mapping for
> Microsoft Xbox One controller.
> Fixed Microsoft Xbox One controller share button not working under USB
> connection.
> 
> Signed-off-by: Chris Ye <lzye@google.com>
> ---
>  drivers/input/joystick/xpad.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 9f0d07dcbf06..08c3e93ccb2f 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
>  	-1
>  };
>  
> +static const signed short xpad_xboxone_btn[] = {
> +	/* buttons for xbox one controller */
> +	BTN_TL, BTN_TR,		/* Button LB/RB */
> +	BTN_MODE,		/* The big X button */
> +	KEY_RECORD,		/* The share button */

If I understand this correctly, not all Xbox One controllers have this
new key. Is it possible to determine if it is present and only set
capability for controllers that actually have it?

Also, I am unsure if KEY_RECORD is the best keycode for this. It might,
but does your controller supports bluetooth? What HID usage code does it
send for this key?

Thanks.

-- 
Dmitry

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

* [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
@ 2021-02-25  4:00 ` Chris Ye
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Ye @ 2021-02-25  4:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team, Chris Ye

Add "Share" button input capability and input event mapping for
Microsoft Xbox One controller.
Fixed Microsoft Xbox One controller share button not working under USB
connection.

Signed-off-by: Chris Ye <lzye@google.com>
---
 drivers/input/joystick/xpad.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 9f0d07dcbf06..08c3e93ccb2f 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
 	-1
 };
 
+static const signed short xpad_xboxone_btn[] = {
+	/* buttons for xbox one controller */
+	BTN_TL, BTN_TR,		/* Button LB/RB */
+	BTN_MODE,		/* The big X button */
+	KEY_RECORD,		/* The share button */
+	-1
+};
+
 static const signed short xpad_abs[] = {
 	ABS_X, ABS_Y,		/* left stick */
 	ABS_RX, ABS_RY,		/* right stick */
@@ -862,6 +870,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 	/* menu/view buttons */
 	input_report_key(dev, BTN_START,  data[4] & 0x04);
 	input_report_key(dev, BTN_SELECT, data[4] & 0x08);
+	input_report_key(dev, KEY_RECORD, data[22] & 0x01);
 
 	/* buttons A,B,X,Y */
 	input_report_key(dev, BTN_A,	data[4] & 0x10);
@@ -1668,10 +1677,13 @@ static int xpad_init_input(struct usb_xpad *xpad)
 		input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
 
 	/* set up model-specific ones */
-	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
-	    xpad->xtype == XTYPE_XBOXONE) {
+	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
 		for (i = 0; xpad360_btn[i] >= 0; i++)
 			input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
+	}  else if (xpad->xtype == XTYPE_XBOXONE) {
+		for (i = 0; xpad_xboxone_btn[i] >= 0; i++)
+			input_set_capability(input_dev, EV_KEY,
+						xpad_xboxone_btn[i]);
 	} else {
 		for (i = 0; xpad_btn[i] >= 0; i++)
 			input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
-- 
2.30.0.617.g56c4b15f3c-goog


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

* [PATCH] Input: Add "Share" button to Microsoft Xbox One controller.
@ 2021-02-25  4:00 ` Chris Ye
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Ye @ 2021-02-25  4:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Chris Ye, linux-mm, linux-kernel, trivial, kernel-team, Chris Ye

Add "Share" button input capability and input event mapping for
Microsoft Xbox One controller.
Fixed Microsoft Xbox One controller share button not working under USB
connection.

Signed-off-by: Chris Ye <lzye@google.com>
---
 drivers/input/joystick/xpad.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 9f0d07dcbf06..08c3e93ccb2f 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -368,6 +368,14 @@ static const signed short xpad360_btn[] = {  /* buttons for x360 controller */
 	-1
 };
 
+static const signed short xpad_xboxone_btn[] = {
+	/* buttons for xbox one controller */
+	BTN_TL, BTN_TR,		/* Button LB/RB */
+	BTN_MODE,		/* The big X button */
+	KEY_RECORD,		/* The share button */
+	-1
+};
+
 static const signed short xpad_abs[] = {
 	ABS_X, ABS_Y,		/* left stick */
 	ABS_RX, ABS_RY,		/* right stick */
@@ -862,6 +870,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 	/* menu/view buttons */
 	input_report_key(dev, BTN_START,  data[4] & 0x04);
 	input_report_key(dev, BTN_SELECT, data[4] & 0x08);
+	input_report_key(dev, KEY_RECORD, data[22] & 0x01);
 
 	/* buttons A,B,X,Y */
 	input_report_key(dev, BTN_A,	data[4] & 0x10);
@@ -1668,10 +1677,13 @@ static int xpad_init_input(struct usb_xpad *xpad)
 		input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
 
 	/* set up model-specific ones */
-	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
-	    xpad->xtype == XTYPE_XBOXONE) {
+	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
 		for (i = 0; xpad360_btn[i] >= 0; i++)
 			input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
+	}  else if (xpad->xtype == XTYPE_XBOXONE) {
+		for (i = 0; xpad_xboxone_btn[i] >= 0; i++)
+			input_set_capability(input_dev, EV_KEY,
+						xpad_xboxone_btn[i]);
 	} else {
 		for (i = 0; xpad_btn[i] >= 0; i++)
 			input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
-- 
2.30.0.617.g56c4b15f3c-goog



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

end of thread, other threads:[~2021-02-28  1:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25  4:10 [PATCH] Input: Add "Share" button to Microsoft Xbox One controller Chris Ye
  -- strict thread matches above, loose matches on Subject: below --
2021-02-25  4:00 Chris Ye
2021-02-25  4:00 ` Chris Ye
2021-02-25  4:32 ` Dmitry Torokhov
2021-02-25  4:44   ` Chris Ye
2021-02-25  4:44     ` Chris Ye
2021-02-25  6:26     ` Dmitry Torokhov
2021-02-28  1:34       ` Cameron Gutman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.