a1ive / grub2-filemanager

GRUB2-based file manager
https://a1ive.github.io/grub2-filemanager/
GNU General Public License v3.0
528 stars 106 forks source link

Change keyboard type when a language is selected #119

Closed steve6375 closed 4 years ago

steve6375 commented 4 years ago

Would be nice to cater for UK keyboard, QWERTZ keyboard, AZERTY keyboards, etc. Maybe have the F4 language also change keyboard type, but also have extra option to pick a different keyboard type?

a1ive commented 4 years ago

Would be nice to cater for UK keyboard, QWERTZ keyboard, AZERTY keyboards, etc.

I don't know how to add it and I can't test it because we all use en_US (QWERTY) keyboard in China.Any example?

steve6375 commented 4 years ago

https://fitzcarraldoblog.wordpress.com/2019/04/21/how-to-change-the-keymap-keyboard-layout-used-by-the-grub-shell-in-gentoo-linux/

insmod keylayouts

Once installed, it is easy to test - just press a key and see what letter is printed on the screen. For an AZERTY keyboard, if you press Q you will get A, for a QWERTZ keyboard if you press Y you will get Z, for a UK keyboard test, if you press @ you will get ".

steve6375 commented 4 years ago

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=686817

I also found the at_keyboard command to be unstable in grub2. This person suggest an ext_kbd module which may be a better approach. E2B has a selection of grub4dos keyboard translation files for different keyboards if that is any help.

I have no idea how to implement UEFI keyboard translation.

In principle, GRUB2 allows you to change the keyboard layout through its 'at_keyboard' input terminal. You can use the 'grub-mklayout' utility to create a GRUB keyboard layout, e.g., for dvorak:

ckbcomp dvorak | grub-mklayout -o dvorak.gkb

Create a 'layouts' subdirectory under your 'grub' directory, and copy the GRUB keyboard layout to it, e.g.:

mkdir /boot/grub/layouts cp dvorak.gkb /boot/grub/layouts

The 'keymap' command under GRUB (e.g., in your 'grub.cfg') will then load the keymap:

keymap dvorak

To actually use the keymap, you will have to switch the the 'at_keyboard' input terminal:

terminal_input at_keyboard

Trouble is, under a PC BIOS system, the 'at_keyboard' input terminal is broken. It is unclear to me how (or even, whether) it can be fixed.

Since I, too, got frustrated that I couldn't change the keyboard layout, I decided to try and create my own 'ext_kbd' input terminal, for personal use. The 'ext_kbd' input terminal implements something akin to the 'setkey' command that was available under what is now known as GRUB Legacy. It won't go into upstream, since it deviates from the infrastructure that GRUB already provides for changing the keyboard layout.

In any case, I'll attach a patch that will add support for my 'ext_kbd' module to GRUB, in case anyone is interested enough to try it. If you decide to apply the patch, then you will subsequently have to run './autogen.sh' before you run './configure'. Otherwise, the build process will not pick up the definition of the 'ext_kbd' module that the patch adds to the 'grub-core/Makefile.core.def' file.

steve6375 commented 4 years ago

I found this https://support.hpe.com/hpesc/public/docDisplay?docId=emr_na-c02851203 Maybe a uefi driver can be used?

steve6375 commented 4 years ago

at_keyboard.mod is also required to support at keyboard

then use

insmod at_keyboard.mod
terminal_input at_keyboard
keymap $prefix/layouts/uk.gkb

" and @ should be swapped

or keymap $prefix/layouts/german.gkb

y and z should be swapped

layouts.zip

https://fitzcarraldoblog.wordpress.com/2019/04/21/how-to-change-the-keymap-keyboard-layout-used-by-the-grub-shell-in-gentoo-linux/

steve6375 commented 4 years ago

test...

image

steve6375 commented 4 years ago

not sure if insmod keylayouts is needed ??

steve6375 commented 4 years ago

I used Mint to generate some files image

steve6375 commented 4 years ago

grub2_gkb_files.zip Here is assorted .gkb file generated from Linux Mint image

steve6375 commented 4 years ago

Would be nice to set the keyboard from users /boot/grubfm/config file.

steve6375 commented 4 years ago

us USA ad Andorra af Afghanistan ara Arabic al Albania am Armenia az Azerbaijan by Belarus be Belgium bd Bangladesh in India ba Bosnia and Herzegovina br Brazil bg Bulgaria ma Morocco mm Myanmar ca Canada cd Congo, Democratic Republic of the cn China hr Croatia cz Czechia dk Denmark nl Netherlands bt Bhutan ee Estonia ir Iran iq Iraq fo Faroe Islands fi Finland fr France gh Ghana gn Guinea ge Georgia de Germany gr Greece hu Hungary is Iceland il Israel it Italy jp Japan kg Kyrgyzstan kh Cambodia kz Kazakhstan la Laos latam Latin American lt Lithuania lv Latvia mao Maori me Montenegro mk Macedonia mt Malta mn Mongolia no Norway pl Poland pt Portugal ro Romania ru Russia rs Serbia si Slovenia sk Slovakia es Spain se Sweden ch Switzerland sy Syria tj Tajikistan lk Sri Lanka th Thailand tr Turkey tw Taiwan ua Ukraine gb United Kingdom uz Uzbekistan vn Vietnam kr Korea, Republic of nec_vndr/jp Japan (PC-98xx Series) ie Ireland pk Pakistan mv Maldives za South Africa epo Esperanto np Nepal ng Nigeria et Ethiopia sn Senegal brai Braille tm Turkmenistan ml Mali tz Tanzania

steve6375 commented 4 years ago

kbd_tw_il_ie.zip additional files

a1ive commented 4 years ago

If we load a gkb file 'keymap /xxx.gkb' how to restore the default qwerty keyboard ?

steve6375 commented 4 years ago

Presumably that is us.gkb?

steve6375 commented 4 years ago

.gkb files should be listed as 'executable' so use can select one of them from a folder. If secondary menu disabled they should just run? Or do you plan to add this into F4 menu?

de.gkb and gb.gkb seems to work ok in MBR and UEFI64.

steve6375 commented 4 years ago

keyboards.zip renamed .gkb files I have used _USA us.gkb so it appears at the top of the list for quick access.

steve6375 commented 4 years ago

P.S. in language.sh, languages are not listed alphabetically.

steve6375 commented 4 years ago

What are your plans for keyboard support? Will you add gkb files? Will you add F4 option?

a1ive commented 4 years ago

What are your plans for keyboard support? Will you add gkb files? Will you add F4 option?

no.

steve6375 commented 4 years ago

OK. I will add the files into agFM for E2B. Correct keyboard is required for user entry, editing files in agFM, console, etc.

steve6375 commented 4 years ago

I have tried this on a few systems now and it causes a lot of keyboard problems when console is changed to at_keyboard. e.g. on Asus Z87 UEFI64 - when at_keyboard is selected, keys such as CAPS LOCK, SCROLL LOCK NUM LOCK cause the LEDs on the keyboard to change, but all other normal keys do not seem to work (a-z, numbers, cursor keys, space, etc.).