[Spice-devel] How to adapt keymaps for spice-html5
Eric Grammatico
eric at grammatico.me
Wed Mar 9 10:54:23 UTC 2016
Hi There,
Thanks a lot Christophe for your support. I have now a complete setup supporting fr/latin9 keyboard !
I made a big step in my investigations, here is the summary:
1/ First I confirmed the keyboard settings in spiceqxl.xorg.conf are ignored.
-> In order to ensure the right keyboard is defined on Xorg server I used the following command:
$> /usr/bin/setxkbmap -model pc105 -layout fr -variant latin9
The -display parameter may be required.
2/ To grab the keycode form Xorg I used the following command:
$> showkey -k
Each time a key is pressed/released, The keycode is displayed
3/ To grab the keycode from HTML5 I used the following page:
http://www.cambiaresearch.com/articles/15/javascript-key-codes
4/ From there I've been able to rewrite utils.js and atKeynames.js and it works!
-> I have a strange behaviour with ^ key, but the AltGr + o/i/u does the stuff. ê is obtained with AltGr + $
Next step will be to clean up a bit my updates and make the keyboard selection possible.
I'll keep you posted.
thanks and regards,
-
_/) Eric Grammatico.
8 mars 2016 10:58 "Christophe Fergeau" <cfergeau at redhat.com> a écrit:
> Hey,
>
> I experimented a bit with this..
>
> On Mon, Mar 07, 2016 at 02:43:16PM +0000, Eric Grammatico wrote:
>
>> The comments from the js file says:
>>
>> * definition of the AT84/MF101/MF102 Keyboard
>>
>> I had a look in Google to see a picture of a AT84.... Wahou ! Does someone believe a user will type
>> on a AT84 using Xspice ? Last time I saw this kind of keyboard I was desperately trying to have
>> something out of RPGII on an IBM36....
>
> The relevant article would be
> https://en.wikipedia.org/wiki/Scancode
> These AT84 scancodes still show up with modern hardware/OSes, which is why
> you are seeing this reference.
>
>> I believe this AT84 is defined somewhere overwriting my keyboard config in spiceqxl.xorg.conf. From
>> my point of view there is no reason to modified any javascript if on server side it's reading the
>> wrong keyboard model/layout. Any idea where to have further investigation ?
>
> When you press a key on your keyboard, a scancode is sent to the OS,
> which then maps it to the appropriate character depending on your OS
> settings. For example, on a French or English keyboard, the A/Q keys are
> in the same location and they return the same scancode, and then the OS
> maps this scancode to an A or a Q depending on the keyboard layout which
> was set.
>
> SPICE tries to send these low level scancodes, so that everything works
> as if this was an actual keyboard on the VM side.
> However, this breaks down with spice-html5. spice-html5 cannot get the
> raw scancode from a keypress, so instead it relies on a mapping from the
> character returned by the OS to the scancode. This mapping will be
> dependent on the current layout configured in the OS unfortunately, for
> example for this A/Q situation I mentioned before..
>
> For a given key on your keyboard, you can get the proper scancode to
> send using
> SPICE_DEBUG=1 remote-viewer spice://localhost:5900 |grep "key_event
> press"
> The 'keycode' value is the one you want.
> Then in utils.js, I added a
> console.log("Code: ", code)
> to get_scancode()
>
> Finally, you need to make sure that one of the scanmap has a mapping
> from the utils.js code to the remote-viewer code.
> For example, the diff below gives me proper output for the three keys right of
> N on a French keyboard (the ,? ;. :/ keys). The client OS and the guest OS
> have to be configured to use a French layout, otherwise this does not work (I
> did this configuration using gnome-control-center).
>
> @@ -198,7 +198,6 @@ common_scanmap[96] = KEY_KP_0;
> common_scanmap[110] = KEY_KP_Decimal;
> common_scanmap[191] = KEY_Slash;
> common_scanmap[190] = KEY_Period;
> -common_scanmap[188] = KEY_Comma;
> common_scanmap[220] = KEY_BSlash;
> common_scanmap[192] = KEY_Tilde;
> common_scanmap[222] = KEY_Quote;
> @@ -209,6 +208,10 @@ common_scanmap[91] = 0xE05B; //KEY_LMeta
> common_scanmap[92] = 0xE05C; //KEY_RMeta
> common_scanmap[93] = 0xE05D; //KEY_Menu
>
> +common_scanmap[58] = 52;
> +common_scanmap[59] = 51;
> +common_scanmap[188] = 50;
> +
> /* Firefox/Mozilla codes */
> var firefox_scanmap = [];
> firefox_scanmap[173] = KEY_Minus;
>
> Hope that helps,
>
> Christophe
More information about the Spice-devel
mailing list