diff mbox

[v3,1/4] input: add an EV_REL event for high-res vertical wheel

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

Commit Message

Mauro Carvalho Chehab April 7, 2017, 11:31 a.m. UTC
As some devices can produce either low-res or high-res
vertical wheel EV_REL events, add a new event to allow
userspace to distinguish between them.

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

Comments

Benjamin Tissoires April 7, 2017, 12:17 p.m. UTC | #1
Hi Mauro,

On Apr 07 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> As some devices can produce either low-res or high-res
> vertical wheel EV_REL events, add a new event to allow
> userspace to distinguish between them.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  Documentation/input/event-codes.rst    | 16 +++++++++++++---
>  include/uapi/linux/input-event-codes.h |  1 +
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
> index 92db50954169..0c8591d39bc6 100644
> --- a/Documentation/input/event-codes.rst
> +++ b/Documentation/input/event-codes.rst
> @@ -185,10 +185,20 @@ instead of EV_REL codes.
>  
>  A few EV_REL codes have special meanings:
>  
> -* REL_WHEEL, REL_HWHEEL:
> +* REL_WHEEL:
>  
> -  - These codes are used for vertical and horizontal scroll wheels,
> -    respectively.
> +  - These codes are used for vertical scroll wheels.
> +
> +  - REL_WHEEL is for normal wheel operational mode, e. g. low-resolution
> +    (line-based) scroll.
> +
> +  - REL_HIRES_WHEEL should be used when the wheel has two resolutions and it
> +    is in high-resolution mode, e. g. the same angular movement that would
> +    produce a single REL_WHEEL will produce multiple REL_HIRES_WHEEL events.
> +
> +* REL_HWHEEL:
> +
> +  - This code is used for horizontal scroll wheels.
>  
>  EV_ABS
>  ------
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 3af60ee69053..23b2d377af59 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -703,6 +703,7 @@
>  #define REL_DIAL		0x07
>  #define REL_WHEEL		0x08
>  #define REL_MISC		0x09
> +#define REL_HIRES_WHEEL		0x0a

There is one issue here. The HID input layer has a tendency to map
usages to REL_MISC +1, +2, +3, etc... When it doesn't know how to map an
usage, the core layer maps it to the next one.

I am not aware of devices exposing such REL axes, but I wouldn't be
surprised if the issue will not raise at some point.

We already had an issue with ABS events where ABS_MISC are conflicting
with ABS_MT_SLOTS. Luckily, we have a little empty space between
ABS_MISC and ABS_MT_SLOT, which allows userspace to detect such issues.

Could you give the define a bigger number (and maybe reserve a couple of
REL_MISC-n) to make sure that we do not end up with joysticks exporting
REL_HIRES_WHEEL?

I'll try the rest of the series on the MX Master today.

Cheers,
Benjamin

>  #define REL_MAX			0x0f
>  #define REL_CNT			(REL_MAX+1)
>  
--
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 April 7, 2017, 1:32 p.m. UTC | #2
Em Fri, 7 Apr 2017 14:17:51 +0200
Benjamin Tissoires <benjamin.tissoires@redhat.com> escreveu:

> Hi Mauro,
> 
> On Apr 07 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> > As some devices can produce either low-res or high-res
> > vertical wheel EV_REL events, add a new event to allow
> > userspace to distinguish between them.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> >  Documentation/input/event-codes.rst    | 16 +++++++++++++---
> >  include/uapi/linux/input-event-codes.h |  1 +
> >  2 files changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
> > index 92db50954169..0c8591d39bc6 100644
> > --- a/Documentation/input/event-codes.rst
> > +++ b/Documentation/input/event-codes.rst
> > @@ -185,10 +185,20 @@ instead of EV_REL codes.
> >  
> >  A few EV_REL codes have special meanings:
> >  
> > -* REL_WHEEL, REL_HWHEEL:
> > +* REL_WHEEL:
> >  
> > -  - These codes are used for vertical and horizontal scroll wheels,
> > -    respectively.
> > +  - These codes are used for vertical scroll wheels.
> > +
> > +  - REL_WHEEL is for normal wheel operational mode, e. g. low-resolution
> > +    (line-based) scroll.
> > +
> > +  - REL_HIRES_WHEEL should be used when the wheel has two resolutions and it
> > +    is in high-resolution mode, e. g. the same angular movement that would
> > +    produce a single REL_WHEEL will produce multiple REL_HIRES_WHEEL events.
> > +
> > +* REL_HWHEEL:
> > +
> > +  - This code is used for horizontal scroll wheels.
> >  
> >  EV_ABS
> >  ------
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index 3af60ee69053..23b2d377af59 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -703,6 +703,7 @@
> >  #define REL_DIAL		0x07
> >  #define REL_WHEEL		0x08
> >  #define REL_MISC		0x09
> > +#define REL_HIRES_WHEEL		0x0a  
> 
> There is one issue here. The HID input layer has a tendency to map
> usages to REL_MISC +1, +2, +3, etc... When it doesn't know how to map an
> usage, the core layer maps it to the next one.
> 
> I am not aware of devices exposing such REL axes, but I wouldn't be
> surprised if the issue will not raise at some point.
> 
> We already had an issue with ABS events where ABS_MISC are conflicting
> with ABS_MT_SLOTS. Luckily, we have a little empty space between
> ABS_MISC and ABS_MT_SLOT, which allows userspace to detect such issues.
> 
> Could you give the define a bigger number (and maybe reserve a couple of
> REL_MISC-n) to make sure that we do not end up with joysticks exporting
> REL_HIRES_WHEEL?

Sure. How many REL_MISC-n should be reserved?

> I'll try the rest of the series on the MX Master today.

It would be great if you could test it!

Regards,
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
Benjamin Tissoires April 7, 2017, 3:10 p.m. UTC | #3
On Apr 07 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> Em Fri, 7 Apr 2017 14:17:51 +0200
> Benjamin Tissoires <benjamin.tissoires@redhat.com> escreveu:
> 
> > Hi Mauro,
> > 
> > On Apr 07 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> > > As some devices can produce either low-res or high-res
> > > vertical wheel EV_REL events, add a new event to allow
> > > userspace to distinguish between them.
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > > ---
> > >  Documentation/input/event-codes.rst    | 16 +++++++++++++---
> > >  include/uapi/linux/input-event-codes.h |  1 +
> > >  2 files changed, 14 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
> > > index 92db50954169..0c8591d39bc6 100644
> > > --- a/Documentation/input/event-codes.rst
> > > +++ b/Documentation/input/event-codes.rst
> > > @@ -185,10 +185,20 @@ instead of EV_REL codes.
> > >  
> > >  A few EV_REL codes have special meanings:
> > >  
> > > -* REL_WHEEL, REL_HWHEEL:
> > > +* REL_WHEEL:
> > >  
> > > -  - These codes are used for vertical and horizontal scroll wheels,
> > > -    respectively.
> > > +  - These codes are used for vertical scroll wheels.
> > > +
> > > +  - REL_WHEEL is for normal wheel operational mode, e. g. low-resolution
> > > +    (line-based) scroll.
> > > +
> > > +  - REL_HIRES_WHEEL should be used when the wheel has two resolutions and it
> > > +    is in high-resolution mode, e. g. the same angular movement that would
> > > +    produce a single REL_WHEEL will produce multiple REL_HIRES_WHEEL events.
> > > +
> > > +* REL_HWHEEL:
> > > +
> > > +  - This code is used for horizontal scroll wheels.
> > >  
> > >  EV_ABS
> > >  ------
> > > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > > index 3af60ee69053..23b2d377af59 100644
> > > --- a/include/uapi/linux/input-event-codes.h
> > > +++ b/include/uapi/linux/input-event-codes.h
> > > @@ -703,6 +703,7 @@
> > >  #define REL_DIAL		0x07
> > >  #define REL_WHEEL		0x08
> > >  #define REL_MISC		0x09
> > > +#define REL_HIRES_WHEEL		0x0a  
> > 
> > There is one issue here. The HID input layer has a tendency to map
> > usages to REL_MISC +1, +2, +3, etc... When it doesn't know how to map an
> > usage, the core layer maps it to the next one.
> > 
> > I am not aware of devices exposing such REL axes, but I wouldn't be
> > surprised if the issue will not raise at some point.
> > 
> > We already had an issue with ABS events where ABS_MISC are conflicting
> > with ABS_MT_SLOTS. Luckily, we have a little empty space between
> > ABS_MISC and ABS_MT_SLOT, which allows userspace to detect such issues.
> > 
> > Could you give the define a bigger number (and maybe reserve a couple of
> > REL_MISC-n) to make sure that we do not end up with joysticks exporting
> > REL_HIRES_WHEEL?
> 
> Sure. How many REL_MISC-n should be reserved?

Not sure. As I mentioned, I haven' t seen such device myself, but maybe
we should reserve the rest of the 0x0n range for those (0x0a-0x0f). This
would force to bump REL_MAX, but I don't think this is an issue besides
recompiling libevdev and others.

> 
> > I'll try the rest of the series on the MX Master today.
> 
> It would be great if you could test it!

I found some issues, I'll report in the other patches.

Cheers,
Benjamin

> 
> Regards,
> 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 April 11, 2017, 10:17 a.m. UTC | #4
Em Fri, 7 Apr 2017 17:10:27 +0200
Benjamin Tissoires <benjamin.tissoires@redhat.com> escreveu:

> On Apr 07 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> > Em Fri, 7 Apr 2017 14:17:51 +0200
> > Benjamin Tissoires <benjamin.tissoires@redhat.com> escreveu:
> >   
> > > Hi Mauro,
> > > 
> > > On Apr 07 2017 or thereabouts, Mauro Carvalho Chehab wrote:  
> > > > As some devices can produce either low-res or high-res
> > > > vertical wheel EV_REL events, add a new event to allow
> > > > userspace to distinguish between them.
> > > > 
> > > > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > > > ---
> > > >  Documentation/input/event-codes.rst    | 16 +++++++++++++---
> > > >  include/uapi/linux/input-event-codes.h |  1 +
> > > >  2 files changed, 14 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
> > > > index 92db50954169..0c8591d39bc6 100644
> > > > --- a/Documentation/input/event-codes.rst
> > > > +++ b/Documentation/input/event-codes.rst
> > > > @@ -185,10 +185,20 @@ instead of EV_REL codes.
> > > >  
> > > >  A few EV_REL codes have special meanings:
> > > >  
> > > > -* REL_WHEEL, REL_HWHEEL:
> > > > +* REL_WHEEL:
> > > >  
> > > > -  - These codes are used for vertical and horizontal scroll wheels,
> > > > -    respectively.
> > > > +  - These codes are used for vertical scroll wheels.
> > > > +
> > > > +  - REL_WHEEL is for normal wheel operational mode, e. g. low-resolution
> > > > +    (line-based) scroll.
> > > > +
> > > > +  - REL_HIRES_WHEEL should be used when the wheel has two resolutions and it
> > > > +    is in high-resolution mode, e. g. the same angular movement that would
> > > > +    produce a single REL_WHEEL will produce multiple REL_HIRES_WHEEL events.
> > > > +
> > > > +* REL_HWHEEL:
> > > > +
> > > > +  - This code is used for horizontal scroll wheels.
> > > >  
> > > >  EV_ABS
> > > >  ------
> > > > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > > > index 3af60ee69053..23b2d377af59 100644
> > > > --- a/include/uapi/linux/input-event-codes.h
> > > > +++ b/include/uapi/linux/input-event-codes.h
> > > > @@ -703,6 +703,7 @@
> > > >  #define REL_DIAL		0x07
> > > >  #define REL_WHEEL		0x08
> > > >  #define REL_MISC		0x09
> > > > +#define REL_HIRES_WHEEL		0x0a    
> > > 
> > > There is one issue here. The HID input layer has a tendency to map
> > > usages to REL_MISC +1, +2, +3, etc... When it doesn't know how to map an
> > > usage, the core layer maps it to the next one.
> > > 
> > > I am not aware of devices exposing such REL axes, but I wouldn't be
> > > surprised if the issue will not raise at some point.
> > > 
> > > We already had an issue with ABS events where ABS_MISC are conflicting
> > > with ABS_MT_SLOTS. Luckily, we have a little empty space between
> > > ABS_MISC and ABS_MT_SLOT, which allows userspace to detect such issues.
> > > 
> > > Could you give the define a bigger number (and maybe reserve a couple of
> > > REL_MISC-n) to make sure that we do not end up with joysticks exporting
> > > REL_HIRES_WHEEL?  
> > 
> > Sure. How many REL_MISC-n should be reserved?  
> 
> Not sure. As I mentioned, I haven' t seen such device myself, but maybe
> we should reserve the rest of the 0x0n range for those (0x0a-0x0f). This
> would force to bump REL_MAX, but I don't think this is an issue besides
> recompiling libevdev and others.

Ok, I'll do that on a separate patch.

Btw, you requested to rebase patches on the top of HID tree.

Well, if I rebase on the top of HID for_next branch, patches 1 and 2
will have (trivial) conflicts with input-next, due to the documentation
patches that got merged there.

I might rebase just patches 3 and 4, but, in this case, the HID
branch won't compile.

So, I guess either input should pull from HID or vice-versa, in order
to avoid such conflicts.

> 
> >   
> > > I'll try the rest of the series on the MX Master today.  
> > 
> > It would be great if you could test it!  
> 
> I found some issues, I'll report in the other patches.

Ok.

> 
> Cheers,
> Benjamin
> 
> > 
> > Regards,
> > Mauro  



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/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
index 92db50954169..0c8591d39bc6 100644
--- a/Documentation/input/event-codes.rst
+++ b/Documentation/input/event-codes.rst
@@ -185,10 +185,20 @@  instead of EV_REL codes.
 
 A few EV_REL codes have special meanings:
 
-* REL_WHEEL, REL_HWHEEL:
+* REL_WHEEL:
 
-  - These codes are used for vertical and horizontal scroll wheels,
-    respectively.
+  - These codes are used for vertical scroll wheels.
+
+  - REL_WHEEL is for normal wheel operational mode, e. g. low-resolution
+    (line-based) scroll.
+
+  - REL_HIRES_WHEEL should be used when the wheel has two resolutions and it
+    is in high-resolution mode, e. g. the same angular movement that would
+    produce a single REL_WHEEL will produce multiple REL_HIRES_WHEEL events.
+
+* REL_HWHEEL:
+
+  - This code is used for horizontal scroll wheels.
 
 EV_ABS
 ------
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 3af60ee69053..23b2d377af59 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -703,6 +703,7 @@ 
 #define REL_DIAL		0x07
 #define REL_WHEEL		0x08
 #define REL_MISC		0x09
+#define REL_HIRES_WHEEL		0x0a
 #define REL_MAX			0x0f
 #define REL_CNT			(REL_MAX+1)