xorgproto: missing _EVDEVK() entries for some keys

2024-12-16 Thread Oliver Gerlich

Hello,

in xorgproto project in include/X11/XF86keysym.h file there are some
keys for which no _EVDEVK(...) line exists. E.g. for the subtitle key
there is only this line:


#define XF86XK_Subtitle  0x1008ff9a  /* cycle through subtitle  
*/


But there is no line like this:


#define XF86XK_Subtitle _EVDEVK(0x172)  /* KEY_SUBTITLE 
*/


My understanding is that the XF86keysym.h file is used to generate the
"evdev" section in
https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/master/symbols/inet
; but only lines with an _EVDEVK() entry are regarded by the generator.

I want to use XKB to map some keys from infrared remote controls, to
improve out-of-the-box support for remote controls in Kodi media center
(for https://github.com/xbmc/xbmc/issues/16834). Since these keys are
not listed in the symbols/inet file, XKB cannot map them, and therefore
Kodi cannot handle them.

I have now run scripts/keysym-generator.py without a --kernel-versions
parameter, to generate an XF86keysym.h file that contains _EVDEVK()
entries for _all_ keys, regardless of the kernel version. The script was
run on a system with libevdev 1.12.1+dfsg-1 and python-libevdev 0.11.
The diff to
https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/blob/e312ab76c4d93f2e637ac0c73987b22cd43420c7/include/X11/XF86keysym.h
is attached.

In the diff I see that additional _EVDEVK() lines were generated for 132
keys.

Would it be possible and sensible to add _EVDEVK() lines for all of
these keys, so that XF86keysym.h supports all evdev keys?

Alternatively, would it be possible to add _EVDEVK() lines for keys that
are related to media controls? The table at
https://www.kernel.org/doc/html/v6.11/userspace-api/media/rc/rc-tables.html
shows which keys would be interesting.

Should I just submit a merge request for one of these approaches?

Thanks,
Oliver Gerlich
--- include/X11/XF86keysym.h	2024-12-09 21:02:07.297023228 +0100
+++ include/X11/XF86keysym.h.new1	2024-12-09 21:09:20.526311394 +0100
@@ -272,10 +272,66 @@
  */
 #define _EVDEVK(_v) (0x10081000 + _v)
 /* Use: XF86XK_Eject_EVDEVK(0x0a2) KEY_EJECTCLOSECD */
+#define XF86XK_Nextsong _EVDEVK(0x0a3)  /* KEY_NEXTSONG */
+#define XF86XK_Playpause_EVDEVK(0x0a4)  /* KEY_PLAYPAUSE */
+#define XF86XK_Previoussong _EVDEVK(0x0a5)  /* KEY_PREVIOUSSONG */
+#define XF86XK_Stopcd   _EVDEVK(0x0a6)  /* KEY_STOPCD */
+#define XF86XK_Record   _EVDEVK(0x0a7)  /* KEY_RECORD */
+#define XF86XK_Rewind   _EVDEVK(0x0a8)  /* KEY_REWIND */
+#define XF86XK_Phone_EVDEVK(0x0a9)  /* KEY_PHONE */
+#define XF86XK_Iso  _EVDEVK(0x0aa)  /* KEY_ISO */
+#define XF86XK_Config   _EVDEVK(0x0ab)  /* KEY_CONFIG */
+#define XF86XK_Homepage _EVDEVK(0x0ac)  /* KEY_HOMEPAGE */
+#define XF86XK_Refresh  _EVDEVK(0x0ad)  /* KEY_REFRESH */
+#define XF86XK_Exit _EVDEVK(0x0ae)  /* KEY_EXIT */
+#define XF86XK_Move _EVDEVK(0x0af)  /* KEY_MOVE */
+#define XF86XK_Edit _EVDEVK(0x0b0)  /* KEY_EDIT */
+#define XF86XK_Scrollup _EVDEVK(0x0b1)  /* KEY_SCROLLUP */
+#define XF86XK_Scrolldown   _EVDEVK(0x0b2)  /* KEY_SCROLLDOWN */
+#define XF86XK_Kpleftparen  _EVDEVK(0x0b3)  /* KEY_KPLEFTPAREN */
+#define XF86XK_Kprightparen _EVDEVK(0x0b4)  /* KEY_KPRIGHTPAREN */
 /* Use: XF86XK_New  _EVDEVK(0x0b5) v2.6.14 KEY_NEW */
 /* Use: XK_Redo _EVDEVK(0x0b6) v2.6.14 KEY_REDO */
 /* KEY_DASHBOARD has been mapped to LaunchB in xkeyboard-config since 2011 */
+#define XF86XK_F13  _EVDEVK(0x0b7)  /* KEY_F13 */
+#define XF86XK_F14  _EVDEVK(0x0b8)  /* KEY_F14 */
+#define XF86XK_F15  _EVDEVK(0x0b9)  /* KEY_F15 */
+#define XF86XK_F16  _EVDEVK(0x0ba)  /* KEY_F16 */
+#define XF86XK_F17  _EVDEVK(0x0bb)  /* KEY_F17 */
+#define XF86XK_F18  _EVDEVK(0x0bc)  /* KEY_F18 */
+#define XF86XK_F19  _EVDEVK(0x0bd)  /* KEY_F19 */
+#define XF86XK_F20  _EVDEVK(0x0be)  /* KEY_F20 */
+#define XF86XK_F21  _EVDEVK(0x0bf)  /* KEY_F21 */
+#define XF86XK_F22  _EVDEVK(0x0c0)  /* KEY_F22 */
+#define XF86XK_F23  _EVDEVK(0x0c1)  /* KEY_F23 */
+#define XF86XK_F24  _EVDEVK(0x0c2)  /* KEY_F24 */
+#define XF86XK_Playcd   _EVDEVK(0x0c8)  /* KEY_PLAYCD */
+#define XF86XK_Pausecd  

Re: xorgproto: missing _EVDEVK() entries for some keys

2024-12-16 Thread Peter Hutterer
On Sun, Dec 15, 2024 at 07:00:12PM +0100, Oliver Gerlich wrote:
> Hello,
> 
> in xorgproto project in include/X11/XF86keysym.h file there are some
> keys for which no _EVDEVK(...) line exists. E.g. for the subtitle key
> there is only this line:
> 
> > #define XF86XK_Subtitle  0x1008ff9a  /* cycle through subtitle  
> > */
> 
> But there is no line like this:
> 
> > #define XF86XK_Subtitle _EVDEVK(0x172)  /* 
> > KEY_SUBTITLE */
> 
> My understanding is that the XF86keysym.h file is used to generate the
> "evdev" section in
> https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/master/symbols/inet
> ; but only lines with an _EVDEVK() entry are regarded by the generator.

For years we added things manually to the keysyms whenever the kernel
added new key codes but that was mostly pointless busywork and keysyms
easily got forgotten. The _EVDEVK macro exists so we can automate this
but one drawback is that any keysyms that were added before this macro
still need to be tended to manually. XF86XK_Subtitle was added in 2008,
well before the automation with the macro so it'll need manual attention
everywhere, including any mappings in xkeyboard-config.

Having a normal define and an _EVDEVK define would be a bug.

> I want to use XKB to map some keys from infrared remote controls, to
> improve out-of-the-box support for remote controls in Kodi media center
> (for https://github.com/xbmc/xbmc/issues/16834). Since these keys are
> not listed in the symbols/inet file, XKB cannot map them, and therefore
> Kodi cannot handle them.
> 
> I have now run scripts/keysym-generator.py without a --kernel-versions
> parameter, to generate an XF86keysym.h file that contains _EVDEVK()
> entries for _all_ keys, regardless of the kernel version. The script was
> run on a system with libevdev 1.12.1+dfsg-1 and python-libevdev 0.11.
> The diff to
> https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/blob/e312ab76c4d93f2e637ac0c73987b22cd43420c7/include/X11/XF86keysym.h
> is attached.

ftr, libevdev uses kernel headers from its own tree so you should always
use the most recent libevdev to ensure you have all symbols available.

> In the diff I see that additional _EVDEVK() lines were generated for 132
> keys.
> 
> Would it be possible and sensible to add _EVDEVK() lines for all of
> these keys, so that XF86keysym.h supports all evdev keys?

Theoretically yes but they'll have to be filtered for
duplicates/existing mappings. When I originally added this I went back
all the way to kernels 2.6.11, see the commits leading up to
ea9cf61a1097ae2c8bebb5e967999a252f696835. There's of course the chance I
missed a few though.

IMO any additions of keysyms should be done per-kernel version so it's
easier to review.

> Alternatively, would it be possible to add _EVDEVK() lines for keys that
> are related to media controls? The table at
> https://www.kernel.org/doc/html/v6.11/userspace-api/media/rc/rc-tables.html
> shows which keys would be interesting.
> 
> Should I just submit a merge request for one of these approaches?

Yes, an MR would be much appreciated, much easier to review than patches
on a list. Thanks.

Cheers,
  Peter


> 
> Thanks,
> Oliver Gerlich

> --- include/X11/XF86keysym.h  2024-12-09 21:02:07.297023228 +0100
> +++ include/X11/XF86keysym.h.new1 2024-12-09 21:09:20.526311394 +0100
> @@ -272,10 +272,66 @@
>   */
>  #define _EVDEVK(_v) (0x10081000 + _v)
>  /* Use: XF86XK_Eject_EVDEVK(0x0a2) 
> KEY_EJECTCLOSECD */
> +#define XF86XK_Nextsong _EVDEVK(0x0a3)  /* 
> KEY_NEXTSONG */
> +#define XF86XK_Playpause_EVDEVK(0x0a4)  /* 
> KEY_PLAYPAUSE */
> +#define XF86XK_Previoussong _EVDEVK(0x0a5)  /* 
> KEY_PREVIOUSSONG */
> +#define XF86XK_Stopcd   _EVDEVK(0x0a6)  /* 
> KEY_STOPCD */
> +#define XF86XK_Record   _EVDEVK(0x0a7)  /* 
> KEY_RECORD */
> +#define XF86XK_Rewind   _EVDEVK(0x0a8)  /* 
> KEY_REWIND */
> +#define XF86XK_Phone_EVDEVK(0x0a9)  /* KEY_PHONE 
> */
> +#define XF86XK_Iso  _EVDEVK(0x0aa)  /* KEY_ISO */
> +#define XF86XK_Config   _EVDEVK(0x0ab)  /* 
> KEY_CONFIG */
> +#define XF86XK_Homepage _EVDEVK(0x0ac)  /* 
> KEY_HOMEPAGE */
> +#define XF86XK_Refresh  _EVDEVK(0x0ad)  /* 
> KEY_REFRESH */
> +#define XF86XK_Exit _EVDEVK(0x0ae)  /* KEY_EXIT 
> */
> +#define XF86XK_Move _EVDEVK(0x0af)  /* KEY_MOVE 
> */
> +#define XF86XK_Edit _EVDEVK(0x0b0)  /* KEY_EDIT 
> */
> +#define XF86XK_Scrollup _EVDEVK(0x0b1)  /* 
> KEY_SCROLLUP */
> +#define XF86XK_Scrolldown   _EVDEVK(0x0b2)  /* 
> KEY_SCROLLDOWN */
> +#define XF86XK_Kpleftparen  _EVDEVK