diff mbox

[RFC,3/4] input: add a EV_SW event for ratchet switch

Message ID c48652786b1e139503834f67b1a5037ff677a174.1490481944.git.mchehab@s-opensource.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab March 25, 2017, 10:49 p.m. UTC
Some mouses have a switch on their wheel, allowing to switch
between ratchet or free wheel mode. Add support for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/linux/mod_devicetable.h        | 2 +-
 include/uapi/linux/input-event-codes.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Peter Hutterer March 27, 2017, 1:53 a.m. UTC | #1
On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:
> Some mouses have a switch on their wheel, allowing to switch
> between ratchet or free wheel mode. Add support for it.

I understand the want to support it because it's there but what do you
expect this to be used for?

tbh, I wouldn't know what to do with this information, short of displaying
some OSD to inform the user. Which is rather superfluous since the physical
change will feel obvious anyway.

A Documentation/input/event-codes.txt hunk would be welcomed here too
btw.

Cheers,
   Peter

> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 8a57f0b1242d..73534c591b40 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -292,7 +292,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
>  #define INPUT_DEVICE_ID_SND_MAX		0x07
>  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> +#define INPUT_DEVICE_ID_SW_MAX		0x1f
>  
>  #define INPUT_DEVICE_ID_MATCH_BUS	1
>  #define INPUT_DEVICE_ID_MATCH_VENDOR	2
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 23b2d377af59..a3eafd0527f1 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -782,7 +782,9 @@
>  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
>  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> -#define SW_MAX			0x0f
> +#define SW_RATCHET		0x10  /* set = ratchet mode,
> +					 unset: free wheel */
> +#define SW_MAX			0x1f
>  #define SW_CNT			(SW_MAX+1)
>  
>  /*
> -- 
> 2.9.3
> 
> 
--
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
Mauro Carvalho Chehab March 27, 2017, 12:27 p.m. UTC | #2
Em Mon, 27 Mar 2017 11:53:57 +1000
Peter Hutterer <peter.hutterer@who-t.net> escreveu:

> On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:
> > Some mouses have a switch on their wheel, allowing to switch
> > between ratchet or free wheel mode. Add support for it.  
> 
> I understand the want to support it because it's there but what do you
> expect this to be used for?
> 
> tbh, I wouldn't know what to do with this information, short of displaying
> some OSD to inform the user. Which is rather superfluous since the physical
> change will feel obvious anyway.

For this particular device, the main reason is because it is there :-)
As adding support for it is trivial, I don't see any reason why not
adding it.

Yet, applications could use it, in order to switch between a "discrete" 
mode, where one wheel position corresponds to one line of scroll, and
movements below a threshold would be ignored.


> 
> A Documentation/input/event-codes.txt hunk would be welcomed here too
> btw.

Sure. Will do on a next patch series, once we agree about the high
resolution wheel movements API.
> 
> Cheers,
>    Peter
> 
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> >  include/linux/mod_devicetable.h        | 2 +-
> >  include/uapi/linux/input-event-codes.h | 4 +++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > index 8a57f0b1242d..73534c591b40 100644
> > --- a/include/linux/mod_devicetable.h
> > +++ b/include/linux/mod_devicetable.h
> > @@ -292,7 +292,7 @@ struct pcmcia_device_id {
> >  #define INPUT_DEVICE_ID_LED_MAX		0x0f
> >  #define INPUT_DEVICE_ID_SND_MAX		0x07
> >  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> > -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> > +#define INPUT_DEVICE_ID_SW_MAX		0x1f
> >  
> >  #define INPUT_DEVICE_ID_MATCH_BUS	1
> >  #define INPUT_DEVICE_ID_MATCH_VENDOR	2
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index 23b2d377af59..a3eafd0527f1 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -782,7 +782,9 @@
> >  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
> >  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
> >  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> > -#define SW_MAX			0x0f
> > +#define SW_RATCHET		0x10  /* set = ratchet mode,
> > +					 unset: free wheel */
> > +#define SW_MAX			0x1f
> >  #define SW_CNT			(SW_MAX+1)
> >  
> >  /*
> > -- 
> > 2.9.3
> > 
> >   



Thanks,
Mauro
--
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
Peter Hutterer March 28, 2017, 12:25 a.m. UTC | #3
On Mon, Mar 27, 2017 at 09:27:31AM -0300, Mauro Carvalho Chehab wrote:
> Em Mon, 27 Mar 2017 11:53:57 +1000
> Peter Hutterer <peter.hutterer@who-t.net> escreveu:
> 
> > On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:
> > > Some mouses have a switch on their wheel, allowing to switch
> > > between ratchet or free wheel mode. Add support for it.  
> > 
> > I understand the want to support it because it's there but what do you
> > expect this to be used for?
> > 
> > tbh, I wouldn't know what to do with this information, short of displaying
> > some OSD to inform the user. Which is rather superfluous since the physical
> > change will feel obvious anyway.
> 
> For this particular device, the main reason is because it is there :-)
> As adding support for it is trivial, I don't see any reason why not
> adding it.
> 
> Yet, applications could use it, in order to switch between a "discrete" 
> mode, where one wheel position corresponds to one line of scroll, and
> movements below a threshold would be ignored.

fwiw, that would more likely be the  result of receiving a different event
code (hires-wheel), more so than a ratchet switch - at least on this device.

the mice I have here don't change the behaviour of the wheel, so the
granularity is the same before and after. But they also don't send events
for the state, so there's that :)

Cheers,
   Peter
> 
> 
> > 
> > A Documentation/input/event-codes.txt hunk would be welcomed here too
> > btw.
> 
> Sure. Will do on a next patch series, once we agree about the high
> resolution wheel movements API.
> > 
> > Cheers,
> >    Peter
> > 
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > > ---
> > >  include/linux/mod_devicetable.h        | 2 +-
> > >  include/uapi/linux/input-event-codes.h | 4 +++-
> > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > > index 8a57f0b1242d..73534c591b40 100644
> > > --- a/include/linux/mod_devicetable.h
> > > +++ b/include/linux/mod_devicetable.h
> > > @@ -292,7 +292,7 @@ struct pcmcia_device_id {
> > >  #define INPUT_DEVICE_ID_LED_MAX		0x0f
> > >  #define INPUT_DEVICE_ID_SND_MAX		0x07
> > >  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> > > -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> > > +#define INPUT_DEVICE_ID_SW_MAX		0x1f
> > >  
> > >  #define INPUT_DEVICE_ID_MATCH_BUS	1
> > >  #define INPUT_DEVICE_ID_MATCH_VENDOR	2
> > > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > > index 23b2d377af59..a3eafd0527f1 100644
> > > --- a/include/uapi/linux/input-event-codes.h
> > > +++ b/include/uapi/linux/input-event-codes.h
> > > @@ -782,7 +782,9 @@
> > >  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
> > >  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
> > >  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> > > -#define SW_MAX			0x0f
> > > +#define SW_RATCHET		0x10  /* set = ratchet mode,
> > > +					 unset: free wheel */
> > > +#define SW_MAX			0x1f
> > >  #define SW_CNT			(SW_MAX+1)
> > >  
> > >  /*
> > > -- 
> > > 2.9.3
> > > 
> > >   
> 
> 
> 
> Thanks,
> Mauro
--
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
Mauro Carvalho Chehab March 28, 2017, 9:36 a.m. UTC | #4
Em Tue, 28 Mar 2017 10:25:17 +1000
Peter Hutterer <peter.hutterer@who-t.net> escreveu:

> On Mon, Mar 27, 2017 at 09:27:31AM -0300, Mauro Carvalho Chehab wrote:
> > Em Mon, 27 Mar 2017 11:53:57 +1000
> > Peter Hutterer <peter.hutterer@who-t.net> escreveu:
> >   
> > > On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:  
> > > > Some mouses have a switch on their wheel, allowing to switch
> > > > between ratchet or free wheel mode. Add support for it.    
> > > 
> > > I understand the want to support it because it's there but what do you
> > > expect this to be used for?
> > > 
> > > tbh, I wouldn't know what to do with this information, short of displaying
> > > some OSD to inform the user. Which is rather superfluous since the physical
> > > change will feel obvious anyway.  
> > 
> > For this particular device, the main reason is because it is there :-)
> > As adding support for it is trivial, I don't see any reason why not
> > adding it.
> > 
> > Yet, applications could use it, in order to switch between a "discrete" 
> > mode, where one wheel position corresponds to one line of scroll, and
> > movements below a threshold would be ignored.  
> 
> fwiw, that would more likely be the  result of receiving a different event
> code (hires-wheel), more so than a ratchet switch - at least on this device.

Yeah, that would be another alternative.

> the mice I have here don't change the behaviour of the wheel, so the
> granularity is the same before and after. But they also don't send events
> for the state, so there's that :)

Another alternative would be that applications could be listening to
EV_SW SW_RATCHET event. When the switch changes to free wheel, it could
be enabling high-resolution mode.

Thanks,
Mauro
--
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
diff mbox

Patch

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 8a57f0b1242d..73534c591b40 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -292,7 +292,7 @@  struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_LED_MAX		0x0f
 #define INPUT_DEVICE_ID_SND_MAX		0x07
 #define INPUT_DEVICE_ID_FF_MAX		0x7f
-#define INPUT_DEVICE_ID_SW_MAX		0x0f
+#define INPUT_DEVICE_ID_SW_MAX		0x1f
 
 #define INPUT_DEVICE_ID_MATCH_BUS	1
 #define INPUT_DEVICE_ID_MATCH_VENDOR	2
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 23b2d377af59..a3eafd0527f1 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -782,7 +782,9 @@ 
 #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
 #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
-#define SW_MAX			0x0f
+#define SW_RATCHET		0x10  /* set = ratchet mode,
+					 unset: free wheel */
+#define SW_MAX			0x1f
 #define SW_CNT			(SW_MAX+1)
 
 /*