# ABNT2 Keyboard



## neebz (May 11, 2021)

Hi, im new here (and with Freebsd), and I'm having trouble making my keyboard (br abnt2) work and my cli show characters like "ã".
keybord shorcuts like alt + q to "/" and alt + w to "?" don't work.

my /etc/rc.conf
have: 
	
	



```
keymap="br.kbd"
```

my: /boot/loader.conf
have: 
	
	



```
kern.vty="vt"
```

i edited: /etc/login.conf
to:

```
:charset=UTF-8:\
:lang=pt_BR.UTF-8:
```

and: /etc/profile
to:

```
LANG=pt_BR.UTF-8; export LANG
CHARSET=UTF-8; export CHARSET
```

my ~/.xinitrc
have: 
	
	



```
setxkbmap -model abnt2 -layout br
```
 (which for some reason does not change the default keyboard in xfce)

And yes, I have read the freebsd handbook, I also looked for threads on the forum and I still have difficulties.


----------



## T-Daemon (May 11, 2021)

neebz said:


> i edited: [file/etc/login.conf[/file]
> to:
> 
> ```
> ...


Have you run afterwards `cap_mkdb /etc/login.conf` ? And the user must log out, then log in to take effect of the new locale.


----------



## rigoletto@ (May 11, 2021)

neebz said:


> my /etc/rc.conf
> have:
> 
> 
> ...


Try: `keymap="br"`

I set keyboard for X like this:


```
Section "InputClass"
        Identifier "KeyboardDefaults"
        MatchIsKeyboard "on"
        Option "XkbLayout" "br"
        Option "XkbModel" "abnt2"
        Option "XkbVariant" "abnt2"
EndSection
```


----------



## rigoletto@ (May 11, 2021)

neebz said:


> and: /etc/profile
> to:
> 
> ```
> ...



What shell do you use?


----------



## neebz (May 11, 2021)

T-Daemon said:


> cap_mkdb /etc/login.conf


yes



rigoletto@ said:


> keymap="br"


ok



rigoletto@ said:


> I set keyboard for X like this:


where?



rigoletto@ said:


> What shell do you use?


the default (sh i think)

edit: i have changed to 
	
	



```
keymap="br"
```
 and still ot working alt + q to "/"


----------



## rigoletto@ (May 11, 2021)

neebz said:


> where?



xorg.conf or /usr/local/etc/X11/xorg.conf.d/somefile.conf (e.g. 00-keyboard.conf)



neebz said:


> the default (sh i think)



The default shell in FreeBSD is tcsh(1).



neebz said:


> and still ot working alt + q to "/"



Also doesn't work in here, I never used it before since I just type "/".


----------



## neebz (May 11, 2021)

rigoletto@ said:


> xorg.conf or /usr/local/etc/X11/xorg.conf.d/somefile.conf (e.g. 00-keyboard.conf)


it will change on the cli too?




rigoletto@ said:


> The default shell in FreeBSD is tcsh(1).


the default when you just press enter on adduser




rigoletto@ said:


> Also doesn't work in here, I never used it before since I just type "/".


I use it a lot, it would make it a lot easier for me to have "ã" and alt + q to "/" in the cli


----------



## rigoletto@ (May 11, 2021)

neebz said:


> it will change on the cli too?


What CLI, console or graphic (aka X) terminal? This is the configuration for X.



neebz said:


> the default when you just press enter on adduser


I've not installed FreeBSD since years but IIRC is tcsh(1).



neebz said:


> I use it a lot, it would make it a lot easier for me to have "ã" and alt + q to "/" in the cli


You can custom map it but you need to search the way. bindkey(1)


----------



## neebz (May 11, 2021)

rigoletto@ said:


> What CLI, console or graphic (aka X) terminal? This is the configuration for X.


Console




rigoletto@ said:


> You can custom map it but you need to search the way. bindkey(1)


so... I need to create a custom map to use a abnt2 keyboard on console?


----------



## T-Daemon (May 11, 2021)

neebz said:


> so... I need to create a custom map to use a abnt2 keyboard on console?


Not necessarily. To get 'ã' character in console with the default keymap, on a ABNT2 Keyboard the  'ã' +'a' keys needs to be  pressed.

If you want one key press  'ã' then yes. The keymap needs to be modified.

Move /usr/share/vt/keymaps/br.kbd to, i.e br.kbd.orig, copy br.kbd.orig to br.kbd, edit br.kbd. Change

```
040   dtil   dcir   nop    nop    dtil   dcir   nop    nop     O
to
040   0xe3   0xc3   nop    nop    dtil   dcir   nop    nop     O
```
When saving, the file is write protected, or make it writable or when in vi(1) `:w!`,

I haven't figured out how to Alt+Q = / but I could look into it.

Detailed explanation of map file format in kbdmap(5),


----------



## neebz (May 11, 2021)

T-Daemon said:


> 'ã' +'a


you mean "~"+"a"?

so, let me understand this: there is no 
	
	



```
keymap=something
```
 that will make things work like the default abnt2? with the "~"+"o" and alt shortcus and everything else?


----------



## T-Daemon (May 12, 2021)

neebz said:


> you mean "~"+"a"?


I see. I got mislead by this article.



neebz said:


> so, let me understand this: there is no
> keymap=something
> that will make things work like the default abnt2? with the "~"+"o" and alt shortcus and everything else?


`"~" + "o"` and `"~" + "a"` are working out of the box in the console (13.0). Remove all what you have modified in

```
- /boot/loader.conf # that one is not related to the problem but
   vt(4) is standard, no need to specify it explicitly
- /etc/profile
```

If the LANG environment is set in /etc/login.conf for system wide then there is no need to specify it again in the login shells, any login shells, global or local configuration file. If the user wants to override the global environment locally for his account this is best done, shell independent, in ~/.login_conf.

For the other missing key mappings, as it looks like the current br.kbd key map needs some modification. It's not a big deal, just edit the lines shown below.

Note: The modifier key is AltGr (Alt Graph) not Alt.

```
For  '/'  by AltGr + q
For  '?'  by AltGr + w

# vi /usr/share/vt/keymaps/br.kbd

edit
016   'q'    'Q'    dc1    dc1    'q'    'Q'    dc1    dc1     C
to
016   'q'    'Q'    dc1    dc1    '/'    '/'    dc1    dc1     C

017   'w'    'W'    etb    etb    'w'    'W'    etb    etb     C
to
017   'w'    'W'    etb    etb    '?'    '?'    etb    etb     C

:wq!

# kbdcontrol -l br
```
If there is  something else missing drop a note.


----------



## neebz (May 12, 2021)

perhaps is something that has to be changed about the fonts on the terminal then? 'cause "~"+"a" and "~"+"o" still show "?" and "?" on the screen


----------



## T-Daemon (May 13, 2021)

neebz said:


> perhaps is something that has to be changed about the fonts on the terminal then?


There is no specific font needed.

In virtual terminal console only the following two requirements are needed to have those special Brazilian Portuguese characters displayed ('~' + 'a'  and '~' + 'o'):


Key map set to 'br'
LANG environment must be set to UTF-8  to the login shell, which is default from 13.0 upwards. In 12.2 it must be set retrospectively
Assuming the user is added with the 'default' login class to the system, then /etc/login.conf must have set UTF-8 variables there:

```
default:\
        ...
        :charset=UTF-8:\
        :lang=C.UTF-8:
```
On 12.2, after editing login.conf, `cap_mkdb /etc/login.conf` must be executed, the user must log out and log in to make the new localization take effect.

If there is the need of a localization other then US, meaning, time, numeric, monetary, messages, then a country specific LANG UTF-8 environment can be set, i.e. `pt_BR.UTF-8`, but it is not a requirement to display those characters, the above variables in login.conf are sufficient.

This is a screenshot of a virtual console in 13.0-RELEASE, 'br' key map set, 104-key PC keyboard ( / and ? are printed by pressing AltGr+Q and AltGr+W with the modified br.kbd key map):




If there are other LANG environment settings somewhere else on your system, set global or per user, make sure to remove them.


----------



## neebz (May 14, 2021)

Still not working here =\
What font do you use?


----------



## T-Daemon (May 21, 2021)

Sorry neebz, I've overlooked your post (I've put the thread on 'watch' now).

The font in use in vt(4) is the default font of 12.2 and 13.0 (Terminus Font I believe). I haven't set a specific font. It's not needed to have the Brazilian Portuguese characters displayed.

On 12.2 and 13.0 all what is needed to display them is to have set `keymap=br` and the login shell to UTF-8. UTF-8 on 12.2 must be set after installation manually, preferable in login.conf (or ~/.login_conf), on 13.0 upwards it's default.

Do you have reverted (removed) all localization modifications in the shells global or per user base configuration files? There should be only in /etc/login.conf or the users ~/.login_conf `lang` and `charset` variables set.

What does `env | grep 'LANG\|CHARSET'` return?


----------



## neebz (May 26, 2021)

- FreeBSD 13 fresh install
-  modified the login_conf
-  cap_mkdb login_conf
- env | grep 'LANG\|CHARSET' returns 

LANG=pt_BR.UTF-8
MM_CHARSET=UTF-8

ã and õ still not working


----------



## T-Daemon (May 30, 2021)

I 'm unable to reproduce on my system, it just works out of the box, in a VM or on bare metal:

- FreeBSD 13.0-RELEASE
- a 104-key PC keyboard (not ABNT2 keyboard)
- `kbdcontrol -l br`
- ã Ã õ Õ in console are printed as shown in screenshot of post #14

Maybe the ABNT2 keyboard is not fully supported.  Have you tried with a non-ABNT2 keyboard (ABNT, 104/105-key PC)?


----------



## neebz (May 30, 2021)

If the abnt2 standard is not fully supported yet in 2021 this is quite discouraging for us =\ here in Brazil basically there are almost no one still using the "abnt1".

I don't want to be that annoying guy who will compare FreeBSD with other systems but it would be more interesting for us brazilian users to simply have the abnt2 option on the installation screen and that by default this would enable characters like "ã" and "õ" on terminal.

I can understand if I don't have complete language support in all applications, English is good enough for me. Not having support for abnt2 and these characters is another story =\

"Brazilian (accent keys)" and "Brazilian (without accent keys)" sounds veeeery strange for us. I don't know if i can ask to change that but Brazilian (ABNT) and Brazilian (ABNT2) should be the options.

Once again: I don't want to be that annoying guy, in fact I wouldn't have a problem asking and helping with support in this regard but I really don't know how to do it. 

If someone has a way on how to adjust this without having to log in to an interface, I will gladly eat humble pie and remove what I said without any problem but I must admit that this kind of thing has been quite discouraging in dealing with freebsd =\


----------



## rigoletto@ (May 30, 2021)

I switched to vt (I normally use sc due to nvidia) console and IIRC ã and õ were working fine on it (I will try again later). Also, sometimes you tell it doesn't work on console and others on terminal, those are different things that need different solutions. Are you talking about console (no graphic interface at all) or (a graphic, X) terminal?

*If this is a terminal try it:* `setxkbmap -model abnt2 -variant abnt2 -layout br`

*[EDIT]*
If you are using Wayland, I have no idea of how it work.


----------



## T-Daemon (May 30, 2021)

rigoletto@ said:


> Are you talking about console (no graphic interface at all) or (a graphic, X) terminal?


We are talking about console.

Off-topic:


rigoletto@ said:


> I switched to vt (I normally use sc due to nvidia)


If you are running 13.0 or CURRENT there is a patch (provided by Alex S aka shkhln) which might resolve garbled vt console with NVIDIA. I have myself an NVIDIA with the mentioned problem but I have no need to switch to vt console when running xorg, therefore didn't tried the patch yet.


----------



## T-Daemon (May 30, 2021)

neebz said:


> If the abnt2 standard is not fully supported yet in 2021 this is quite discouraging for us


We don't know yet if the hardware is the source of the problem, it's only a assumption, therefore I asked if you have another keyboard.

In case the characters are printed with that keyboard then there is confirmation the hardware (ABNT2 keyboard) is the problem. Or the characters are not printed then there might be a misconfiguration.

But it's highly likely there is a misconfiguration on your side. If rigoletto recalls correctly those characters work fine.


----------



## rigoletto@ (May 30, 2021)

I confirm `ãõç¹²³éè` all working normally on VT.

T-Daemon I will try the patch later. Thanks!


----------



## neebz (May 31, 2021)

rigoletto@ said:


> I confirm `ãõç¹²³éè` all working normally on VT.
> 
> T-Daemon I will try the patch later. Thanks!


Ok so, please, tell me exactly what i need to do on a freebsd 13 fresh install to have ãõç working on console 
please xD


----------



## rigoletto@ (May 31, 2021)

The only thing needed is setting `keymap="br"` on /etc/rc.conf, since LANG and CHARSET are already set to some UTF-8 by default on /etc/login.conf.

If this is not working I assume some some hardware issue/incompatibility.


----------



## neebz (Jun 1, 2021)

Same on virtualbox


----------



## T-Daemon (Jun 1, 2021)

Does your ABNT2 keyboard print those characters in xorg?

Maybe it's specific to your keyboard not working fully in console. Which brand and model is it?


----------



## neebz (Jun 1, 2021)

i doubt, i tried more than 5 keyboards here

yes, it prints on the interface

edit:
for some reason worked with 
	
	



```
hw.vga.textmode=0
```


----------



## T-Daemon (Jun 1, 2021)

neebz said:


> hw.vga.textmode=0


Interesting. 'vga' gave the hint where to look. I could reproduce the situation. Apparently there is a correlation between VGA mode and displayed characters.

Your solution works, but the displayed characters are not that pretty. Better remove `hw.vga.textmode` and set the parameters down below into loader.conf(5):

/boot/loader.conf

```
Option 1:

screen.textmode=0

Option 2:
If you want a higher screen resolution and smaller font size set instead

vbe_max_resolution="n"     # Replace "n" with desired resolution.
                           # See loader.conf(5) for predefined values or set custom.

screen.font="nxn"          # For font size see /boot/fonts
```


----------



## neebz (Jun 2, 2021)

ok, now 
	
	



```
ã õ ç
```
 are working

the alt gr keys are working with "¹²³£¢¬§ªº" (alt gr + 1 / 2 / 3 / 4 5 / 6 / = [ / ] ) symbols but no "/?°₢" (alt + q / w / e / c )

is there any way to upload something to patch this once and for all and ask to change the keyboard to abnt and abnt2 instead of braziliand and brazilian with accent keys on install?


----------



## T-Daemon (Jun 2, 2021)

neebz said:


> no "/?°₢" (alt + q / w / e / c )
> 
> is there any way to upload something to patch this once and for all ...



You can file a bug report at https://bugs.freebsd.org and propose the extra characters to be included to the 'br' key map with the patch file attached down below.

It modifies br.kbd, AltGr + q / w / e  to print / , ? , ° .

No cruzeiro sign. Unicode hex 0x20a2 for ₢  has no effect in console, only a rectangle is printed. The cruzeiro sign is not alone, many of the currency symbols are not displayed.


----------



## neebz (Jun 4, 2021)

Sorry if is a noob question but do you want me to include this patch in the bug report explaining the situation right?


----------



## T-Daemon (Jun 4, 2021)

neebz said:


> Sorry if is a noob question


Don't worry, no problem at all.



neebz said:


> do you want me to include this patch in the bug report explaining the situation right?


Yes. Please attach the patch to the problem report. After filing the PR drop a note here in this thread of the PR number. I will follow on bugzilla, contribute if necessary.

In the PR you can mention that the cruzeiro sign is not printed regardless of the correct unicode used (0x20a2). Maybe one of the developers are willing to look into it

I had a look at the source code but couldn't determine which files are responsible for the characters and currency signs printed in console.


----------



## neebz (Jun 5, 2021)

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256416 posted this, sorry if it was not correct xD


----------



## msplsh (Jun 5, 2021)

neebz said:


> sorry if it was not correct


You're doing fine.  Your English is fine.  Thanks for your persistence in making things better for your classmates.


----------



## neebz (Jun 10, 2021)

T-Daemon said:


> You can file a bug report at https://bugs.freebsd.org and propose the extra characters to be included to the 'br' key map with the patch file attached down below.
> 
> It modifies br.kbd, AltGr + q / w / e  to print / , ? , ° .
> 
> No cruzeiro sign. Unicode hex 0x20a2 for ₢  has no effect in console, only a rectangle is printed. The cruzeiro sign is not alone, many of the currency symbols are not displayed.


Could you provide me an alternate patch with the ₢ symbol even if it's not functional please?


----------



## T-Daemon (Jun 10, 2021)

neebz said:


> Could you provide me an alternate patch with the ₢ symbol even if it's not functional please?


Sure.

But first I like to ask if 'AltGr + c' prints the cruzeiro sign or the copyright sign ( © ) ? I tried to get more information about this matter, searched also in Portuguese, and found those two variants about that key combination on a ABNT2 keyboard.

Also in Xorg 'AltGr + c' prints the copyright sign (`setxkbdmap -variant abnt2 -layout br`).

Couldn't find any official information. Searched also on the ABNT web site, keyword 'teclado',  it brought up http://www.abnt.org.br/pesquisas/?searchword=teclado&x=0&y=0 , but the files are behind a pay wall.


----------



## rigoletto@ (Jun 10, 2021)

I can't see a point of having the "cruzeiro" symbol since it is gone for almost three decades.


----------



## msplsh (Jun 10, 2021)

1. It's in Unicode
2. The keyboard is supposed to generate it


----------



## rigoletto@ (Jun 10, 2021)

msplsh said:


> 2. The keyboard is supposed to generate it



I'm not so sure ABNT keep the "Cruzeiro" symbol in the specification since it make absolutely no sense anymore. Btw, I don't know of ever a single ABNT-2 keyboard with it printed on it, otherwise the "¢" (cent) is in place.

*[EDIT]*

I just had a look and the actual ₢ (Cruzeiro) symbol was officially abandonned in 1967 when "Cr$" became the official, later "NCr$" (Cruzeiro Novo), and then the "Cruzeiro" died in 1994 when the Real (R$) became the official Brazilian currency.

So, without looking the ABNT specification this is more likely the correct character to print is ©, this is what mine one print and rather more useful than ₢ (unless you are writting some papers about the history of Brazilian currencies).


----------



## neebz (Jun 10, 2021)

Correction:

Asked a lot of friends, this is what i have now: The keyboard IT'S SUPPOSED TO PRINT THE ₢ symbol by the ABNT2 standard, Windows prints this symbol BUT Linux USUALLY prints the © (probably because of what rigoletto said).

If i could choose, I think it would be better to print the ₢ symbol just because that is THE ABNT2 standard. I can totally understand the practical reasons to choose © symbol, but Alfredo said that both keymaps were ABNT2 based so...


----------



## rigoletto@ (Jun 10, 2021)

neebz said:


> Alt Gr + c in all my keyboards prints this: ₢



Interesting, I just had a look on another machine, this one running Arch Linux and "Alt Gr + c" printed ©; however both have Microsoft keyboards attached to it.


----------



## neebz (Jun 10, 2021)

sorry, i have edited xD


----------



## msplsh (Jun 11, 2021)

Some pictures of real keyboards that don't have the copyright symbol there.









						GitHub - fellipec/abnteuro: Layout de teclado Português - ABNT2 com símbolo do Euro (€)
					

Layout de teclado Português - ABNT2 com símbolo do Euro (€) - GitHub - fellipec/abnteuro: Layout de teclado Português - ABNT2 com símbolo do Euro (€)




					github.com


----------



## T-Daemon (Jun 11, 2021)

It looks like on online computer hardware selling platforms the greater part of ABNT2 keyboards don't have a Cruzeiro sign printed on the 'C' key, but there are a few with it. Here an example: [1]

Patch with the Cruzeiro sign added.


----------



## neebz (Jun 11, 2021)

msplsh said:


> Some pictures of real keyboards that don't have the copyright symbol there.
> 
> 
> 
> ...


Now i am realizing that the ABNT2 uses "€" instead of "°" too .-.


----------



## msplsh (Jun 11, 2021)

It seems to depend on if the keyboard has enough keys for /

No / Key, has ° on E
* T-Daemon's link
* White keyboard in my github link

Has / Key, has € on E
* Black keyboard in my github link
* Computer generated layout examples


----------

