VirtualBox

Ticket #6046 (closed defect: duplicate)

Opened 4 years ago

Last modified 3 years ago

Key scancodes swapped with swedish keyboard layout

Reported by: wader Owned by:
Priority: minor Component: other
Version: VirtualBox 3.1.2 Keywords:
Cc: Guest type: Linux
Host type: Mac OS X

Description

Hello, im no keyboard expert but i want to share my findings

When i Linux as guest OS (Ubuntu 9.10) with a standard swedish USB keyboard (Dell keyboard) two keys are swapped. The keys are also swapped with the builtin swedish macbook keyboard.

Here is the standard swedish keyboard layout:  http://upload.wikimedia.org/wikipedia/commons/e/e0/KB_Sweden.svg

The swapped keys are "§½" and "<>|", the "§½" key generates scancode 0x2c and "<>|" generates 0x56

The attached patch fixes this but im quite sure that it will mess things up for other layouts, but what is the correct way to fix this?

Attachments

darwin-swedish-scancode-swap.patch Download (1.3 KB) - added by wader 4 years ago.
source.tar Download (7.5 KB) - added by claudio_ 4 years ago.
Source for creating test program

Change History

Changed 4 years ago by wader

comment:1 Changed 4 years ago by wader

I can get a similar result using a ~/.Xmodmap file: keycode 49 = less greater NoSymbol NoSymbol bar keycode 94 = section onehalf

comment:2 Changed 4 years ago by wader

Sorry, should use wikiformatting

keycode 49 = less greater NoSymbol NoSymbol bar
keycode 94 = section onehalf

comment:3 Changed 4 years ago by claudio_

While it is possible to remap the keys in applications it looks like this is a geniun bug. According to  http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc page 16 the key left to the "1" key should report scancode 0x29 and on page 17 you see that the extra key right to the left-shift key present on e.g. european keyboards should report keycode 0x56.

I wrote a tiny boot sector program which uses first Int16 to read the keyboard, then once you press the space key, will intercept scancodes sent to Int 15 (AH=4F) and finally once you held down a key long enough, will switch to read key values directly from the 8042 controller. In all instances I observe on my MacBook Pro (with OS X 10.6.2 and VirtualBox 3.1.2) that the scancodes are swapped with regard to Microsoft's specification.

Changed 4 years ago by claudio_

Source for creating test program

comment:4 Changed 4 years ago by claudio_

Unpack source.tar in any directory.

nasm is used to create the binary. Specify its location in the first line of the Makefile.

The command to create the CD iso image is OS X specific.

Also if make is executed without arguments it tries to run a VM with name "test" assuming it is set up to boot from the CD image. So execute once make keyboard.iso to create the CD image, then you can set up manually a VM. Later on you can just type make.

To just assemble the source to create a boot sector you can type make keyboard.

comment:5 Changed 4 years ago by claudio_

I just remembered, that I have a PC USB keyboard, so attached it to my Mac and run my little test program. Same error appears. The wrong scancodes are reported in VirtualBox.

comment:6 Changed 4 years ago by claudio_

By the way I forgot to mention, that I am not having a swedish but a swiss keayboard. Also other layouts are affected as seen in other bug reports: #5936 swiss german, #5185 hungarian, #4006 german, #2996 german microsoft natural keyboard, #1494 unknown. Also #5543 notices that the keycode on the japanese keyboard is mapped wrongly: "Oh, I now noticed that the key actually is considered accent grave".

comment:7 follow-up: ↓ 11 Changed 4 years ago by wader

So as i understand it, Mac OS X reports the wrong scan code to VirtualBox?

Have you tested to boot your test program natively? same result?

comment:8 Changed 4 years ago by wader

I had some problem reading the doc in OS X, here is link to read it using google docs

 http://docs.google.com/gview?url=http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc

comment:9 Changed 4 years ago by claudio_

Ah, I think I found the needed change to fix this.  http://www.virtualbox.org/browser/trunk/src/VBox/Frontends/VirtualBox/src/darwin/DarwinKeyboard.cpp shows this:

106 	/**
107 	 * This is derived partially from SDL_QuartzKeys.h and partially from testing.
108 	 *
109 	 * (The funny thing about the virtual scan codes on the mac is that they aren't
110 	 * offically documented, which is rather silly to say the least. Thus, the need
111 	 * for looking at SDL and other odd places for docs.)
112 	 */
   ...
126 	    0x56,                       /* between lshift and z. 'INT 1'? */
   ...
220 	    0x29,                       /* Zen/Han (JIS)   0x68 */

The codes on those two lines would need to be swapped. Line 126 should read

126         0x29,                       /* between lshift and z. */

and line 220 should read

220 	    0x56,                       /* Zen/Han (JIS)   0x68 */

The line number are not part of the file but shown by the subversion browser and I have copied them too, so you can see which lines I am talking about.

comment:10 follow-up: ↓ 12 Changed 4 years ago by wader

Yes, that is what my patch does

comment:11 in reply to: ↑ 7 Changed 4 years ago by claudio_

Replying to wader:

Have you tested to boot your test program natively? same result?

Tried yes, results none. Problem is that Macs use EFI with a BIOS emulation and I suspect the BIOS emulation is not complete.

comment:12 in reply to: ↑ 10 Changed 4 years ago by claudio_

Replying to wader:

Yes, that is what my patch does

Oops I overlooked that one, as everybody else here usually tells about remapping the keys in X. Yes I think this would be the correct patch.

comment:13 Changed 4 years ago by claudio_

I notice 0x29 is present on three different lines: 166, 218 and 220. I suppose all three need to be replaced by 0x56. The first one (line 166) to fix the issue affecting all keyboards and the other two (lines 218 and 220) to fix also the japanese keyboards as mentioned in #5543.

comment:14 Changed 3 years ago by poetzsch

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #2996.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use