Pimping your Brazilian keyboard

by Michael S. Kaplan, published on 2006/10/07 03:09 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/10/07/799605.aspx


Can we actually talk about pimping our Brazilian keyboards with Carnival not happening for so many months? :-) 

The other day when I helped Olivier with his question (well a part of it, at least) and Emerson's earlier identical question in In case you have a yen to extend your keyboard (or at least want a yen?), in response to one of Emerson's additional questions about other VK values he could use, I suggested VK_ABNT_C1 and VK_ABNT_C2, which are defined in kbd.h instead of winuser.h like all of the other virtual key codes.

A bunch of people asked me offline why, and a few of them even tried using the Brazilian keyboards in MSKLC which did not work for them (at least not for these two keys).

And then to top it all off, someone just asked Dr. International:

Hi
I'm using MS Keyboard Layout Creator, and figure out that MSKLC has no support for extra brasilian key.
The "portuguese ABNT2" keyboard has a key ("/" "?") between shift and VK_OEM_2 witch can not be used on new layouts.
There's a version of MSKLC witch can assign a letter to this Key? Will you support this in next versions?
Thanks

I decided maybe I should help people pimp that MSKLC-created Brazilian keyboard the same way I helped folks pimp the Japanese one. :-)

Now just like with the Japanese layout, the appropriate scan codes are not queried, which is why neither of the Brazilian keyboards

 

even when selected in MSKLC:

handle this key properly.

(ABNT is ASSOCIAÇÃO BRASILEIRA DE NORMAS TÉCNICAS, which is the national standards setting body in Brazil)

For what its worth you can note that the two layouts are actually identical under Windows and point to the same layout DLL, which is why this KB article exists (in real life, one is a subset of the other, which is why the GlobalDev keyboard layout site does not list them both)

Now, if you move over to kbd.h, you can see the VK definitions we will use:

#define VK_ABNT_C1 0xC1
#define VK_ABNT_C2 0xC2

and if you do not have an ABNT or ABNT2 keyboard to test them with, you can search down a bit in the header file to find that the two scan codes are pretty consistently 0x73 and 0x7e.

So the two entries you have to add to the .KLC file (just before the VK_DECIMAL definition, also included below), are:

73  ABNT_C1     0   /   ?
7e  ABNT_C2     0   .   .
53  DECIMAL     0   ,   ,

Once they are added, MSKLC will respect them if they are there so you can make other modifications if you need to (just like with that extra key on the Japanese keyboard!).

They still will not show up in the MSKLC main dialog:

 

but that is just something you can ignore (if you want to change the definition of them you have to do it manually in the .KLC file; note that not even the GlobalDev site displays the location of both of the keys....

So, will this blog entry make you happy? Wealthy? More likely to get lucky if you make it down to Carnival next year?

No, probably not. Sorry!

But it will help you to pimp your Brazilian Portuguese ABNT/ABNT2 keyboards in MSKLC, something that this site didn't know how to do and so did not try! :-)

 

This post brought to you by (U+0c2f, a.k.a. TELUGU LETTER YA)


Emerson on 12 Oct 2006 12:39 AM:

Hello, Michael.

Actually I could not get my keyboard the way I want... I did not miss the YEN SIGN that much, but I cannot say the same for the VERTICAL LINE. I had to place it on DIGIT ZERO on SHIFT STATE as a temporary solution.

Here's what happens when I try to use VK_ABNT_C1 and C2 (I gave up trying to find other "free" VKs...)

If I try to use ABNT_C2 for scancode 7d, I get a message box with the following:

Error 2020 (..\.\tmpKBDNAME.txt, line 76):

VK_ABNT_C2 (c2) found at scancode 7d and 7e.

And if I try using ABNT_C1 for the same scancode, I get:

(Box title: Microsoft .NET Framework)

An unhandled exception has occurred in your application. If you click Continue, the application will ignore this error ad attempt to continue. If you click Quit, the application will be shut down immediately.

Value cannot be null.

Parameter name: format.

There's a button labeled "Details". They are:

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************

System.ArgumentNullException: Value cannot be null.

Parameter name: format

  at System.String.Format(IFormatProvider provider, String format, Object[] args)

  at Microsoft.Globalization.Tools.KeyboardLayoutCreator.Keyboard.BuildKeyboard()

  at Microsoft.Globalization.Tools.KeyboardLayoutCreator.Keyboard.mnuProjectPackage_Click(Object sender, EventArgs e)

  at System.Windows.Forms.MenuItem.OnClick(EventArgs e)

  at System.Windows.Forms.MenuItemData.Execute()

  at System.Windows.Forms.Command.Invoke()

  at System.Windows.Forms.Control.WmCommand(Message& m)

  at System.Windows.Forms.Control.WndProc(Message& m)

  at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

  at System.Windows.Forms.ContainerControl.WndProc(Message& m)

  at System.Windows.Forms.Form.WndProc(Message& m)

  at Microsoft.Globalization.Tools.KeyboardLayoutCreator.Keyboard.WndProc(Message& m)

  at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

  at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************

mscorlib

   Assembly Version: 1.0.5000.0

   Win32 Version: 1.1.4322.2032

   CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll

----------------------------------------

msklc

   Assembly Version: 1.3.4073.0

   Win32 Version: 1.3.4073.0

   CodeBase: file:///C:/Arquivos%20de%20programas/Microsoft%20Keyboard%20Layout%20Creator/msklc.exe

----------------------------------------

System.Windows.Forms

   Assembly Version: 1.0.5000.0

   Win32 Version: 1.1.4322.2032

   CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll

----------------------------------------

System

   Assembly Version: 1.0.5000.0

   Win32 Version: 1.1.4322.2032

   CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll

----------------------------------------

System.Drawing

   Assembly Version: 1.0.5000.0

   Win32 Version: 1.1.4322.2032

   CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll

----------------------------------------

************** JIT Debugging **************

To enable just in time (JIT) debugging, the config file for this

application or machine (machine.config) must have the

jitDebugging value set in the system.windows.forms section.

The application must also be compiled with debugging

enabled.

For example:

<configuration>

   <system.windows.forms jitDebugging="true" />

</configuration>

When JIT debugging is enabled, any unhandled exception

will be sent to the JIT debugger registered on the machine

rather than being handled by this dialog.

When I try to use ABNT_C2, MSKLC does not build DLL and setup package. When I try to use ABNT_C1, the program generates the DLL, but not the setup package.

Michael S. Kaplan on 12 Oct 2006 1:02 AM:

Well, did you try my other suggestion -- building the dll from kbdutool.exe from the command line? Once you have added these additional character entries? That works just fine for me, so if it doesn't work for you I'd need to see what entries you used....

In other words, build the package without them, then build the DLL separately and stick it in the package.

Michael S. Kaplan on 12 Oct 2006 1:32 AM:

By the way, the actual error you are seeing is because the entry you put in was not correct. If you let me know what you added I can help you fix the problem that cause the exception....

UPDATE: the problem appers to be that you are putting in duplicate entries, which you cannot do, for either VK or scan code values. You must never do that....

Emerson on 12 Oct 2006 3:39 PM:

My entries are 73 and 7d:

39 SPACE 0 0020 0020 0020 -1 -1 // SPACE, SPACE, SPACE, <none>, <none>

73 OEM_8 0 005c 005f -1 -1 -1 // REVERSE SOLIDUS, LOW LINE, <none>, <none>, <none>

7d ABNT_C1 0 00a5 007c -1 -1 -1 // YEN SIGN, VERTICAL LINE, <none>, <none>, <none>

53 DECIMAL 0 002c 002e -1 -1 -1 // COMMA, FULL STOP, , ,

or

39 SPACE 0 0020 0020 0020 -1 -1 // SPACE, SPACE, SPACE, <none>, <none>

73 OEM_8 0 005c 005f -1 -1 -1 // REVERSE SOLIDUS, LOW LINE, <none>, <none>, <none>

7d ABNT_C2 0 00a5 007c -1 -1 -1 // YEN SIGN, VERTICAL LINE, <none>, <none>, <none>

53 DECIMAL 0 002c 002e -1 -1 -1 // COMMA, FULL STOP, , ,

I'll try building from the command line.

Emerson on 12 Oct 2006 4:16 PM:

It worked wonderfully (building the DLL separately)! Thanks a lot!!!


Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2008/10/27 Not only going BACK, but changing how to do it

2008/06/27 Adding keys to your layout when you don't know what they are (aka Life with a 108-key keyboard layout)

2008/05/16 My Spidey senses blame the rogue text editor

2007/07/04 Pimping the numeric keypad

go to newer or older post, or back to index or month or day