Using xkbcomp for a specific device

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 26 22:27:06 PDT 2012


On Sun, Sep 16, 2012 at 01:41:02PM -0700, Darren Hart wrote:
> I'm looking to modify the keysyms of a remote that presents as a usbhid device.
> I also have an HP wireless keyboard and mouse combination device that I do not
> wish to modify. I'm trying to accomplish this with a combination of setxkbmap
> and xkbcomp, using the "-i device_id" to xkbcomp to modify the keymap of only
> the remote. The problem: both devices get remapped.
> 
> The following describes my system and the exact steps I've taken to try and
> remap the remote.
> 
> $ xinput --list 
> ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
> ⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
> ⎜   ↳ HOLTEK                                  	id=10	[slave  pointer  (2)]
> ⎜   ↳ HP HP Wireless Mini Keyboard            	id=11	[slave  pointer  (2)]
> ⎜   ↳ HP HP Wireless Mini Keyboard            	id=12	[slave  pointer  (2)]
> ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
>     ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
>     ↳ Power Button                            	id=6	[slave  keyboard (3)]
>     ↳ Video Bus                               	id=7	[slave  keyboard (3)]
>     ↳ Power Button                            	id=8	[slave  keyboard (3)]
>     ↳ HOLTEK                                  	id=9	[slave  keyboard (3)]
> 
> In the list above, the HOLTEK is the remote (it sends both keyboard and mouse
> events). Yes it's horrible, but it's what I have and I'd like to make it work. The
> two entries for the HP Wireless Mini Keyboard correspond to the single USB
> receiver for the keyboard and mouse.
> 

[...]

> The remote sends ctrl+p and ctrl+shift+p for pause and play. MythTV doesn't
> distinguish between the two, so I want to change the shifted P to another key,
> such as XF86AudioPlay. I'd also like to change the Backspace to Esc on the remote.
> I can make this work with the following script which I lifted from the MythTV
> wiki, and then modified:
> 
> #!/bin/sh
> set -x
> 
> remote_id=$(xinput list | sed -n 's/.*HOLTEK.*id=\([0-9]*\).*keyboard.*/\1/p')
> [ "$remote_id" ] || exit
> 
> mkdir -p /tmp/xkb/symbols
> cat >/tmp/xkb/symbols/custom <<\EOF
> xkb_symbols "remote" {
> 	key <AD10> {        [ p,    XF86AudioPlay ]       };
> 	key <BKSP> { [ Escape, Escape ] };
> };
> EOF
> 
> setxkbmap -device $remote_id -print | sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' | xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null
> 
> 
> Once run, the HP keyboard p and backspace keys continue to work. But once I run xev
> and press the play button, both the remote and the HP keyboard have been remapped.
> shift+p sends XF86AudioPlay and Backspace sends Esc on both devices. I checked that
> my version of xkbcomp contains the per-device patch by downloading the sources and
> checking the contents of xkbcomp.c:
 
[...]

> I also confirmed that if I send a bad device_id, the script displays X11 out of range
> errors, with the value to the operation being the hex value of the bogus device_id.
> No error is reported when I pass "9" (the device_id for the HOLTEK keyboard xinput
> assigns to the remote). If I use the HP Wireless xinput device IDs, the remapping does
> not take place.
> 
> I can reset the devices to their original state using:
> 
> $ setxkbmap -print | xkbcomp - $DISPLAY 2>/dev/null
> 
> If I try to use "-i 11" or "-i 12" to reset just the HP Wireless keyboard, the change doesn't take effect.
> 
> I am running on a 32 bit installation of Ubuntu 12.04 (Mythbuntu specifically). I've
> tried this in the XFCE desktop as well as with a .xinitrc with only an xterm running
> with the same results.
> 
> Am I on the right track? Or is there another method I should be considering?
> 
> Can anyone point to why xkbcomp appears to be sending the device_id, yet both
> the remote and the keyboard are being remapped?

not sure, this should work and testing it on my box here it does work
(tested on two keyboards). the 12.04 ubuntu X stack has a lot of input
patches that differ from upstream, so I suggest you try with an upstream X
server first.

Cheers,
   Peter



More information about the xorg mailing list